diff --git a/init.php b/init.php index bb86b47..3790014 100644 --- a/init.php +++ b/init.php @@ -348,6 +348,7 @@ require_once __DIR__ . '/src/Component/ValueObject/TypeGuid.php'; require_once __DIR__ . '/src/Component/ValueObject/TypeGuidNullable.php'; require_once __DIR__ . '/src/Component/ValueObject/TypeGuidUnlimited.php'; +require_once __DIR__ . '/src/Component/ValueObject/TypeHsCodeNullable.php'; require_once __DIR__ . '/src/Component/ValueObject/TypeNonEmptyString.php'; require_once __DIR__ . '/src/Component/ValueObject/TypePositiveAmount.php'; require_once __DIR__ . '/src/Component/ValueObject/TypePositiveAmountNullable.php'; diff --git a/src/Component/Entity/Product.php b/src/Component/Entity/Product.php index 951a619..1240ac7 100644 --- a/src/Component/Entity/Product.php +++ b/src/Component/Entity/Product.php @@ -19,6 +19,7 @@ use Shoptet\Api\Sdk\Php\Component\ValueObject\TypeAmountNullable; use Shoptet\Api\Sdk\Php\Component\ValueObject\TypeDateTimeNullable; use Shoptet\Api\Sdk\Php\Component\ValueObject\TypeGuidUnlimited; +use Shoptet\Api\Sdk\Php\Component\ValueObject\TypeHsCodeNullable; class Product extends Entity { @@ -39,6 +40,7 @@ class Product extends Entity protected ?string $conditionDescription; protected ?string $internalNote; protected ?bool $preauthorizationRequired; + protected TypeHsCodeNullable $hsCode; protected DefaultCategory $defaultCategory; protected ?Categories $categories; protected ?DescriptiveParameters $descriptiveParameters; @@ -258,6 +260,17 @@ public function setPreauthorizationRequired(?bool $preauthorizationRequired): st return $this; } + public function getHsCode(): TypeHsCodeNullable + { + return $this->hsCode; + } + + public function setHsCode(TypeHsCodeNullable $hsCode): static + { + $this->hsCode = $hsCode; + return $this; + } + public function getDefaultCategory(): DefaultCategory { return $this->defaultCategory; diff --git a/src/Component/Entity/ProductUpdate.php b/src/Component/Entity/ProductUpdate.php index 46c7209..6006bbb 100644 --- a/src/Component/Entity/ProductUpdate.php +++ b/src/Component/Entity/ProductUpdate.php @@ -12,6 +12,7 @@ use Shoptet\Api\Sdk\Php\Component\Entity\ProductUpdate\Variants; use Shoptet\Api\Sdk\Php\Component\ValueObject\TypeGuid; use Shoptet\Api\Sdk\Php\Component\ValueObject\TypeGuidNullable; +use Shoptet\Api\Sdk\Php\Component\ValueObject\TypeHsCodeNullable; class ProductUpdate extends Entity { @@ -31,6 +32,7 @@ class ProductUpdate extends Entity protected ?string $brandCode; protected ?string $internalNote; protected ?bool $preauthorizationRequired; + protected ?TypeHsCodeNullable $hsCode; protected ?TypeGuidNullable $supplierGuid; protected ?CategoryGuids $categoryGuids; protected ?int $warrantyId; @@ -219,6 +221,17 @@ public function setPreauthorizationRequired(?bool $preauthorizationRequired): st return $this; } + public function getHsCode(): ?TypeHsCodeNullable + { + return $this->hsCode; + } + + public function setHsCode(?TypeHsCodeNullable $hsCode): static + { + $this->hsCode = $hsCode; + return $this; + } + public function getSupplierGuid(): ?TypeGuidNullable { return $this->supplierGuid; diff --git a/src/Component/ValueObject/TypeHsCodeNullable.php b/src/Component/ValueObject/TypeHsCodeNullable.php new file mode 100644 index 0000000..c22f05a --- /dev/null +++ b/src/Component/ValueObject/TypeHsCodeNullable.php @@ -0,0 +1,34 @@ +typeHsCodeNullable === null) { + return; + } + if (!preg_match('/^\d{6,10}$/', $this->typeHsCodeNullable)) { + throw new InvalidArgumentException(sprintf('Invalid %s "%s".', 'typeHsCodeNullable', $this->typeHsCodeNullable)); + } + } + + public function equals(self $typeHsCodeNullable): bool + { + return $typeHsCodeNullable->typeHsCodeNullable === $this->typeHsCodeNullable; + } + + public function __toString(): string + { + return (string) $this->typeHsCodeNullable; + } + + public function jsonSerialize(): string + { + return $this->__toString(); + } +} diff --git a/src/Endpoint/Products/CreateProductRequest/CreateProductRequest/Data.php b/src/Endpoint/Products/CreateProductRequest/CreateProductRequest/Data.php index d51364d..d0bf9bd 100644 --- a/src/Endpoint/Products/CreateProductRequest/CreateProductRequest/Data.php +++ b/src/Endpoint/Products/CreateProductRequest/CreateProductRequest/Data.php @@ -4,6 +4,7 @@ use Shoptet\Api\Sdk\Php\Component\Entity\Entity; use Shoptet\Api\Sdk\Php\Component\ValueObject\TypeGuid; +use Shoptet\Api\Sdk\Php\Component\ValueObject\TypeHsCodeNullable; use Shoptet\Api\Sdk\Php\Endpoint\Products\CreateProductRequest\CreateProductRequest\Data\CategoryGuids; use Shoptet\Api\Sdk\Php\Endpoint\Products\CreateProductRequest\CreateProductRequest\Data\DescriptiveParameters; use Shoptet\Api\Sdk\Php\Endpoint\Products\CreateProductRequest\CreateProductRequest\Data\FilteringParameters; @@ -30,6 +31,7 @@ class Data extends Entity protected ?string $brandCode; protected ?string $internalNote; protected ?bool $preauthorizationRequired; + protected ?TypeHsCodeNullable $hsCode; protected ?TypeGuid $supplierGuid; protected ?CategoryGuids $categoryGuids; protected ?int $warrantyId; @@ -217,6 +219,17 @@ public function setPreauthorizationRequired(?bool $preauthorizationRequired): st return $this; } + public function getHsCode(): ?TypeHsCodeNullable + { + return $this->hsCode; + } + + public function setHsCode(?TypeHsCodeNullable $hsCode): static + { + $this->hsCode = $hsCode; + return $this; + } + public function getSupplierGuid(): ?TypeGuid { return $this->supplierGuid;