Initial xentral_oss_20.3.c9ffacf
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\AmazonVendorDF\Data;
|
||||
|
||||
class Container
|
||||
{
|
||||
/** @var string */
|
||||
private $containerType;
|
||||
/** @var string */
|
||||
private $containerIdentifier;
|
||||
/** @var string */
|
||||
private $length;
|
||||
/** @var string */
|
||||
private $width;
|
||||
/** @var string */
|
||||
private $height;
|
||||
/** @var string */
|
||||
private $unitOfMeasure;
|
||||
/** @var array */
|
||||
private $items = [];
|
||||
|
||||
public function __construct(string $containerIdentifier, string $containerType = 'carton')
|
||||
{
|
||||
$this->containerIdentifier = $containerIdentifier;
|
||||
$this->containerType = $containerType;
|
||||
}
|
||||
|
||||
public function setDimensions(string $length, string $width, string $height, string $unitOfMeasure = 'CM')
|
||||
{
|
||||
$this->length = $length;
|
||||
$this->width = $width;
|
||||
$this->height = $height;
|
||||
$this->unitOfMeasure = $unitOfMeasure;
|
||||
}
|
||||
|
||||
public function addItem(
|
||||
string $itemSequenceNumber,
|
||||
string $buyerProductIdentifier,
|
||||
string $vendorProductIdentifier,
|
||||
Quantity $packedQuantity
|
||||
) {
|
||||
$quantity = $packedQuantity->toArray();
|
||||
unset($quantity['unitSize']);
|
||||
$this->items[] = [
|
||||
'itemSequenceNumber' => (int)$itemSequenceNumber,
|
||||
'buyerProductIdentifier' => $buyerProductIdentifier,
|
||||
'vendorProductIdentifier' => $vendorProductIdentifier,
|
||||
'packedQuantity' => $quantity,
|
||||
];
|
||||
}
|
||||
|
||||
public function getItems(): array
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return [
|
||||
'containerType' => $this->containerType,
|
||||
'containerIdentifier' => $this->containerIdentifier,
|
||||
'dimensions' => [
|
||||
'length' => $this->length,
|
||||
'width' => $this->width,
|
||||
'height' => $this->height,
|
||||
'unitOfMeasure' => $this->unitOfMeasure,
|
||||
],
|
||||
'weight' => [
|
||||
'unitOfMeasure' => 'KG',
|
||||
'value' => '1',
|
||||
],
|
||||
'packedItems' => $this->items,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user