-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Setono\PeakWMS\Client\Endpoint; | ||
|
||
use Setono\PeakWMS\DataTransferObject\Collection; | ||
use Setono\PeakWMS\DataTransferObject\Product\Product; | ||
|
||
/** | ||
* @extends Endpoint<Product> | ||
*/ | ||
final class ProductEndpoint extends Endpoint implements ProductEndpointInterface | ||
{ | ||
/** | ||
* @use CreatableEndpointTrait<Product> | ||
*/ | ||
use CreatableEndpointTrait; | ||
|
||
use DeletableEndpointTrait; | ||
|
||
public function getByProductId(string $productId): Collection | ||
{ | ||
/** @var class-string<Collection<Product>> $signature */ | ||
$signature = sprintf('%s<%s>', Collection::class, self::getDataClass()); | ||
|
||
return $this | ||
->mapperBuilder | ||
->mapper() | ||
->map( | ||
$signature, | ||
$this->createSource( | ||
$this->client->get(sprintf('%s/%s', $this->endpoint, $productId)), | ||
), | ||
); | ||
} | ||
|
||
protected static function getDataClass(): string | ||
{ | ||
return Product::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Setono\PeakWMS\Client\Endpoint; | ||
|
||
use Setono\PeakWMS\DataTransferObject\Collection; | ||
use Setono\PeakWMS\DataTransferObject\Product\Product; | ||
|
||
/** | ||
* @extends EndpointInterface<Product> | ||
* @extends CreatableEndpointInterface<Product> | ||
*/ | ||
interface ProductEndpointInterface extends EndpointInterface, CreatableEndpointInterface, DeletableEndpointInterface | ||
{ | ||
/** | ||
* @return Collection<Product> | ||
*/ | ||
public function getByProductId(string $productId): Collection; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Setono\PeakWMS\DataTransferObject; | ||
|
||
/** | ||
* @template T of AbstractDataTransferObject | ||
* | ||
* @implements \IteratorAggregate<int, T> | ||
*/ | ||
final class Collection implements \IteratorAggregate, \Countable | ||
{ | ||
/** @var list<T> */ | ||
public array $items; | ||
|
||
/** | ||
* @param list<T> $items | ||
*/ | ||
public function __construct(array $items = []) | ||
{ | ||
$this->items = $items; | ||
} | ||
|
||
public function empty(): bool | ||
{ | ||
return [] === $this->items; | ||
} | ||
|
||
/** | ||
* @return \ArrayIterator<int<0, max>, T> | ||
*/ | ||
public function getIterator(): \ArrayIterator | ||
{ | ||
return new \ArrayIterator($this->items); | ||
} | ||
|
||
public function count(): int | ||
{ | ||
return count($this->items); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Setono\PeakWMS\DataTransferObject\Product; | ||
|
||
use Setono\PeakWMS\DataTransferObject\AbstractDataTransferObject; | ||
|
||
final class Product extends AbstractDataTransferObject | ||
{ | ||
public function __construct( | ||
public ?string $createdAt = null, | ||
public ?string $updatedAt = null, | ||
public ?int $id = null, | ||
public ?string $productId = null, | ||
public ?string $variantId = null, | ||
public ?string $itemNumber = null, | ||
public ?string $description = null, | ||
public ?string $comment = null, | ||
public ?string $countryOfOrigin = null, | ||
public ?string $quantityInUnits = null, | ||
public ?string $units = null, | ||
/** | ||
* @var list<array{code: string}>|null | ||
*/ | ||
public ?array $customsTariffs = null, | ||
public ?string $imagePath = null, | ||
public ?string $ean = null, | ||
public ?int $state = null, | ||
public ?int $pickType = null, | ||
public ?int $cycleCountThreshold = null, | ||
public ?int $cycleCountInterval = null, | ||
public ?int $weight = null, | ||
public ?int $netWeight = null, | ||
public ?int $volume = null, | ||
public ?int $length = null, | ||
public ?int $width = null, | ||
public ?int $height = null, | ||
public ?float $averageCostPrice = null, | ||
public ?float $costPricePiece = null, | ||
public ?float $salesPricePerPiece = null, | ||
public ?bool $bestBeforeDateControlled = null, | ||
public ?bool $lotNumberControlled = null, | ||
public ?bool $lotRequiredForOrder = null, | ||
public ?bool $includeInPoForecast = null, | ||
public ?string $variantMaster = null, | ||
public ?int $minStockThreshold = null, | ||
public ?int $maxStockThreshold = null, | ||
public ?string $brand = null, | ||
public ?int $availableToSell = null, | ||
public ?int $availableInStock = null, | ||
public ?int $orderedByCustomers = null, | ||
public ?bool $production = null, | ||
public ?bool $autoAssignLot = null, | ||
/** | ||
* @var list<array{name: string, vendorName: string}>|null | ||
*/ | ||
public ?array $vendors = null, | ||
/** | ||
* @var list<string>|null | ||
*/ | ||
public ?array $allowedAreas = null, | ||
public ?string $dangerousGoodsClass = null, | ||
public ?string $size = null, | ||
public ?string $composition = null, | ||
public ?string $collection = null, | ||
public ?string $sizeRange = null, | ||
public ?string $styleNumber = null, | ||
public ?string $styleDescription = null, | ||
public ?string $colorNumber = null, | ||
public ?string $colorDescription = null, | ||
public ?string $productGroup = null, | ||
) { | ||
} | ||
} |