Skip to content

Commit

Permalink
Add some item fields
Browse files Browse the repository at this point in the history
  • Loading branch information
vollborn committed Aug 19, 2024
1 parent f62befb commit 026ed7b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "drei-d/laravel-jtl-api",
"description": "a JTL api wrapper for Laravel",
"type": "library",
"version": "1.2.0",
"version": "1.2.1",
"license": "MIT",
"require": {
"php": "^8.2",
Expand Down
19 changes: 19 additions & 0 deletions src/Modules/Item/DataTransferObjects/ItemCategoryDto.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace DREID\LaravelJtlApi\Modules\Item\DataTransferObjects;

readonly class ItemCategoryDto
{
public function __construct(
public int $categoryId,
public string $name,
) {}

public static function fromResponse(array $data): static
{
return new self(
$data['CategoryId'],
$data['Name'],
);
}
}
6 changes: 6 additions & 0 deletions src/Modules/Item/DataTransferObjects/ItemDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
public function __construct(
public int $id,
public string $sku,
public bool $isActive,
public array $categories,
public ?int $manufacturerId,
public string $name,
public ?string $description,
Expand All @@ -28,6 +30,10 @@ public static function fromResponse(array $data): static
return new self(
$data['Id'],
$data['SKU'],
$data['IsActive'],
array_map(static function ($data) {
return ItemCategoryDto::fromResponse($data);
}, $data['Categories'] ?? []),
$data['ManufacturerId'] ?? null,
$data['Name'],
$data['Description'] ?: null,
Expand Down

0 comments on commit 026ed7b

Please sign in to comment.