This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #241
- Loading branch information
Jens Schulze
committed
Aug 8, 2016
1 parent
23e0193
commit 43f8dd6
Showing
19 changed files
with
856 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* @author @jayS-de <jens.schulze@commercetools.de> | ||
*/ | ||
|
||
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'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* @author @jayS-de <jens.schulze@commercetools.de> | ||
*/ | ||
|
||
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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* @author @jayS-de <jens.schulze@commercetools.de> | ||
*/ | ||
|
||
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'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* @author @jayS-de <jens.schulze@commercetools.de> | ||
*/ | ||
|
||
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'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* @author @jayS-de <jens.schulze@commercetools.de> | ||
*/ | ||
|
||
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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* @author @jayS-de <jens.schulze@commercetools.de> | ||
*/ | ||
|
||
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'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* @author @jayS-de <jens.schulze@commercetools.de> | ||
*/ | ||
|
||
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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/** | ||
* @author @jayS-de <jens.schulze@commercetools.de> | ||
*/ | ||
|
||
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); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/Request/Products/Command/ProductChangeAssetNameAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/** | ||
* @author @jayS-de <jens.schulze@commercetools.de> | ||
*/ | ||
|
||
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); | ||
} | ||
} |
Oops, something went wrong.