Skip to content

Commit 8c775d1

Browse files
authored
Merge pull request #14 from codebar-ag/feature-new-requests
Add Missing Requests
2 parents 92b8c8f + 3315cec commit 8c775d1

File tree

130 files changed

+1624
-144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+1624
-144
lines changed

.phpunit.cache/test-results

+1-1
Large diffs are not rendered by default.

src/Dto/BankAccounts/BankAccountDTO.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ public function __construct(
1313
public int $id,
1414
public string $uuid,
1515
public string $name,
16-
public string $owner,
17-
public string $owner_address,
18-
public string $owner_zip,
19-
public string $owner_city,
20-
public string $bc_nr,
21-
public string $bank_name,
22-
public string $bank_account_nr,
23-
public string $iban_nr,
16+
public ?string $owner,
17+
public ?string $owner_address,
18+
public ?string $owner_zip,
19+
public ?string $owner_city,
20+
public ?string $bc_nr,
21+
public ?string $bank_name,
22+
public ?string $bank_account_nr,
23+
public ?string $iban_nr,
2424
public int $currency_id,
2525
public int $account_id,
26-
public string $is_esr,
27-
public string $invoice_mode,
26+
public ?string $is_esr,
27+
public ?string $invoice_mode,
2828
public string $type,
29-
public string $bank_nr,
29+
public ?string $bank_nr,
3030
public ?string $esr_besr_id = null,
3131
public ?string $esr_post_account_nr = null,
3232
public ?string $esr_payment_for_text = null,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace CodebarAg\Bexio\Dto\BusinessActivities;
4+
5+
use Exception;
6+
use Illuminate\Support\Arr;
7+
use Saloon\Http\Response;
8+
use Spatie\LaravelData\Data;
9+
10+
class BusinessActivityDTO extends Data
11+
{
12+
public function __construct(
13+
public int $id,
14+
public string $name,
15+
public ?bool $default_is_billable,
16+
public ?float $default_price_per_hour,
17+
public ?int $account_id,
18+
) {}
19+
20+
public static function fromResponse(Response $response): self
21+
{
22+
if ($response->failed()) {
23+
throw new \Exception('Failed to create DTO from Response');
24+
}
25+
26+
$data = $response->json();
27+
28+
return self::fromArray($data);
29+
}
30+
31+
public static function fromArray(array $data): self
32+
{
33+
if (! $data) {
34+
throw new Exception('Unable to create DTO. Data missing from response.');
35+
}
36+
37+
return new self(
38+
id: Arr::get($data, 'id'),
39+
name: Arr::get($data, 'name'),
40+
default_is_billable: Arr::get($data, 'default_is_billable'),
41+
default_price_per_hour: Arr::get($data, 'default_price_per_hour'),
42+
account_id: Arr::get($data, 'account_id'),
43+
);
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
3+
namespace CodebarAg\Bexio\Dto\DocumentSettings;
4+
5+
use Exception;
6+
use Illuminate\Support\Arr;
7+
use Saloon\Http\Response;
8+
use Spatie\LaravelData\Data;
9+
10+
class DocumentSettingDTO extends Data
11+
{
12+
public function __construct(
13+
public int $id,
14+
public string $text,
15+
public string $kb_item_class,
16+
public ?string $enumeration_format,
17+
public ?bool $user_automatic_enumeration,
18+
public ?bool $user_yearly_enumeration,
19+
public int $next_nr,
20+
public int $nr_min_length,
21+
public int $default_time_period_in_days,
22+
public int $default_logopaper_id,
23+
public int $default_language_id,
24+
public ?int $default_client_bank_account_new_id,
25+
public int $default_currency_id,
26+
public int $default_mwst_type,
27+
public bool $default_mwst_is_net,
28+
public int $default_nb_decimals_amount,
29+
public int $default_nb_decimals_price,
30+
public bool $default_show_position_taxes,
31+
public string $default_title,
32+
public bool $default_show_esr_on_same_page,
33+
public ?int $default_payment_type_id,
34+
public ?int $kb_terms_of_payment_template_id,
35+
public bool $default_show_total,
36+
) {}
37+
38+
public static function fromResponse(Response $response): self
39+
{
40+
if ($response->failed()) {
41+
throw new \Exception('Failed to create DTO from Response');
42+
}
43+
44+
$data = $response->json();
45+
46+
return self::fromArray($data);
47+
}
48+
49+
public static function fromArray(array $data): self
50+
{
51+
if (! $data) {
52+
throw new Exception('Unable to create DTO. Data missing from response.');
53+
}
54+
55+
return new self(
56+
id: Arr::get($data, 'id'),
57+
text: Arr::get($data, 'text'),
58+
kb_item_class: Arr::get($data, 'kb_item_class'),
59+
enumeration_format: Arr::get($data, 'enumeration_format'),
60+
user_automatic_enumeration: Arr::get($data, 'user_automatic_enumeration'),
61+
user_yearly_enumeration: Arr::get($data, 'user_yearly_enumeration'),
62+
next_nr: Arr::get($data, 'next_nr'),
63+
nr_min_length: Arr::get($data, 'nr_min_length'),
64+
default_time_period_in_days: Arr::get($data, 'default_time_period_in_days'),
65+
default_logopaper_id: Arr::get($data, 'default_logopaper_id'),
66+
default_language_id: Arr::get($data, 'default_language_id'),
67+
default_client_bank_account_new_id: Arr::get($data, 'default_client_bank_account_new_id'),
68+
default_currency_id: Arr::get($data, 'default_currency_id'),
69+
default_mwst_type: Arr::get($data, 'default_mwst_type'),
70+
default_mwst_is_net: Arr::get($data, 'default_mwst_is_net'),
71+
default_nb_decimals_amount: Arr::get($data, 'default_nb_decimals_amount'),
72+
default_nb_decimals_price: Arr::get($data, 'default_nb_decimals_price'),
73+
default_show_position_taxes: Arr::get($data, 'default_show_position_taxes'),
74+
default_title: Arr::get($data, 'default_title'),
75+
default_show_esr_on_same_page: Arr::get($data, 'default_show_esr_on_same_page'),
76+
default_payment_type_id: Arr::get($data, 'default_payment_type_id'),
77+
kb_terms_of_payment_template_id: Arr::get($data, 'kb_terms_of_payment_template_id'),
78+
default_show_total: Arr::get($data, 'default_show_total'),
79+
);
80+
}
81+
}

src/Dto/Invoices/InvoiceDTO.php

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
3+
namespace CodebarAg\Bexio\Dto\Invoices;
4+
5+
use Exception;
6+
use Illuminate\Support\Arr;
7+
use Illuminate\Support\Collection;
8+
use Saloon\Http\Response;
9+
use Spatie\LaravelData\Data;
10+
11+
class InvoiceDTO extends Data
12+
{
13+
public function __construct(
14+
public int $id,
15+
public string $document_nr,
16+
public ?string $title,
17+
public ?int $contact_id,
18+
public ?int $contact_sub_id,
19+
public int $user_id,
20+
public ?int $project_id,
21+
public ?int $logopaper_id, // Deprecated
22+
public int $language_id,
23+
public int $bank_account_id,
24+
public int $currency_id,
25+
public int $payment_type_id,
26+
public string $header,
27+
public string $footer,
28+
public string $total_gross,
29+
public string $total_net,
30+
public string $total_taxes,
31+
public string $total_received_payments,
32+
public string $total_credit_vouchers,
33+
public string $total_remaining_payments,
34+
public string $total,
35+
public int|float $total_rounding_difference,
36+
public int $mwst_type,
37+
public bool $mwst_is_net,
38+
public bool $show_position_taxes,
39+
public string $is_valid_from,
40+
public string $is_valid_to,
41+
public string $contact_address,
42+
public int $kb_item_status_id,
43+
public ?string $reference,
44+
public ?string $api_reference,
45+
public ?string $viewed_by_client_at,
46+
public string $updated_at,
47+
public int $esr_id,
48+
public int $qr_invoice_id,
49+
public ?string $template_slug,
50+
public Collection $taxs,
51+
public ?string $network_link,
52+
) {}
53+
54+
public static function fromResponse(Response $response): self
55+
{
56+
if ($response->failed()) {
57+
throw new \Exception('Failed to create DTO from Response');
58+
}
59+
60+
$data = $response->json();
61+
62+
return self::fromArray($data);
63+
}
64+
65+
public static function fromArray(array $data): self
66+
{
67+
if (! $data) {
68+
throw new Exception('Unable to create DTO. Data missing from response.');
69+
}
70+
71+
return new self(
72+
id: Arr::get($data, 'id'),
73+
document_nr: Arr::get($data, 'document_nr'),
74+
title: Arr::get($data, 'title'),
75+
contact_id: Arr::get($data, 'contact_id'),
76+
contact_sub_id: Arr::get($data, 'contact_sub_id'),
77+
user_id: Arr::get($data, 'user_id'),
78+
project_id: Arr::get($data, 'project_id'),
79+
logopaper_id: Arr::get($data, 'logopaper_id'),
80+
language_id: Arr::get($data, 'language_id'),
81+
bank_account_id: Arr::get($data, 'bank_account_id'),
82+
currency_id: Arr::get($data, 'currency_id'),
83+
payment_type_id: Arr::get($data, 'payment_type_id'),
84+
header: Arr::get($data, 'header'),
85+
footer: Arr::get($data, 'footer'),
86+
total_gross: Arr::get($data, 'total_gross'),
87+
total_net: Arr::get($data, 'total_net'),
88+
total_taxes: Arr::get($data, 'total_taxes'),
89+
total_received_payments: Arr::get($data, 'total_received_payments'),
90+
total_credit_vouchers: Arr::get($data, 'total_credit_vouchers'),
91+
total_remaining_payments: Arr::get($data, 'total_remaining_payments'),
92+
total: Arr::get($data, 'total'),
93+
total_rounding_difference: Arr::get($data, 'total_rounding_difference'),
94+
mwst_type: Arr::get($data, 'mwst_type'),
95+
mwst_is_net: Arr::get($data, 'mwst_is_net'),
96+
show_position_taxes: Arr::get($data, 'show_position_taxes'),
97+
is_valid_from: Arr::get($data, 'is_valid_from'),
98+
is_valid_to: Arr::get($data, 'is_valid_to'),
99+
contact_address: Arr::get($data, 'contact_address'),
100+
kb_item_status_id: Arr::get($data, 'kb_item_status_id'),
101+
reference: Arr::get($data, 'reference'),
102+
api_reference: Arr::get($data, 'api_reference'),
103+
viewed_by_client_at: Arr::get($data, 'viewed_by_client_at'),
104+
updated_at: Arr::get($data, 'updated_at'),
105+
esr_id: Arr::get($data, 'esr_id'),
106+
qr_invoice_id: Arr::get($data, 'qr_invoice_id'),
107+
template_slug: Arr::get($data, 'template_slug'),
108+
taxs: collect(Arr::get($data, 'taxs', []))->map(fn (array $tax) => InvoiceTaxDTO::fromArray($tax)),
109+
network_link: Arr::get($data, 'network_link'),
110+
);
111+
}
112+
}

src/Dto/Invoices/InvoiceTaxDTO.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace CodebarAg\Bexio\Dto\Invoices;
4+
5+
use Exception;
6+
use Illuminate\Support\Arr;
7+
use Saloon\Http\Response;
8+
use Spatie\LaravelData\Data;
9+
10+
class InvoiceTaxDTO extends Data
11+
{
12+
public function __construct(
13+
public float $percentage,
14+
public float $value,
15+
) {}
16+
17+
public static function fromResponse(Response $response): self
18+
{
19+
if ($response->failed()) {
20+
throw new \Exception('Failed to create DTO from Response');
21+
}
22+
23+
$data = $response->json();
24+
25+
return self::fromArray($data);
26+
}
27+
28+
public static function fromArray(array $data): self
29+
{
30+
if (! $data) {
31+
throw new Exception('Unable to create DTO. Data missing from response.');
32+
}
33+
34+
return new self(
35+
percentage: Arr::get($data, 'percentage'),
36+
value: Arr::get($data, 'value'),
37+
);
38+
}
39+
}

src/Dto/Languages/LanguageDTO.php

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace CodebarAg\Bexio\Dto\Languages;
4+
5+
use Exception;
6+
use Illuminate\Support\Arr;
7+
use Saloon\Http\Response;
8+
use Spatie\LaravelData\Data;
9+
10+
class LanguageDTO extends Data
11+
{
12+
public function __construct(
13+
public int $id,
14+
public string $name,
15+
public string $decimal_point,
16+
public string $thousands_separator,
17+
public int $date_format_id,
18+
public string $date_format,
19+
public string $iso_639_1,
20+
) {}
21+
22+
public static function fromResponse(Response $response): self
23+
{
24+
if ($response->failed()) {
25+
throw new \Exception('Failed to create DTO from Response');
26+
}
27+
28+
$data = $response->json();
29+
30+
return self::fromArray($data);
31+
}
32+
33+
public static function fromArray(array $data): self
34+
{
35+
if (! $data) {
36+
throw new Exception('Unable to create DTO. Data missing from response.');
37+
}
38+
39+
return new self(
40+
id: Arr::get($data, 'id'),
41+
name: Arr::get($data, 'name'),
42+
decimal_point: Arr::get($data, 'decimal_point'),
43+
thousands_separator: Arr::get($data, 'thousands_separator'),
44+
date_format_id: Arr::get($data, 'date_format_id'),
45+
date_format: Arr::get($data, 'date_format'),
46+
iso_639_1: Arr::get($data, 'iso_639_1'),
47+
);
48+
}
49+
}

0 commit comments

Comments
 (0)