Skip to content

Commit

Permalink
Merge pull request #36 from klingac/feature/MAR-13225-orders-add-exte…
Browse files Browse the repository at this point in the history
…rnal-id

v4.2.0
  • Loading branch information
michalkelcik authored Aug 30, 2022
2 parents 8290e11 + c950e08 commit a5f5841
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/MpApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions src/Order/Entity/BasicOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,6 +33,7 @@ final class BasicOrder implements JsonSerializable

private function __construct(
int $id,
?string $externalId,
int $purchaseId,
int $customerId,
string $customer,
Expand All @@ -49,6 +51,7 @@ private function __construct(
bool $mdpSpectrum
) {
$this->id = $id;
$this->externalId = $externalId;
$this->purchaseId = $purchaseId;
$this->customerId = $customerId;
$this->customer = $customer;
Expand Down Expand Up @@ -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'],
Expand All @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions src/Order/Entity/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -53,6 +54,7 @@ final class Order implements JsonSerializable

private function __construct(
int $id,
?string $externalId,
int $purchaseId,
string $currency,
float $deliveryPrice,
Expand Down Expand Up @@ -91,6 +93,7 @@ private function __construct(
ConsignmentStatusHistoryIterator $consignmentStatusHistory
) {
$this->id = $id;
$this->externalId = $externalId;
$this->purchaseId = $purchaseId;
$this->currency = $currency;
$this->deliveryPrice = $deliveryPrice;
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions tests/functional/OrderClientCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit a5f5841

Please sign in to comment.