|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * @author @jayS-de <[email protected]> |
| 4 | + */ |
| 5 | + |
| 6 | +namespace Commercetools\Core\Request\Products\Command; |
| 7 | + |
| 8 | +use Commercetools\Core\Model\Common\Context; |
| 9 | +use Commercetools\Core\Request\AbstractAction; |
| 10 | + |
| 11 | +/** |
| 12 | + * @package Commercetools\Core\Request\Products\Command |
| 13 | + * @link https://dev.commercetools.com/http-api-projects-products.html#set-productvariant-key |
| 14 | + * @method string getAction() |
| 15 | + * @method ProductSetProductVariantKeyAction setAction(string $action = null) |
| 16 | + * @method string getKey() |
| 17 | + * @method ProductSetProductVariantKeyAction setKey(string $key = null) |
| 18 | + * @method int getVariantId() |
| 19 | + * @method ProductSetProductVariantKeyAction setVariantId(int $variantId = null) |
| 20 | + * @method string getSku() |
| 21 | + * @method ProductSetProductVariantKeyAction setSku(string $sku = null) |
| 22 | + * @method bool getStaged() |
| 23 | + * @method ProductSetProductVariantKeyAction setStaged(bool $staged = null) |
| 24 | + */ |
| 25 | +class ProductSetProductVariantKeyAction extends AbstractAction |
| 26 | +{ |
| 27 | + public function fieldDefinitions() |
| 28 | + { |
| 29 | + return [ |
| 30 | + 'action' => [static::TYPE => 'string'], |
| 31 | + 'variantId' => [static::TYPE => 'int'], |
| 32 | + 'sku' => [static::TYPE => 'string'], |
| 33 | + 'key' => [static::TYPE => 'string'], |
| 34 | + 'staged' => [static::TYPE => 'bool'] |
| 35 | + ]; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * @param array $data |
| 40 | + * @param Context|callable $context |
| 41 | + */ |
| 42 | + public function __construct(array $data = [], $context = null) |
| 43 | + { |
| 44 | + parent::__construct($data, $context); |
| 45 | + $this->setAction('setProductVariantKey'); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @param $variantId |
| 50 | + * @param string $key |
| 51 | + * @param Context|callable $context |
| 52 | + * @return ProductSetProductVariantKeyAction |
| 53 | + */ |
| 54 | + public static function ofVariantIdAndKey($variantId, $key, $context = null) |
| 55 | + { |
| 56 | + return static::of($context)->setVariantId($variantId)->setKey($key); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * @param $sku |
| 61 | + * @param string $key |
| 62 | + * @param Context|callable $context |
| 63 | + * @return ProductSetProductVariantKeyAction |
| 64 | + */ |
| 65 | + public static function ofSkuAndKey($sku, $key, $context = null) |
| 66 | + { |
| 67 | + return static::of($context)->setSku($sku)->setKey($key); |
| 68 | + } |
| 69 | +} |
0 commit comments