Skip to content

Commit bdecc6d

Browse files
[2026-04-16] - Sync content (24501328830) (#46)
> [!NOTE] > This PR copies content from the source repo. > Source repo commit [b782410](shoptet/cms4@b782410) **List of changes:** - Introduction of new valueObject `TypeVatRateNullable` in the reqquest body of `updatePricelist` endpoint Co-authored-by: havlicekl <82386873+havlicekl@users.noreply.github.com>
1 parent 7436799 commit bdecc6d

4 files changed

Lines changed: 43 additions & 7 deletions

File tree

init.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@
342342
require_once __DIR__ . '/src/Component/ValueObject/TypeUnitRatio.php';
343343
require_once __DIR__ . '/src/Component/ValueObject/TypeVariantCodeRequest.php';
344344
require_once __DIR__ . '/src/Component/ValueObject/TypeVatRate.php';
345+
require_once __DIR__ . '/src/Component/ValueObject/TypeVatRateNullable.php';
345346
require_once __DIR__ . '/src/Component/ValueObject/TypeWeight.php';
346347
require_once __DIR__ . '/src/Component/ValueObject/TypeWeightRequest.php';
347348
require_once __DIR__ . '/src/Component/ValueObject/TypeWeightUnlimited.php';
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Shoptet\Api\Sdk\Php\Component\ValueObject;
4+
5+
use Shoptet\Api\Sdk\Php\Exception\InvalidArgumentException;
6+
7+
readonly class TypeVatRateNullable implements ValueObjectInterface
8+
{
9+
public function __construct(
10+
public ?string $typeVatRateNullable,
11+
) {
12+
if ($this->typeVatRateNullable === null) {
13+
return;
14+
}
15+
if (!preg_match('/^[0-9]+\.[0-9]{2}$/', $this->typeVatRateNullable)) {
16+
throw new InvalidArgumentException(sprintf('Invalid %s "%s".', 'typeVatRateNullable', $this->typeVatRateNullable));
17+
}
18+
}
19+
20+
public function equals(self $typeVatRateNullable): bool
21+
{
22+
return $typeVatRateNullable->typeVatRateNullable === $this->typeVatRateNullable;
23+
}
24+
25+
public function __toString(): string
26+
{
27+
return (string) $this->typeVatRateNullable;
28+
}
29+
30+
public function jsonSerialize(): string
31+
{
32+
return $this->__toString();
33+
}
34+
}

src/Endpoint/PriceLists/UpdatePricelistRequest/UpdatePricelistRequest/Data/Item.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Shoptet\Api\Sdk\Php\Endpoint\PriceLists\UpdatePricelistRequest\UpdatePricelistRequest\Data;
44

55
use Shoptet\Api\Sdk\Php\Component\Entity\Entity;
6-
use Shoptet\Api\Sdk\Php\Component\ValueObject\TypePriceNullable;
6+
use Shoptet\Api\Sdk\Php\Component\ValueObject\TypeVatRateNullable;
77
use Shoptet\Api\Sdk\Php\Endpoint\PriceLists\UpdatePricelistRequest\UpdatePricelistRequest\Data\Item\OrderableAmount;
88
use Shoptet\Api\Sdk\Php\Endpoint\PriceLists\UpdatePricelistRequest\UpdatePricelistRequest\Data\Item\Price;
99
use Shoptet\Api\Sdk\Php\Endpoint\PriceLists\UpdatePricelistRequest\UpdatePricelistRequest\Data\Item\PriceWithVat;
@@ -15,7 +15,7 @@ class Item extends Entity
1515
{
1616
protected string $code;
1717
protected ?string $currencyCode;
18-
protected ?TypePriceNullable $vatRate;
18+
protected ?TypeVatRateNullable $vatRate;
1919
protected ?bool $includingVat;
2020
protected ?OrderableAmount $orderableAmount;
2121
protected ?Sales $sales;
@@ -46,12 +46,12 @@ public function setCurrencyCode(?string $currencyCode): static
4646
return $this;
4747
}
4848

49-
public function getVatRate(): ?TypePriceNullable
49+
public function getVatRate(): ?TypeVatRateNullable
5050
{
5151
return $this->vatRate;
5252
}
5353

54-
public function setVatRate(?TypePriceNullable $vatRate): static
54+
public function setVatRate(?TypeVatRateNullable $vatRate): static
5555
{
5656
$this->vatRate = $vatRate;
5757
return $this;

src/Endpoint/PriceLists/UpdatePricelistRequest/UpdatePricelistRequest/Data/Item/Prices/PurchasePrice.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
use Shoptet\Api\Sdk\Php\Component\Entity\Entity;
66
use Shoptet\Api\Sdk\Php\Component\ValueObject\TypePriceNullable;
7+
use Shoptet\Api\Sdk\Php\Component\ValueObject\TypeVatRateNullable;
78

89
class PurchasePrice extends Entity
910
{
1011
protected ?TypePriceNullable $price;
11-
protected ?TypePriceNullable $vatRate;
12+
protected ?TypeVatRateNullable $vatRate;
1213
protected ?bool $includingVat;
1314

1415
public function getPrice(): ?TypePriceNullable
@@ -22,12 +23,12 @@ public function setPrice(?TypePriceNullable $price): static
2223
return $this;
2324
}
2425

25-
public function getVatRate(): ?TypePriceNullable
26+
public function getVatRate(): ?TypeVatRateNullable
2627
{
2728
return $this->vatRate;
2829
}
2930

30-
public function setVatRate(?TypePriceNullable $vatRate): static
31+
public function setVatRate(?TypeVatRateNullable $vatRate): static
3132
{
3233
$this->vatRate = $vatRate;
3334
return $this;

0 commit comments

Comments
 (0)