From 6125da5c11ff32731c948795d9c46ce161ef08e0 Mon Sep 17 00:00:00 2001 From: Luis Humberto Barrientos Zambrano Date: Wed, 24 Apr 2024 09:47:54 -0400 Subject: [PATCH 1/2] feat: add contentScore property to GlobalProduct --- .../Xml/Product/GlobalProductFactory.php | 3 ++- src/Model/Product/GlobalProduct.php | 17 ++++++++++++++++- tests/_schemas/Product/GlobalProduct.xml | 1 + .../_schemas/Product/GlobalProductsResponse.xml | 2 ++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Factory/Xml/Product/GlobalProductFactory.php b/src/Factory/Xml/Product/GlobalProductFactory.php index 41dc14e..25c6050 100644 --- a/src/Factory/Xml/Product/GlobalProductFactory.php +++ b/src/Factory/Xml/Product/GlobalProductFactory.php @@ -59,7 +59,8 @@ public static function make(SimpleXMLElement $element): GlobalProduct (string) $element->TaxClass, $productData, $images ?? null, - (string) $element->QCStatus ?? null + (string) $element->QCStatus ?? null, + (int) $element->ContentScore ?? null ); if (!empty($element->ShopSku)) { diff --git a/src/Model/Product/GlobalProduct.php b/src/Model/Product/GlobalProduct.php index 530a45b..8564d5a 100644 --- a/src/Model/Product/GlobalProduct.php +++ b/src/Model/Product/GlobalProduct.php @@ -44,6 +44,11 @@ class GlobalProduct extends BaseProduct implements JsonSerializable, ProductInte */ protected $talla; + /** + * @var int|null + */ + protected $contentScore; + public function __construct() { $this->productData = new ProductData(); @@ -65,7 +70,8 @@ public static function fromBasicData( ?string $taxClass, ProductData $productData, ?Images $images = null, - ?string $qcStatus = null + ?string $qcStatus = null, + ?int $contentScore = null ): self { self::ValidateArguments($sellerSku, $name, $description, $productId); @@ -96,6 +102,10 @@ public static function fromBasicData( $product->setQcStatus($qcStatus); } + if (!empty($contentScore)) { + $product->setContentScore($contentScore); + } + return $product; } @@ -163,6 +173,11 @@ public function setTalla(string $talla): void $this->talla = $talla; } + public function setContentScore(int $contentScore): void + { + $this->contentScore = $contentScore; + } + /** * @return mixed[] */ diff --git a/tests/_schemas/Product/GlobalProduct.xml b/tests/_schemas/Product/GlobalProduct.xml index a358b96..9069350 100644 --- a/tests/_schemas/Product/GlobalProduct.xml +++ b/tests/_schemas/Product/GlobalProduct.xml @@ -20,6 +20,7 @@ https://i.linio.com.co/p/4a3e6ac763e2289c2952e0b00fd7b4a5-catalog.jpg https://i.linio.com.co/p/4a3e6ac763e2289c2952e0b00fd7b4a6-catalog.jpg + 26 Beige Beige L diff --git a/tests/_schemas/Product/GlobalProductsResponse.xml b/tests/_schemas/Product/GlobalProductsResponse.xml index 26e9613..e29815f 100644 --- a/tests/_schemas/Product/GlobalProductsResponse.xml +++ b/tests/_schemas/Product/GlobalProductsResponse.xml @@ -36,6 +36,7 @@ http://static.somesite.com/p/image2.jpg http://static.somesite.com/p/image3.jpg + 26 fdsfdsfds<span></span> IVA 19% GENERIC @@ -122,6 +123,7 @@ http://static.somesite.com/p/image2.jpg http://static.somesite.com/p/image3.jpg + 26 fdsfdsfds<span></span> IVA 19% GENERIC From a7e124abb382ff342ac30e0f4f85d31fb26c6675 Mon Sep 17 00:00:00 2001 From: Luis Humberto Barrientos Zambrano Date: Wed, 24 Apr 2024 11:13:42 -0400 Subject: [PATCH 2/2] fix: add getContentScore method --- src/Model/Product/GlobalProduct.php | 5 +++++ tests/Unit/Product/GlobalProductTest.php | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Model/Product/GlobalProduct.php b/src/Model/Product/GlobalProduct.php index 8564d5a..509225d 100644 --- a/src/Model/Product/GlobalProduct.php +++ b/src/Model/Product/GlobalProduct.php @@ -143,6 +143,11 @@ public function getTalla(): ?string return $this->talla; } + public function getContentScore(): ?int + { + return $this->contentScore; + } + public function setQcStatus(string $qcStatus): void { $this->qcStatus = $qcStatus; diff --git a/tests/Unit/Product/GlobalProductTest.php b/tests/Unit/Product/GlobalProductTest.php index 3005adb..56bb4cb 100644 --- a/tests/Unit/Product/GlobalProductTest.php +++ b/tests/Unit/Product/GlobalProductTest.php @@ -57,6 +57,8 @@ class GlobalProductTest extends LinioTestCase protected $mainImage; protected $images; + protected $contentScore = 40; + protected $conditionType = 'Nuevo'; protected $packageHeight = 3; protected $packageWidth = 0; @@ -124,7 +126,9 @@ public function testItCreatesAGlobalProductWithMandatoryParameters(): void $this->productId, $this->taxClass, $this->productData, - $this->images + $this->images, + null, + $this->contentScore ); $this->assertInstanceOf(GlobalProduct::class, $product); @@ -138,6 +142,7 @@ public function testItCreatesAGlobalProductWithMandatoryParameters(): void $this->assertEquals($product->getTaxClass(), $this->taxClass); $this->assertEquals($product->getProductData(), $this->productData); $this->assertEquals($product->getQcStatus(), null); + $this->assertEquals($product->getContentScore(), $this->contentScore); $this->assertInstanceOf(Images::class, $product->getImages()); $this->assertInstanceOf(BusinessUnits::class, $product->getBusinessUnits()); }