From 57a4e83d6954b4cb87cdd3c81d0919dc49757d11 Mon Sep 17 00:00:00 2001 From: Pavel Voborsky Date: Fri, 12 Nov 2021 15:05:45 +0100 Subject: [PATCH] Added isPhe attribute to Category TreeMenuItem entity --- CHANGELOG.md | 7 +++++++ doc/Article.md | 2 ++ doc/Category.md | 3 ++- src/Article/DTO/ProductRequest.php | 12 ++++++++++++ src/Article/Entity/Product.php | 12 +++++++++++- src/Category/Entity/TreeMenuItem.php | 10 +++++++++- src/MpApiClient.php | 2 +- tests/functional/ArticleClientCest.php | 1 + tests/functional/CategoryClientCest.php | 1 + tests/functional/bootstrap.php | 2 +- 10 files changed, 47 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39da918..f85d849 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ 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.0.0-beta.3 - 2021-11-25 + +### Added + +- `isPhe` attribute to Category client `TreeMenuItem` entity +- `weeeFee` attribute to `Product` entity and `ProductRequest` DTO + ## 4.0.0-beta.2 - 2021-11-22 ### Added diff --git a/doc/Article.md b/doc/Article.md index 34d71a6..bf85a18 100644 --- a/doc/Article.md +++ b/doc/Article.md @@ -120,6 +120,7 @@ Example above prints out "variableParameters": [], "partnerTitle": null, "brandId": "BRAND_ID", + "weeeFee": null, "id": "my-product-id", "articleId": 100001234567, "title": "Product title", @@ -216,6 +217,7 @@ Example above prints out "variableParameters": [], "partnerTitle": null, "brandId": "BRAND_ID", + "weeeFee": null, "id": "my-product-id", "articleId": 100001234567, "title": "Product title", diff --git a/doc/Category.md b/doc/Category.md index 6969942..5ad7bea 100644 --- a/doc/Category.md +++ b/doc/Category.md @@ -148,7 +148,8 @@ Example above prints out "segment": "MP" } ], - "url": "https://www.mall.cz/darkove-kose-pro-deti" + "url": "https://www.mall.cz/darkove-kose-pro-deti", + "isPhe": false }, ... ] diff --git a/src/Article/DTO/ProductRequest.php b/src/Article/DTO/ProductRequest.php index 337d73f..ef5b03f 100644 --- a/src/Article/DTO/ProductRequest.php +++ b/src/Article/DTO/ProductRequest.php @@ -21,6 +21,7 @@ final class ProductRequest extends AbstractArticleRequest private array $variableParameters = []; private ?string $partnerTitle = null; private ?string $brandId = null; + private ?float $weeeFee = null; public function __construct(string $id, string $title, string $shortDesc, string $longDesc, string $categoryId, int $vat, int $priority) { @@ -62,6 +63,7 @@ public static function createFromProduct(Product $product): self $self->setVariableParameters(...$product->getVariableParameters()); $self->setPartnerTitle($product->getPartnerTitle()); $self->setBrandId($product->getBrandId()); + $self->setWeeeFee($product->getWeeeFee()); /** @var Variant $variant - PHPStan false positive fix */ foreach ($product->getVariants() as $variant) { @@ -187,4 +189,14 @@ public function setBrandId(?string $brandId): void $this->brandId = $brandId; } + public function getWeeeFee(): ?float + { + return $this->weeeFee; + } + + public function setWeeeFee(?float $weeeFee): void + { + $this->weeeFee = $weeeFee; + } + } diff --git a/src/Article/Entity/Product.php b/src/Article/Entity/Product.php index e0dc538..e58dedc 100644 --- a/src/Article/Entity/Product.php +++ b/src/Article/Entity/Product.php @@ -27,6 +27,7 @@ final class Product extends AbstractArticle protected array $variableParameters; protected ?string $partnerTitle; protected ?string $brandId; + protected ?float $weeeFee; /** * @param string $id @@ -59,6 +60,7 @@ final class Product extends AbstractArticle * @param bool $mallboxAllowed * @param string|null $partnerTitle * @param string|null $brandId + * @param float|null $weeeFee */ private function __construct( string $id, @@ -90,7 +92,8 @@ private function __construct( PackageSizeEnum $packageSize, bool $mallboxAllowed, ?string $partnerTitle, - ?string $brandId + ?string $brandId, + ?float $weeeFee ) { parent::__construct( $id, @@ -124,6 +127,7 @@ private function __construct( $this->variableParameters = $variableParameters; $this->partnerTitle = $partnerTitle; $this->brandId = $brandId; + $this->weeeFee = $weeeFee; } /** @@ -165,6 +169,7 @@ public static function createFromApi(array $data): self (bool) $data['mallbox_allowed'], InputDataUtil::getNullableString($data, 'partner_title'), InputDataUtil::getNullableString($data, 'brand_id'), + InputDataUtil::getNullableFloat($data, 'weee_fee'), ); } @@ -206,4 +211,9 @@ public function getBrandId(): ?string return $this->brandId; } + public function getWeeeFee(): ?float + { + return $this->weeeFee; + } + } diff --git a/src/Category/Entity/TreeMenuItem.php b/src/Category/Entity/TreeMenuItem.php index 1c7fa0c..d47ece1 100644 --- a/src/Category/Entity/TreeMenuItem.php +++ b/src/Category/Entity/TreeMenuItem.php @@ -15,14 +15,16 @@ final class TreeMenuItem implements JsonSerializable private bool $categoryVisible; private TreeSapCategoryIterator $sapCategories; private string $url; + private bool $isPhe; - private function __construct(int $menuItemId, string $title, bool $categoryVisible, TreeSapCategoryIterator $sapCategories, string $url) + private function __construct(int $menuItemId, string $title, bool $categoryVisible, TreeSapCategoryIterator $sapCategories, string $url, bool $isPhe) { $this->menuItemId = $menuItemId; $this->title = $title; $this->categoryVisible = $categoryVisible; $this->sapCategories = $sapCategories; $this->url = $url; + $this->isPhe = $isPhe; } /** @@ -38,6 +40,7 @@ public static function createFromApi(array $data): self (bool) $data['categoryVisible'], TreeSapCategoryIterator::createFromApi($data['sapCategories']), (string) $data['url'], + (bool) $data['isPhe'], ); } @@ -66,4 +69,9 @@ public function getUrl(): string return $this->url; } + public function isPhe(): bool + { + return $this->isPhe; + } + } diff --git a/src/MpApiClient.php b/src/MpApiClient.php index b889565..910605b 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.0.0-beta'; + const APP_VERSION = '4.0.1-beta'; private BrandClientInterface $brandClient; private CategoryClientInterface $categoryClient; diff --git a/tests/functional/ArticleClientCest.php b/tests/functional/ArticleClientCest.php index 902f462..f3ec104 100644 --- a/tests/functional/ArticleClientCest.php +++ b/tests/functional/ArticleClientCest.php @@ -595,6 +595,7 @@ private function assertProductValues(FunctionalTester $I, ProductRequest $produc $I->assertEquals($productRequest->getPrice(), $product->getPrice()); $I->assertEquals($productRequest->getPartnerTitle(), $product->getPartnerTitle()); $I->assertEquals($productRequest->getBrandId(), $product->getBrandId()); + $I->assertEquals($productRequest->getWeeeFee(), $product->getWeeeFee()); $I->assertEquals($productRequest->getAvailability()->getStatus(), $product->getAvailability()->getStatus()); $I->assertEquals($productRequest->getAvailability()->getInStock(), $product->getAvailability()->getInStock()); } diff --git a/tests/functional/CategoryClientCest.php b/tests/functional/CategoryClientCest.php index 1a57795..122d10d 100644 --- a/tests/functional/CategoryClientCest.php +++ b/tests/functional/CategoryClientCest.php @@ -113,6 +113,7 @@ private function assertTreeMenuItems(FunctionalTester $I, TreeMenuItemIterator $ $I->assertIsInt($menuItem->getMenuItemId()); $I->assertIsString($menuItem->getTitle()); $I->assertIsString($menuItem->getUrl()); + $I->assertIsBool($menuItem->isPhe()); $I->assertInstanceOf(TreeSapCategoryIterator::class, $menuItem->getSapCategories()); $this->assertTreeSapCategories($I, $menuItem->getSapCategories()); diff --git a/tests/functional/bootstrap.php b/tests/functional/bootstrap.php index 5f0251a..5136b52 100644 --- a/tests/functional/bootstrap.php +++ b/tests/functional/bootstrap.php @@ -257,8 +257,8 @@ Fixtures::add( 'article-media', new MediaIterator( - new Media('https://i.cdn.nrholding.net/21749465', true), new Media('https://i.cdn.nrholding.net/21749466', false, null, true, false), + new Media('https://i.cdn.nrholding.net/21749465', true), ), );