Skip to content

Commit

Permalink
TASK: Updating import SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
Auto Mation committed Aug 19, 2020
1 parent 456e736 commit 7539e7c
Show file tree
Hide file tree
Showing 35 changed files with 1,036 additions and 166 deletions.
2 changes: 1 addition & 1 deletion lib/commercetools-base/gen.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
hash=e731df5dde29eb223f6396f8b01f3c95930f2362
hash=971b10acb4fa6e8cb9ea4187b4109b82725e110e
2 changes: 1 addition & 1 deletion lib/commercetools-import-tests/gen.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
hash=e731df5dde29eb223f6396f8b01f3c95930f2362
hash=971b10acb4fa6e8cb9ea4187b4109b82725e110e
2 changes: 1 addition & 1 deletion lib/commercetools-import/gen.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
hash=e731df5dde29eb223f6396f8b01f3c95930f2362
hash=971b10acb4fa6e8cb9ea4187b4109b82725e110e
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface DiscountedPrice extends JsonObject
public const FIELD_DISCOUNT = 'discount';

/**
* @return null|Money
* @return null|TypedMoney
*/
public function getValue();

Expand All @@ -29,9 +29,9 @@ public function getValue();
public function getDiscount();

/**
* @param ?Money $value
* @param ?TypedMoney $value
*/
public function setValue(?Money $value): void;
public function setValue(?TypedMoney $value): void;

/**
* @param ?ProductDiscountKeyReference $discount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
final class DiscountedPriceBuilder implements Builder
{
/**
* @var null|Money|MoneyBuilder
* @var null|TypedMoney|TypedMoneyBuilder
*/
private $value;

Expand All @@ -31,11 +31,11 @@ final class DiscountedPriceBuilder implements Builder
private $discount;

/**
* @return null|Money
* @return null|TypedMoney
*/
public function getValue()
{
return $this->value instanceof MoneyBuilder ? $this->value->build() : $this->value;
return $this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value;
}

/**
Expand All @@ -49,10 +49,10 @@ public function getDiscount()
}

/**
* @param ?Money $value
* @param ?TypedMoney $value
* @return $this
*/
public function withValue(?Money $value)
public function withValue(?TypedMoney $value)
{
$this->value = $value;

Expand All @@ -73,7 +73,7 @@ public function withDiscount(?ProductDiscountKeyReference $discount)
/**
* @return $this
*/
public function withValueBuilder(?MoneyBuilder $value)
public function withValueBuilder(?TypedMoneyBuilder $value)
{
$this->value = $value;

Expand All @@ -93,7 +93,7 @@ public function withDiscountBuilder(?ProductDiscountKeyReferenceBuilder $discoun
public function build(): DiscountedPrice
{
return new DiscountedPriceModel(
$this->value instanceof MoneyBuilder ? $this->value->build() : $this->value,
$this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value,
$this->discount instanceof ProductDiscountKeyReferenceBuilder ? $this->discount->build() : $this->discount
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
final class DiscountedPriceModel extends JsonObjectModel implements DiscountedPrice
{
/**
* @var ?Money
* @var ?TypedMoney
*/
protected $value;

Expand All @@ -34,15 +34,15 @@ final class DiscountedPriceModel extends JsonObjectModel implements DiscountedPr
* @psalm-suppress MissingParamType
*/
public function __construct(
?Money $value = null,
?TypedMoney $value = null,
?ProductDiscountKeyReference $discount = null
) {
$this->value = $value;
$this->discount = $discount;
}

/**
* @return null|Money
* @return null|TypedMoney
*/
public function getValue()
{
Expand All @@ -52,8 +52,8 @@ public function getValue()
if (is_null($data)) {
return null;
}

$this->value = MoneyModel::of($data);
$className = TypedMoneyModel::resolveDiscriminatorClass($data);
$this->value = $className::of($data);
}

return $this->value;
Expand Down Expand Up @@ -81,9 +81,9 @@ public function getDiscount()


/**
* @param ?Money $value
* @param ?TypedMoney $value
*/
public function setValue(?Money $value): void
public function setValue(?TypedMoney $value): void
{
$this->value = $value;
}
Expand Down
27 changes: 27 additions & 0 deletions lib/commercetools-import/src/Models/Common/HighPrecisionMoney.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);
/**
* This file has been auto generated
* Do not change it.
*/

namespace Commercetools\Import\Models\Common;

use Commercetools\Base\DateTimeImmutableCollection;
use Commercetools\Base\JsonObject;

interface HighPrecisionMoney extends TypedMoney
{
public const FIELD_PRECISE_AMOUNT = 'preciseAmount';

/**
* @return null|int
*/
public function getPreciseAmount();

/**
* @param ?int $preciseAmount
*/
public function setPreciseAmount(?int $preciseAmount): void;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?php

declare(strict_types=1);
/**
* This file has been auto generated
* Do not change it.
*/

namespace Commercetools\Import\Models\Common;

use Commercetools\Base\Builder;
use Commercetools\Base\DateTimeImmutableCollection;
use Commercetools\Base\JsonObject;
use Commercetools\Base\JsonObjectModel;
use Commercetools\Base\MapperFactory;
use stdClass;

/**
* @implements Builder<HighPrecisionMoney>
*/
final class HighPrecisionMoneyBuilder implements Builder
{
/**
* @var ?int
*/
private $fractionDigits;

/**
* @var ?int
*/
private $centAmount;

/**
* @var ?string
*/
private $currencyCode;

/**
* @var ?int
*/
private $preciseAmount;

/**
* @return null|int
*/
public function getFractionDigits()
{
return $this->fractionDigits;
}

/**
* @return null|int
*/
public function getCentAmount()
{
return $this->centAmount;
}

/**
* <p>The currency code compliant to <a href="https://en.wikipedia.org/wiki/ISO_4217">ISO 4217</a>.</p>
*
* @return null|string
*/
public function getCurrencyCode()
{
return $this->currencyCode;
}

/**
* @return null|int
*/
public function getPreciseAmount()
{
return $this->preciseAmount;
}

/**
* @param ?int $fractionDigits
* @return $this
*/
public function withFractionDigits(?int $fractionDigits)
{
$this->fractionDigits = $fractionDigits;

return $this;
}

/**
* @param ?int $centAmount
* @return $this
*/
public function withCentAmount(?int $centAmount)
{
$this->centAmount = $centAmount;

return $this;
}

/**
* @param ?string $currencyCode
* @return $this
*/
public function withCurrencyCode(?string $currencyCode)
{
$this->currencyCode = $currencyCode;

return $this;
}

/**
* @param ?int $preciseAmount
* @return $this
*/
public function withPreciseAmount(?int $preciseAmount)
{
$this->preciseAmount = $preciseAmount;

return $this;
}


public function build(): HighPrecisionMoney
{
return new HighPrecisionMoneyModel(
$this->fractionDigits,
$this->centAmount,
$this->currencyCode,
$this->preciseAmount
);
}

public static function of(): HighPrecisionMoneyBuilder
{
return new self();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

declare(strict_types=1);
/**
* This file has been auto generated
* Do not change it.
*/

namespace Commercetools\Import\Models\Common;

use Commercetools\Base\MapperSequence;
use Commercetools\Exception\InvalidArgumentException;
use stdClass;

/**
* @extends MapperSequence<HighPrecisionMoney>
* @method HighPrecisionMoney current()
* @method HighPrecisionMoney at($offset)
*/
class HighPrecisionMoneyCollection extends MapperSequence
{
/**
* @psalm-assert HighPrecisionMoney $value
* @psalm-param HighPrecisionMoney|stdClass $value
* @throws InvalidArgumentException
*
* @return HighPrecisionMoneyCollection
*/
public function add($value)
{
if (!$value instanceof HighPrecisionMoney) {
throw new InvalidArgumentException();
}
$this->store($value);

return $this;
}

/**
* @psalm-return callable(int):?HighPrecisionMoney
*/
protected function mapper()
{
return function (int $index): ?HighPrecisionMoney {
$data = $this->get($index);
if ($data instanceof stdClass) {
$data = HighPrecisionMoneyModel::of($data);
$this->set($data, $index);
}

return $data;
};
}
}
Loading

0 comments on commit 7539e7c

Please sign in to comment.