diff --git a/src/Model/Common/Asset.php b/src/Model/Common/Asset.php new file mode 100644 index 0000000000..e7c72e3e0f --- /dev/null +++ b/src/Model/Common/Asset.php @@ -0,0 +1,39 @@ + + */ + +namespace Commercetools\Core\Model\Common; + +use Commercetools\Core\Model\CustomField\CustomFieldObject; + +/** + * @package Commercetools\Core\Model\Common + * + * @method string getId() + * @method Asset setId(string $id = null) + * @method AssetSourceCollection getSources() + * @method Asset setSources(AssetSourceCollection $sources = null) + * @method LocalizedString getName() + * @method Asset setName(LocalizedString $name = null) + * @method LocalizedString getDescription() + * @method Asset setDescription(LocalizedString $description = null) + * @method array getTags() + * @method Asset setTags(array $tags = null) + * @method CustomFieldObject getCustom() + * @method Asset setCustom(CustomFieldObject $custom = null) + */ +class Asset extends JsonObject +{ + public function fieldDefinitions() + { + return [ + 'id' => [static::TYPE => 'string'], + 'sources' => [static::TYPE => '\Commercetools\Core\Model\Common\AssetSourceCollection'], + 'name' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'], + 'description' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'], + 'tags' => [static::TYPE => 'array'], + 'custom' => [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObject'], + ]; + } +} diff --git a/src/Model/Common/AssetCollection.php b/src/Model/Common/AssetCollection.php new file mode 100644 index 0000000000..b652a3e0f3 --- /dev/null +++ b/src/Model/Common/AssetCollection.php @@ -0,0 +1,18 @@ + + */ + +namespace Commercetools\Core\Model\Common; + +/** + * @package Commercetools\Core\Model\Common + * + * @method AssetCollection add(Asset $element) + * @method Asset current() + * @method Asset getAt($offset) + */ +class AssetCollection extends Collection +{ + protected $type = '\Commercetools\Core\Model\Common\Asset'; +} diff --git a/src/Model/Common/AssetDimension.php b/src/Model/Common/AssetDimension.php new file mode 100644 index 0000000000..46034c25de --- /dev/null +++ b/src/Model/Common/AssetDimension.php @@ -0,0 +1,24 @@ + + */ + +namespace Commercetools\Core\Model\Common; + +/** + * @package Commercetools\Core\Model\Common + * @method int getW() + * @method AssetDimension setW(int $w = null) + * @method int getH() + * @method AssetDimension setH(int $h = null) + */ +class AssetDimension extends JsonObject +{ + public function fieldDefinitions() + { + return [ + 'w' => [static::TYPE => 'int'], + 'h' => [static::TYPE => 'int'], + ]; + } +} diff --git a/src/Model/Common/AssetDraft.php b/src/Model/Common/AssetDraft.php new file mode 100644 index 0000000000..87fbd2b977 --- /dev/null +++ b/src/Model/Common/AssetDraft.php @@ -0,0 +1,36 @@ + + */ + +namespace Commercetools\Core\Model\Common; + +use Commercetools\Core\Model\CustomField\CustomFieldObject; + +/** + * @package Commercetools\Core\Model\Common + * + * @method AssetSourceCollection getSources() + * @method AssetDraft setSources(AssetSourceCollection $sources = null) + * @method LocalizedString getName() + * @method AssetDraft setName(LocalizedString $name = null) + * @method LocalizedString getDescription() + * @method AssetDraft setDescription(LocalizedString $description = null) + * @method array getTags() + * @method AssetDraft setTags(array $tags = null) + * @method CustomFieldObject getCustom() + * @method AssetDraft setCustom(CustomFieldObject $custom = null) + */ +class AssetDraft extends JsonObject +{ + public function fieldDefinitions() + { + return [ + 'sources' => [static::TYPE => '\Commercetools\Core\Model\Common\AssetSourceCollection'], + 'name' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'], + 'description' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'], + 'tags' => [static::TYPE => 'array'], + 'custom' => [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObject'], + ]; + } +} diff --git a/src/Model/Common/AssetDraftCollection.php b/src/Model/Common/AssetDraftCollection.php new file mode 100644 index 0000000000..5d345b6044 --- /dev/null +++ b/src/Model/Common/AssetDraftCollection.php @@ -0,0 +1,18 @@ + + */ + +namespace Commercetools\Core\Model\Common; + +/** + * @package Commercetools\Core\Model\Common + * + * @method AssetDraftCollection add(AssetDraft $element) + * @method AssetDraft current() + * @method AssetDraft getAt($offset) + */ +class AssetDraftCollection extends Collection +{ + protected $type = '\Commercetools\Core\Model\Common\AssetDraft'; +} diff --git a/src/Model/Common/AssetSource.php b/src/Model/Common/AssetSource.php new file mode 100644 index 0000000000..f84353aee7 --- /dev/null +++ b/src/Model/Common/AssetSource.php @@ -0,0 +1,31 @@ + + */ + +namespace Commercetools\Core\Model\Common; + +/** + * @package Commercetools\Core\Model\Common + * + * @method string getUri() + * @method AssetSource setUri(string $uri = null) + * @method string getKey() + * @method AssetSource setKey(string $key = null) + * @method AssetDimension getDimensions() + * @method AssetSource setDimensions(AssetDimension $dimensions = null) + * @method string getContentType() + * @method AssetSource setContentType(string $contentType = null) + */ +class AssetSource extends JsonObject +{ + public function fieldDefinitions() + { + return [ + 'uri' => [static::TYPE => 'string'], + 'key' => [static::TYPE => 'string'], + 'dimensions' => [static::TYPE => '\Commercetools\Core\Model\Common\AssetDimension'], + 'contentType' => [static::TYPE => 'string'], + ]; + } +} diff --git a/src/Model/Common/AssetSourceCollection.php b/src/Model/Common/AssetSourceCollection.php new file mode 100644 index 0000000000..b6b75b27b5 --- /dev/null +++ b/src/Model/Common/AssetSourceCollection.php @@ -0,0 +1,18 @@ + + */ + +namespace Commercetools\Core\Model\Common; + +/** + * @package Commercetools\Core\Model\Common + * + * @method AssetSourceCollection add(AssetSource $element) + * @method AssetSource current() + * @method AssetSource getAt($offset) + */ +class AssetSourceCollection extends Collection +{ + protected $type = '\Commercetools\Core\Model\Common\AssetSource'; +} diff --git a/src/Model/Product/ProductVariant.php b/src/Model/Product/ProductVariant.php index 751bc4b306..17b682bd06 100644 --- a/src/Model/Product/ProductVariant.php +++ b/src/Model/Product/ProductVariant.php @@ -11,6 +11,7 @@ use Commercetools\Core\Model\Common\PriceCollection; use Commercetools\Core\Model\Common\Price; use Commercetools\Core\Model\Common\ScopedPrice; +use Commercetools\Core\Model\Common\AssetCollection; /** * @package Commercetools\Core\Model\Product @@ -35,6 +36,8 @@ * @method ProductVariant setScopedPrice(ScopedPrice $scopedPrice = null) * @method bool getScopedPriceDiscounted() * @method ProductVariant setScopedPriceDiscounted(bool $scopedPriceDiscounted = null) + * @method AssetCollection getAssets() + * @method ProductVariant setAssets(AssetCollection $assets = null) */ class ProductVariant extends JsonObject { @@ -51,6 +54,7 @@ public function fieldDefinitions() 'isMatchingVariant' => [static::TYPE => 'bool'], 'scopedPrice' => [static::TYPE => '\Commercetools\Core\Model\Common\ScopedPrice'], 'scopedPriceDiscounted' => [static::TYPE => 'bool'], + 'assets' => [static::TYPE => '\Commercetools\Core\Model\Common\AssetCollection'] ]; } } diff --git a/src/Model/Product/ProductVariantDraft.php b/src/Model/Product/ProductVariantDraft.php index a679630e23..690611ee80 100644 --- a/src/Model/Product/ProductVariantDraft.php +++ b/src/Model/Product/ProductVariantDraft.php @@ -10,6 +10,7 @@ use Commercetools\Core\Model\Common\JsonObject; use Commercetools\Core\Model\Common\PriceDraftCollection; use Commercetools\Core\Model\Common\ImageCollection; +use Commercetools\Core\Model\Common\AssetDraftCollection; /** * @package Commercetools\Core\Model\Product @@ -22,6 +23,8 @@ * @method AttributeCollection getAttributes() * @method ImageCollection getImages() * @method ProductVariantDraft setImages(ImageCollection $images = null) + * @method AssetDraftCollection getAssets() + * @method ProductVariantDraft setAssets(AssetDraftCollection $assets = null) */ class ProductVariantDraft extends JsonObject { @@ -32,6 +35,7 @@ public function fieldDefinitions() 'prices' => [self::TYPE => '\Commercetools\Core\Model\Common\PriceDraftCollection'], 'images' => [static::TYPE => '\Commercetools\Core\Model\Common\ImageCollection'], 'attributes' => [self::TYPE => '\Commercetools\Core\Model\Common\AttributeCollection'], + 'assets' => [static::TYPE => '\Commercetools\Core\Model\Common\AssetDraftCollection'] ]; } } diff --git a/src/Request/Products/Command/ProductAddAssetAction.php b/src/Request/Products/Command/ProductAddAssetAction.php new file mode 100644 index 0000000000..864f0628ca --- /dev/null +++ b/src/Request/Products/Command/ProductAddAssetAction.php @@ -0,0 +1,71 @@ + + */ + +namespace Commercetools\Core\Request\Products\Command; + +use Commercetools\Core\Model\Common\Asset; +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Request\AbstractAction; +use Commercetools\Core\Model\Common\AssetDraft; + +/** + * @package Commercetools\Core\Request\Products\Command + * @link https://dev.commercetools.com/http-api-projects-products.html#add-asset + * @method string getAction() + * @method ProductAddAssetAction setAction(string $action = null) + * @method int getVariantId() + * @method ProductAddAssetAction setVariantId(int $variantId = null) + * @method string getSku() + * @method ProductAddAssetAction setSku(string $sku = null) + * @method AssetDraft getAsset() + * @method ProductAddAssetAction setAsset(AssetDraft $asset = null) + * @method bool getStaged() + * @method ProductAddAssetAction setStaged(bool $staged = null) + */ +class ProductAddAssetAction extends AbstractAction +{ + public function fieldDefinitions() + { + return [ + 'action' => [static::TYPE => 'string'], + 'variantId' => [static::TYPE => 'int'], + 'sku' => [static::TYPE => 'string'], + 'asset' => [static::TYPE => '\Commercetools\Core\Model\Common\AssetDraft'], + 'staged' => [static::TYPE => 'bool'], + ]; + } + + /** + * @param array $data + * @param Context|callable $context + */ + public function __construct(array $data = [], $context = null) + { + parent::__construct($data, $context); + $this->setAction('addAsset'); + } + + /** + * @param int $variantId + * @param Asset $asset + * @param Context|callable $context + * @return ProductAddExternalImageAction + */ + public static function ofVariantIdAndAsset($variantId, Asset $asset, $context = null) + { + return static::of($context)->setVariantId($variantId)->setAsset($asset); + } + + /** + * @param string $sku + * @param Asset $asset + * @param Context|callable $context + * @return ProductAddExternalImageAction + */ + public static function ofSkuAndAsset($sku, Asset $asset, $context = null) + { + return static::of($context)->setSku($sku)->setAsset($asset); + } +} diff --git a/src/Request/Products/Command/ProductChangeAssetNameAction.php b/src/Request/Products/Command/ProductChangeAssetNameAction.php new file mode 100644 index 0000000000..143236f4b2 --- /dev/null +++ b/src/Request/Products/Command/ProductChangeAssetNameAction.php @@ -0,0 +1,75 @@ + + */ + +namespace Commercetools\Core\Request\Products\Command; + +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Model\Common\LocalizedString; +use Commercetools\Core\Request\AbstractAction; + +/** + * @package Commercetools\Core\Request\Products\Command + * @link https://dev.commercetools.com/http-api-projects-products.html#change-asset-name + * @method string getAction() + * @method ProductChangeAssetNameAction setAction(string $action = null) + * @method LocalizedString getName() + * @method ProductChangeAssetNameAction setName(LocalizedString $name = null) + * @method bool getStaged() + * @method ProductChangeAssetNameAction setStaged(bool $staged = null) + * @method int getVariantId() + * @method ProductChangeAssetNameAction setVariantId(int $variantId = null) + * @method string getSku() + * @method ProductChangeAssetNameAction setSku(string $sku = null) + * @method string getAssetId() + * @method ProductChangeAssetNameAction setAssetId(string $assetId = null) + */ +class ProductChangeAssetNameAction extends AbstractAction +{ + public function fieldDefinitions() + { + return [ + 'action' => [static::TYPE => 'string'], + 'variantId' => [static::TYPE => 'int'], + 'sku' => [static::TYPE => 'string'], + 'assetId' => [static::TYPE => 'string'], + 'name' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'], + 'staged' => [static::TYPE => 'bool'], + ]; + } + + /** + * @param array $data + * @param Context|callable $context + */ + public function __construct(array $data = [], $context = null) + { + parent::__construct($data, $context); + $this->setAction('changeAssetName'); + } + + /** + * @param int $variantId + * @param string $assetId + * @param LocalizedString $name + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofVariantIdAssetIdAndName($variantId, $assetId, LocalizedString $name, $context = null) + { + return static::of($context)->setVariantId($variantId)->setAssetId($assetId)->setName($name); + } + + /** + * @param string $sku + * @param string $assetId + * @param LocalizedString $name + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofSkuAssetIdAndName($sku, $assetId, LocalizedString $name, $context = null) + { + return static::of($context)->setSku($sku)->setAssetId($assetId)->setName($name); + } +} diff --git a/src/Request/Products/Command/ProductChangeAssetOrderAction.php b/src/Request/Products/Command/ProductChangeAssetOrderAction.php new file mode 100644 index 0000000000..ed7f8b1617 --- /dev/null +++ b/src/Request/Products/Command/ProductChangeAssetOrderAction.php @@ -0,0 +1,70 @@ + + */ + +namespace Commercetools\Core\Request\Products\Command; + +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Request\AbstractAction; +use Commercetools\Core\Model\Common\AssetDraft; + +/** + * @package Commercetools\Core\Request\Products\Command + * + * @method string getAction() + * @method ProductChangeAssetOrderAction setAction(string $action = null) + * @method int getVariantId() + * @method ProductChangeAssetOrderAction setVariantId(int $variantId = null) + * @method string getSku() + * @method ProductChangeAssetOrderAction setSku(string $sku = null) + * @method AssetDraft getAsset() + * @method ProductChangeAssetOrderAction setAsset(AssetDraft $asset = null) + * @method bool getStaged() + * @method ProductChangeAssetOrderAction setStaged(bool $staged = null) + * @method array getAssetOrder() + * @method ProductChangeAssetOrderAction setAssetOrder(array $assetOrder = null) + */ +class ProductChangeAssetOrderAction extends AbstractAction +{ + public function fieldDefinitions() + { + return [ + 'action' => [static::TYPE => 'string'], + 'variantId' => [static::TYPE => 'int'], + 'sku' => [static::TYPE => 'string'], + 'assetOrder' => [static::TYPE => 'array'], + 'staged' => [static::TYPE => 'bool'], + ]; + } + + /** + * @param array $data + * @param Context|callable $context + */ + public function __construct(array $data = [], $context = null) + { + parent::__construct($data, $context); + $this->setAction('changeAssetOrder'); + } + + /** + * @param int $variantId + * @param Context|callable $context + * @return ProductAddExternalImageAction + */ + public static function ofVariantId($variantId, $context = null) + { + return static::of($context)->setVariantId($variantId); + } + + /** + * @param string $sku + * @param Context|callable $context + * @return ProductAddExternalImageAction + */ + public static function ofSku($sku, $context = null) + { + return static::of($context)->setSku($sku); + } +} diff --git a/src/Request/Products/Command/ProductRemoveAssetAction.php b/src/Request/Products/Command/ProductRemoveAssetAction.php new file mode 100644 index 0000000000..ff5fc7dcec --- /dev/null +++ b/src/Request/Products/Command/ProductRemoveAssetAction.php @@ -0,0 +1,69 @@ + + */ + +namespace Commercetools\Core\Request\Products\Command; + +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Request\AbstractAction; + +/** + * @package Commercetools\Core\Request\Products\Command + * @link https://dev.commercetools.com/http-api-projects-products.html#remove-asset + * @method string getAction() + * @method ProductRemoveAssetAction setAction(string $action = null) + * @method int getVariantId() + * @method ProductRemoveAssetAction setVariantId(int $variantId = null) + * @method string getSku() + * @method ProductRemoveAssetAction setSku(string $sku = null) + * @method string getAssetId() + * @method ProductRemoveAssetAction setAssetId(string $assetId = null) + * @method bool getStaged() + * @method ProductRemoveAssetAction setStaged(bool $staged = null) + */ +class ProductRemoveAssetAction extends AbstractAction +{ + public function fieldDefinitions() + { + return [ + 'action' => [static::TYPE => 'string'], + 'variantId' => [static::TYPE => 'int'], + 'sku' => [static::TYPE => 'string'], + 'assetId' => [static::TYPE => 'string'], + 'staged' => [static::TYPE => 'bool'], + ]; + } + + /** + * @param array $data + * @param Context|callable $context + */ + public function __construct(array $data = [], $context = null) + { + parent::__construct($data, $context); + $this->setAction('removeAsset'); + } + + /** + * @param int $variantId + * @param string $assetId + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofVariantIdAndAssetId($variantId, $assetId, $context = null) + { + return static::of($context)->setVariantId($variantId)->setAssetId($assetId); + } + + /** + * @param string $sku + * @param string $assetId + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofSkuAndAssetId($sku, $assetId, $context = null) + { + return static::of($context)->setSku($sku)->setAssetId($assetId); + } +} diff --git a/src/Request/Products/Command/ProductSetAssetCustomFieldAction.php b/src/Request/Products/Command/ProductSetAssetCustomFieldAction.php new file mode 100644 index 0000000000..b4a01a5913 --- /dev/null +++ b/src/Request/Products/Command/ProductSetAssetCustomFieldAction.php @@ -0,0 +1,78 @@ + + */ + +namespace Commercetools\Core\Request\Products\Command; + +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Request\CustomField\Command\SetCustomFieldAction; + +/** + * @package Commercetools\Core\Request\Products\Command + * @link https://dev.commercetools.com/http-api-projects-products.html#set-asset-customfield + * + * @method string getAction() + * @method ProductSetAssetCustomFieldAction setAction(string $action = null) + * @method int getVariantId() + * @method ProductSetAssetCustomFieldAction setVariantId(int $variantId = null) + * @method string getSku() + * @method ProductSetAssetCustomFieldAction setSku(string $sku = null) + * @method string getAssetId() + * @method ProductSetAssetCustomFieldAction setAssetId(string $assetId = null) + * @method string getName() + * @method ProductSetAssetCustomFieldAction setName(string $name = null) + * @method mixed getValue() + * @method ProductSetAssetCustomFieldAction setValue($value = null) + * @method bool getStaged() + * @method ProductSetAssetCustomFieldAction setStaged(bool $staged = null) + */ +class ProductSetAssetCustomFieldAction extends SetCustomFieldAction +{ + public function fieldDefinitions() + { + return [ + 'action' => [static::TYPE => 'string'], + 'variantId' => [static::TYPE => 'int'], + 'sku' => [static::TYPE => 'string'], + 'assetId' => [static::TYPE => 'string'], + 'name' => [static::TYPE => 'string'], + 'value' => [static::TYPE => null], + 'staged' => [static::TYPE => 'bool'], + ]; + } + + /** + * @param array $data + * @param Context|callable $context + */ + public function __construct(array $data = [], $context = null) + { + parent::__construct($data, $context); + $this->setAction('setAssetCustomField'); + } + + /** + * @param int $variantId + * @param string $assetId + * @param string $name + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofVariantIdAssetIdAndName($variantId, $assetId, $name, $context = null) + { + return static::of($context)->setVariantId($variantId)->setAssetId($assetId)->setName($name); + } + + /** + * @param string $sku + * @param string $assetId + * @param string $name + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofSkuAssetIdAndName($sku, $assetId, $name, $context = null) + { + return static::of($context)->setSku($sku)->setAssetId($assetId)->setName($name); + } +} diff --git a/src/Request/Products/Command/ProductSetAssetCustomTypeAction.php b/src/Request/Products/Command/ProductSetAssetCustomTypeAction.php new file mode 100644 index 0000000000..61a14b14bd --- /dev/null +++ b/src/Request/Products/Command/ProductSetAssetCustomTypeAction.php @@ -0,0 +1,79 @@ + + */ + +namespace Commercetools\Core\Request\Products\Command; + +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Request\CustomField\Command\SetCustomTypeAction; +use Commercetools\Core\Model\CustomField\FieldContainer; +use Commercetools\Core\Model\Type\TypeReference; + +/** + * @package Commercetools\Core\Request\Products\Command + * @link https://dev.commercetools.com/http-api-projects-products.html#set-asset-custom-type + * @method string getAction() + * @method ProductSetAssetCustomTypeAction setAction(string $action = null) + * @method int getVariantId() + * @method ProductSetAssetCustomTypeAction setVariantId(int $variantId = null) + * @method string getSku() + * @method ProductSetAssetCustomTypeAction setSku(string $sku = null) + * @method string getAssetId() + * @method ProductSetAssetCustomTypeAction setAssetId(string $assetId = null) + * @method bool getStaged() + * @method ProductSetAssetCustomTypeAction setStaged(bool $staged = null) + * @method TypeReference getType() + * @method ProductSetAssetCustomTypeAction setType(TypeReference $type = null) + * @method FieldContainer getFields() + * @method ProductSetAssetCustomTypeAction setFields(FieldContainer $fields = null) + */ +class ProductSetAssetCustomTypeAction extends SetCustomTypeAction +{ + public function fieldDefinitions() + { + return [ + 'action' => [static::TYPE => 'string'], + 'variantId' => [static::TYPE => 'int'], + 'sku' => [static::TYPE => 'string'], + 'assetId' => [static::TYPE => 'string'], + 'staged' => [static::TYPE => 'bool'], + 'type' => [static::TYPE => '\Commercetools\Core\Model\Type\TypeReference'], + 'fields' => [static::TYPE => '\Commercetools\Core\Model\CustomField\FieldContainer'], + ]; + } + + /** + * @param array $data + * @param Context|callable $context + */ + public function __construct(array $data = [], $context = null) + { + parent::__construct($data, $context); + $this->setAction('setAssetCustomType'); + } + + /** + * @param TypeReference $type + * @param int $variantId + * @param string $assetId + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofTypeVariantIdAssetIdAndName(TypeReference $type, $variantId, $assetId, $context = null) + { + return static::of($context)->setType($type)->setVariantId($variantId)->setAssetId($assetId); + } + + /** + * @param TypeReference $type + * @param string $sku + * @param string $assetId + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofTypeSkuAssetIdAndName(TypeReference $type, $sku, $assetId, $context = null) + { + return static::of($context)->setType($type)->setSku($sku)->setAssetId($assetId); + } +} diff --git a/src/Request/Products/Command/ProductSetAssetDescriptionAction.php b/src/Request/Products/Command/ProductSetAssetDescriptionAction.php new file mode 100644 index 0000000000..11ce2eae38 --- /dev/null +++ b/src/Request/Products/Command/ProductSetAssetDescriptionAction.php @@ -0,0 +1,73 @@ + + */ + +namespace Commercetools\Core\Request\Products\Command; + +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Model\Common\LocalizedString; +use Commercetools\Core\Request\AbstractAction; + +/** + * @package Commercetools\Core\Request\Products\Command + * @link https://dev.commercetools.com/http-api-projects-products.html#set-asset-description + * @method string getAction() + * @method ProductSetAssetDescriptionAction setAction(string $action = null) + * @method bool getStaged() + * @method ProductSetAssetDescriptionAction setStaged(bool $staged = null) + * @method int getVariantId() + * @method ProductSetAssetDescriptionAction setVariantId(int $variantId = null) + * @method string getSku() + * @method ProductSetAssetDescriptionAction setSku(string $sku = null) + * @method string getAssetId() + * @method ProductSetAssetDescriptionAction setAssetId(string $assetId = null) + * @method LocalizedString getDescription() + * @method ProductSetAssetDescriptionAction setDescription(LocalizedString $description = null) + */ +class ProductSetAssetDescriptionAction extends AbstractAction +{ + public function fieldDefinitions() + { + return [ + 'action' => [static::TYPE => 'string'], + 'variantId' => [static::TYPE => 'int'], + 'sku' => [static::TYPE => 'string'], + 'assetId' => [static::TYPE => 'string'], + 'description' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'], + 'staged' => [static::TYPE => 'bool'], + ]; + } + + /** + * @param array $data + * @param Context|callable $context + */ + public function __construct(array $data = [], $context = null) + { + parent::__construct($data, $context); + $this->setAction('setAssetDescription'); + } + + /** + * @param int $variantId + * @param string $assetId + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofVariantIdAndAssetId($variantId, $assetId, $context = null) + { + return static::of($context)->setVariantId($variantId)->setAssetId($assetId); + } + + /** + * @param string $sku + * @param string $assetId + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofSkuAndAssetId($sku, $assetId, $context = null) + { + return static::of($context)->setSku($sku)->setAssetId($assetId); + } +} diff --git a/src/Request/Products/Command/ProductSetAssetSourcesAction.php b/src/Request/Products/Command/ProductSetAssetSourcesAction.php new file mode 100644 index 0000000000..e1b7b766eb --- /dev/null +++ b/src/Request/Products/Command/ProductSetAssetSourcesAction.php @@ -0,0 +1,74 @@ + + */ + +namespace Commercetools\Core\Request\Products\Command; + +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Model\Common\LocalizedString; +use Commercetools\Core\Request\AbstractAction; +use Commercetools\Core\Model\Common\AssetSourceCollection; + +/** + * @package Commercetools\Core\Request\Products\Command + * @link https://dev.commercetools.com/http-api-projects-products.html#set-asset-tags + * @method string getAction() + * @method ProductSetAssetSourcesAction setAction(string $action = null) + * @method bool getStaged() + * @method ProductSetAssetSourcesAction setStaged(bool $staged = null) + * @method int getVariantId() + * @method ProductSetAssetSourcesAction setVariantId(int $variantId = null) + * @method string getSku() + * @method ProductSetAssetSourcesAction setSku(string $sku = null) + * @method string getAssetId() + * @method ProductSetAssetSourcesAction setAssetId(string $assetId = null) + * @method AssetSourceCollection getSources() + * @method ProductSetAssetSourcesAction setSources(AssetSourceCollection $sources = null) + */ +class ProductSetAssetSourcesAction extends AbstractAction +{ + public function fieldDefinitions() + { + return [ + 'action' => [static::TYPE => 'string'], + 'variantId' => [static::TYPE => 'int'], + 'sku' => [static::TYPE => 'string'], + 'assetId' => [static::TYPE => 'string'], + 'sources' => [static::TYPE => '\Commercetools\Core\Model\Common\AssetSourceCollection'], + 'staged' => [static::TYPE => 'bool'], + ]; + } + + /** + * @param array $data + * @param Context|callable $context + */ + public function __construct(array $data = [], $context = null) + { + parent::__construct($data, $context); + $this->setAction('setAssetSources'); + } + + /** + * @param int $variantId + * @param string $assetId + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofVariantIdAndAssetId($variantId, $assetId, $context = null) + { + return static::of($context)->setVariantId($variantId)->setAssetId($assetId); + } + + /** + * @param string $sku + * @param string $assetId + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofSkuAndAssetId($sku, $assetId, $context = null) + { + return static::of($context)->setSku($sku)->setAssetId($assetId); + } +} diff --git a/src/Request/Products/Command/ProductSetAssetTagsAction.php b/src/Request/Products/Command/ProductSetAssetTagsAction.php new file mode 100644 index 0000000000..b1ef6740ec --- /dev/null +++ b/src/Request/Products/Command/ProductSetAssetTagsAction.php @@ -0,0 +1,73 @@ + + */ + +namespace Commercetools\Core\Request\Products\Command; + +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Model\Common\LocalizedString; +use Commercetools\Core\Request\AbstractAction; + +/** + * @package Commercetools\Core\Request\Products\Command + * @link https://dev.commercetools.com/http-api-projects-products.html#set-asset-tags + * @method string getAction() + * @method ProductSetAssetTagsAction setAction(string $action = null) + * @method bool getStaged() + * @method ProductSetAssetTagsAction setStaged(bool $staged = null) + * @method int getVariantId() + * @method ProductSetAssetTagsAction setVariantId(int $variantId = null) + * @method string getSku() + * @method ProductSetAssetTagsAction setSku(string $sku = null) + * @method string getAssetId() + * @method ProductSetAssetTagsAction setAssetId(string $assetId = null) + * @method array getTags() + * @method ProductSetAssetTagsAction setTags(array $tags = null) + */ +class ProductSetAssetTagsAction extends AbstractAction +{ + public function fieldDefinitions() + { + return [ + 'action' => [static::TYPE => 'string'], + 'variantId' => [static::TYPE => 'int'], + 'sku' => [static::TYPE => 'string'], + 'assetId' => [static::TYPE => 'string'], + 'tags' => [static::TYPE => 'array'], + 'staged' => [static::TYPE => 'bool'], + ]; + } + + /** + * @param array $data + * @param Context|callable $context + */ + public function __construct(array $data = [], $context = null) + { + parent::__construct($data, $context); + $this->setAction('setAssetTags'); + } + + /** + * @param int $variantId + * @param string $assetId + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofVariantIdAndAssetId($variantId, $assetId, $context = null) + { + return static::of($context)->setVariantId($variantId)->setAssetId($assetId); + } + + /** + * @param string $sku + * @param string $assetId + * @param Context|callable $context + * @return ProductRemoveAssetAction + */ + public static function ofSkuAndAssetId($sku, $assetId, $context = null) + { + return static::of($context)->setSku($sku)->setAssetId($assetId); + } +} diff --git a/tests/fixtures/models.yaml b/tests/fixtures/models.yaml index 6586564649..5bb4c9eb49 100644 --- a/tests/fixtures/models.yaml +++ b/tests/fixtures/models.yaml @@ -531,6 +531,7 @@ productVariant: - price - attributes - images + - assets - availability - isMatchingVariant - scopedPrice @@ -571,6 +572,7 @@ productVariantDraft: - sku - prices - images + - assets - attributes facetTerm: