Skip to content

Commit 7d3cd79

Browse files
committed
Updated DTO and tested it with real API for creating fixtures
1 parent 8bbb806 commit 7d3cd79

23 files changed

+280
-41
lines changed

.phpunit.cache/test-results

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,13 +2040,16 @@ $items = $connector->send(new SearchItemsRequest(
20402040
*/
20412041
$item = $connector->send(new CreateItemRequest(
20422042
data: new CreateEditItemDTO(
2043+
user_id: 1,
20432044
article_type_id: 1,
20442045
intern_code: 'ITEM-001',
20452046
intern_name: 'Test Item',
20462047
intern_description: 'Item Description',
20472048
sale_price: '20.00',
20482049
purchase_price: '10.00',
20492050
currency_id: 1,
2051+
tax_income_id: 14,
2052+
tax_expense_id: 21,
20502053
unit_id: 1,
20512054
)
20522055
))->dto();
@@ -2059,6 +2062,7 @@ $item = $connector->send(new CreateItemRequest(
20592062
$item = $connector->send(new EditAnItemRequest(
20602063
article_id: 1,
20612064
data: new CreateEditItemDTO(
2065+
user_id: 1,
20622066
article_type_id: 1,
20632067
intern_code: 'ITEM-001',
20642068
intern_name: 'Updated Item Name',

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<php>
2323
<env name="APP_KEY" value="base64:F+mHMDBbavrsp/I3WYA5lDSwDJJI/0wQG4eM3csq/lo="/>
2424
<env name="BEXIO_API_TOKEN" value=""/>
25+
<env name="RESET_FIXTURES" value="false"/>
2526
</php>
2627
<source>
2728
<include>

src/Dto/Items/CreateEditItemDTO.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public function __construct(
2525
public ?float $sale_total = null,
2626
public ?int $currency_id = null,
2727
public ?int $tax_income_id = null,
28-
public ?int $tax_id = null,
2928
public ?int $tax_expense_id = null,
3029
public ?int $unit_id = null,
3130
public bool $is_stock = false,
@@ -78,7 +77,6 @@ public static function fromArray(array $data): self
7877
sale_total: Arr::get($data, 'sale_total'),
7978
currency_id: Arr::get($data, 'currency_id'),
8079
tax_income_id: Arr::get($data, 'tax_income_id'),
81-
tax_id: Arr::get($data, 'tax_id'),
8280
tax_expense_id: Arr::get($data, 'tax_expense_id'),
8381
unit_id: Arr::get($data, 'unit_id'),
8482
is_stock: Arr::get($data, 'is_stock', false),

src/Requests/Items/CreateItemRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct(
2323

2424
public function resolveEndpoint(): string
2525
{
26-
return '/3.0/article';
26+
return '/2.0/article';
2727
}
2828

2929
protected function defaultBody(): array

src/Requests/Items/DeleteAnItemRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function __construct(
1717

1818
public function resolveEndpoint(): string
1919
{
20-
return '/3.0/article/'.$this->article_id;
20+
return '/2.0/article/'.$this->article_id;
2121
}
2222

2323
public function createDtoFromResponse(Response $response): mixed

src/Requests/Items/EditAnItemRequest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(
2424

2525
public function resolveEndpoint(): string
2626
{
27-
return '/3.0/article/'.$this->article_id;
27+
return '/2.0/article/'.$this->article_id;
2828
}
2929

3030
protected function defaultBody(): array
@@ -35,7 +35,11 @@ protected function defaultBody(): array
3535
$body = CreateEditItemDTO::fromArray($body);
3636
}
3737

38-
return $body->toArray();
38+
$data = $body->toArray();
39+
40+
unset($data['article_type_id']);
41+
42+
return $data;
3943
}
4044

4145
public function createDtoFromResponse(Response $response): ItemDTO

src/Requests/Items/FetchAListOfItemsRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct(
2222

2323
public function resolveEndpoint(): string
2424
{
25-
return '/3.0/article';
25+
return '/2.0/article';
2626
}
2727

2828
public function defaultQuery(): array

src/Requests/Items/FetchAnItemRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function __construct(
1818

1919
public function resolveEndpoint(): string
2020
{
21-
return '/3.0/article/'.$this->article_id;
21+
return '/2.0/article/'.$this->article_id;
2222
}
2323

2424
public function createDtoFromResponse(Response $response): ItemDTO

src/Requests/Items/SearchItemsRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(
3030

3131
public function resolveEndpoint(): string
3232
{
33-
return '/3.0/article/search';
33+
return '/2.0/article/search';
3434
}
3535

3636
public function defaultQuery(): array

0 commit comments

Comments
 (0)