Skip to content

Commit

Permalink
Added isPhe attribute to Category TreeMenuItem entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Voborsky authored and michalsalon-mall committed Nov 25, 2021
1 parent f56b0fb commit 57a4e83
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions doc/Article.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion doc/Category.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
...
]
Expand Down
12 changes: 12 additions & 0 deletions src/Article/DTO/ProductRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

}
12 changes: 11 additions & 1 deletion src/Article/Entity/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ final class Product extends AbstractArticle
protected array $variableParameters;
protected ?string $partnerTitle;
protected ?string $brandId;
protected ?float $weeeFee;

/**
* @param string $id
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -90,7 +92,8 @@ private function __construct(
PackageSizeEnum $packageSize,
bool $mallboxAllowed,
?string $partnerTitle,
?string $brandId
?string $brandId,
?float $weeeFee
) {
parent::__construct(
$id,
Expand Down Expand Up @@ -124,6 +127,7 @@ private function __construct(
$this->variableParameters = $variableParameters;
$this->partnerTitle = $partnerTitle;
$this->brandId = $brandId;
$this->weeeFee = $weeeFee;
}

/**
Expand Down Expand Up @@ -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'),
);
}

Expand Down Expand Up @@ -206,4 +211,9 @@ public function getBrandId(): ?string
return $this->brandId;
}

public function getWeeeFee(): ?float
{
return $this->weeeFee;
}

}
10 changes: 9 additions & 1 deletion src/Category/Entity/TreeMenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -38,6 +40,7 @@ public static function createFromApi(array $data): self
(bool) $data['categoryVisible'],
TreeSapCategoryIterator::createFromApi($data['sapCategories']),
(string) $data['url'],
(bool) $data['isPhe'],
);
}

Expand Down Expand Up @@ -66,4 +69,9 @@ public function getUrl(): string
return $this->url;
}

public function isPhe(): bool
{
return $this->isPhe;
}

}
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.0.0-beta';
const APP_VERSION = '4.0.1-beta';

private BrandClientInterface $brandClient;
private CategoryClientInterface $categoryClient;
Expand Down
1 change: 1 addition & 0 deletions tests/functional/ArticleClientCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
1 change: 1 addition & 0 deletions tests/functional/CategoryClientCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
);

Expand Down

0 comments on commit 57a4e83

Please sign in to comment.