diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a7bcaf..7065204 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 4.2.0 - 2022-08-04 + +### Added + +- `externalId` attribute to orders + ## 4.1.2 - 2022-06-30 ### Added diff --git a/src/MpApiClient.php b/src/MpApiClient.php index 4f92562..07dfeb6 100644 --- a/src/MpApiClient.php +++ b/src/MpApiClient.php @@ -29,7 +29,7 @@ final class MpApiClient implements ClientInterface, MpApiClientInterface { const APP_NAME = 'mp-api-client'; - const APP_VERSION = '4.1.2'; + const APP_VERSION = '4.2.0'; private BrandClientInterface $brandClient; private CategoryClientInterface $categoryClient; diff --git a/src/Order/Entity/BasicOrder.php b/src/Order/Entity/BasicOrder.php index 620cc15..5080cb3 100644 --- a/src/Order/Entity/BasicOrder.php +++ b/src/Order/Entity/BasicOrder.php @@ -14,6 +14,7 @@ final class BasicOrder implements JsonSerializable use JsonSerializeEntityTrait; private int $id; + private ?string $externalId; private int $purchaseId; private int $customerId; private string $customer; @@ -32,6 +33,7 @@ final class BasicOrder implements JsonSerializable private function __construct( int $id, + ?string $externalId, int $purchaseId, int $customerId, string $customer, @@ -49,6 +51,7 @@ private function __construct( bool $mdpSpectrum ) { $this->id = $id; + $this->externalId = $externalId; $this->purchaseId = $purchaseId; $this->customerId = $customerId; $this->customer = $customer; @@ -76,6 +79,7 @@ public static function createFromApi(array $data): self { return new self( (int) $data['id'], + $data['external_id'] ?? null, (int) $data['purchase_id'], (int) $data['customer_id'], (string) $data['customer'], @@ -99,6 +103,11 @@ public function getId(): int return $this->id; } + public function getExternalId(): ?string + { + return $this->externalId; + } + public function getPurchaseId(): int { return $this->purchaseId; diff --git a/src/Order/Entity/Order.php b/src/Order/Entity/Order.php index 5c5e85e..68ae465 100644 --- a/src/Order/Entity/Order.php +++ b/src/Order/Entity/Order.php @@ -14,6 +14,7 @@ final class Order implements JsonSerializable use JsonSerializeEntityTrait; private int $id; + private ?string $externalId; private int $purchaseId; private string $currency; private float $deliveryPrice; @@ -53,6 +54,7 @@ final class Order implements JsonSerializable private function __construct( int $id, + ?string $externalId, int $purchaseId, string $currency, float $deliveryPrice, @@ -91,6 +93,7 @@ private function __construct( ConsignmentStatusHistoryIterator $consignmentStatusHistory ) { $this->id = $id; + $this->externalId = $externalId; $this->purchaseId = $purchaseId; $this->currency = $currency; $this->deliveryPrice = $deliveryPrice; @@ -139,6 +142,7 @@ public static function createFromApi(array $data): self { return new self( (int) $data['id'], + $data['external_id'] ?? null, (int) $data['purchase_id'], (string) $data['currency'], (float) $data['delivery_price'], @@ -183,6 +187,11 @@ public function getId(): int return $this->id; } + public function getExternalId(): ?string + { + return $this->externalId; + } + public function getPurchaseId(): int { return $this->purchaseId; diff --git a/tests/functional/OrderClientCest.php b/tests/functional/OrderClientCest.php index cee48b1..6fc4b8f 100644 --- a/tests/functional/OrderClientCest.php +++ b/tests/functional/OrderClientCest.php @@ -56,6 +56,9 @@ public function testList(FunctionalTester $I): void foreach ($orders as $order) { $I->assertIsInt($order->getId()); + if ($order->getExternalId() !== null) { + $I->assertIsString($order->getExternalId()); + } $I->assertIsInt($order->getPurchaseId()); $I->assertIsInt($order->getCustomerId()); $I->assertIsString($order->getCustomer());