Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit a3c9ea0

Browse files
author
Jens Schulze
committed
feat: support key for assets
Closes #371
1 parent abb7b3c commit a3c9ea0

22 files changed

+765
-1
lines changed

src/Core/Model/Common/Asset.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@
2222
* @method Asset setTags(array $tags = null)
2323
* @method CustomFieldObject getCustom()
2424
* @method Asset setCustom(CustomFieldObject $custom = null)
25+
* @method string getKey()
26+
* @method Asset setKey(string $key = null)
2527
*/
2628
class Asset extends JsonObject
2729
{
2830
public function fieldDefinitions()
2931
{
3032
return [
3133
'id' => [static::TYPE => 'string'],
34+
'key' => [static::TYPE => 'string'],
3235
'sources' => [static::TYPE => AssetSourceCollection::class],
3336
'name' => [static::TYPE => LocalizedString::class],
3437
'description' => [static::TYPE => LocalizedString::class],

src/Core/Model/Common/AssetDraft.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@
2121
* @method AssetDraft setTags(array $tags = null)
2222
* @method CustomFieldObjectDraft getCustom()
2323
* @method AssetDraft setCustom(CustomFieldObjectDraft $custom = null)
24+
* @method string getKey()
25+
* @method AssetDraft setKey(string $key = null)
2426
*/
2527
class AssetDraft extends JsonObject
2628
{
2729
public function fieldDefinitions()
2830
{
2931
return [
32+
'key' => [static::TYPE => 'string'],
3033
'sources' => [static::TYPE => AssetSourceCollection::class],
3134
'name' => [static::TYPE => LocalizedString::class],
3235
'description' => [static::TYPE => LocalizedString::class],

src/Core/Request/Categories/Command/CategoryAddAssetAction.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* @method CategoryAddAssetAction setAction(string $action = null)
1717
* @method AssetDraft getAsset()
1818
* @method CategoryAddAssetAction setAsset(AssetDraft $asset = null)
19+
* @method int getPosition()
20+
* @method CategoryAddAssetAction setPosition(int $position = null)
1921
*/
2022
class CategoryAddAssetAction extends AbstractAction
2123
{
@@ -24,6 +26,7 @@ public function fieldDefinitions()
2426
return [
2527
'action' => [static::TYPE => 'string'],
2628
'asset' => [static::TYPE => AssetDraft::class],
29+
'position' => [static::TYPE => 'int'],
2730
];
2831
}
2932

src/Core/Request/Categories/Command/CategoryChangeAssetNameAction.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* @method CategoryChangeAssetNameAction setName(LocalizedString $name = null)
1919
* @method string getAssetId()
2020
* @method CategoryChangeAssetNameAction setAssetId(string $assetId = null)
21+
* @method string getAssetKey()
22+
* @method CategoryChangeAssetNameAction setAssetKey(string $assetKey = null)
2123
*/
2224
class CategoryChangeAssetNameAction extends AbstractAction
2325
{
@@ -26,6 +28,7 @@ public function fieldDefinitions()
2628
return [
2729
'action' => [static::TYPE => 'string'],
2830
'assetId' => [static::TYPE => 'string'],
31+
'assetKey' => [static::TYPE => 'string'],
2932
'name' => [static::TYPE => LocalizedString::class],
3033
];
3134
}
@@ -50,4 +53,15 @@ public static function ofAssetIdAndName($assetId, LocalizedString $name, $contex
5053
{
5154
return static::of($context)->setAssetId($assetId)->setName($name);
5255
}
56+
57+
/**
58+
* @param string $assetKey
59+
* @param LocalizedString $name
60+
* @param Context|callable $context
61+
* @return CategoryChangeAssetNameAction
62+
*/
63+
public static function ofAssetKeyAndName($assetKey, LocalizedString $name, $context = null)
64+
{
65+
return static::of($context)->setAssetKey($assetKey)->setName($name);
66+
}
5367
}

src/Core/Request/Categories/Command/CategoryRemoveAssetAction.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* @method CategoryRemoveAssetAction setAction(string $action = null)
1616
* @method string getAssetId()
1717
* @method CategoryRemoveAssetAction setAssetId(string $assetId = null)
18+
* @method string getAssetKey()
19+
* @method CategoryRemoveAssetAction setAssetKey(string $assetKey = null)
1820
*/
1921
class CategoryRemoveAssetAction extends AbstractAction
2022
{
@@ -23,6 +25,7 @@ public function fieldDefinitions()
2325
return [
2426
'action' => [static::TYPE => 'string'],
2527
'assetId' => [static::TYPE => 'string'],
28+
'assetKey' => [static::TYPE => 'string'],
2629
];
2730
}
2831

@@ -45,4 +48,14 @@ public static function ofAssetId($assetId, $context = null)
4548
{
4649
return static::of($context)->setAssetId($assetId);
4750
}
51+
52+
/**
53+
* @param string $assetKey
54+
* @param Context|callable $context
55+
* @return CategoryRemoveAssetAction
56+
*/
57+
public static function ofAssetKey($assetKey, $context = null)
58+
{
59+
return static::of($context)->setAssetKey($assetKey);
60+
}
4861
}

src/Core/Request/Categories/Command/CategorySetAssetCustomFieldAction.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
* @method CategorySetAssetCustomFieldAction setName(string $name = null)
2121
* @method mixed getValue()
2222
* @method CategorySetAssetCustomFieldAction setValue($value = null)
23+
* @method string getAssetKey()
24+
* @method CategorySetAssetCustomFieldAction setAssetKey(string $assetKey = null)
2325
*/
2426
class CategorySetAssetCustomFieldAction extends SetCustomFieldAction
2527
{
@@ -28,6 +30,7 @@ public function fieldDefinitions()
2830
return [
2931
'action' => [static::TYPE => 'string'],
3032
'assetId' => [static::TYPE => 'string'],
33+
'assetKey' => [static::TYPE => 'string'],
3134
'name' => [static::TYPE => 'string'],
3235
'value' => [static::TYPE => null],
3336
];
@@ -53,4 +56,15 @@ public static function ofAssetIdAndName($assetId, $name, $context = null)
5356
{
5457
return static::of($context)->setAssetId($assetId)->setName($name);
5558
}
59+
60+
/**
61+
* @param string $assetKey
62+
* @param string $name
63+
* @param Context|callable $context
64+
* @return CategorySetAssetCustomFieldAction
65+
*/
66+
public static function ofAssetKeyAndName($assetKey, $name, $context = null)
67+
{
68+
return static::of($context)->setAssetKey($assetKey)->setName($name);
69+
}
5670
}

src/Core/Request/Categories/Command/CategorySetAssetCustomTypeAction.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
* @method CategorySetAssetCustomTypeAction setType(TypeReference $type = null)
2222
* @method FieldContainer getFields()
2323
* @method CategorySetAssetCustomTypeAction setFields(FieldContainer $fields = null)
24+
* @method string getAssetKey()
25+
* @method CategorySetAssetCustomTypeAction setAssetKey(string $assetKey = null)
2426
*/
2527
class CategorySetAssetCustomTypeAction extends SetCustomTypeAction
2628
{
@@ -29,6 +31,7 @@ public function fieldDefinitions()
2931
return [
3032
'action' => [static::TYPE => 'string'],
3133
'assetId' => [static::TYPE => 'string'],
34+
'assetKey' => [static::TYPE => 'string'],
3235
'type' => [static::TYPE => TypeReference::class],
3336
'fields' => [static::TYPE => FieldContainer::class],
3437
];
@@ -54,4 +57,15 @@ public static function ofTypeAssetIdAndName(TypeReference $type, $assetId, $cont
5457
{
5558
return static::of($context)->setType($type)->setAssetId($assetId);
5659
}
60+
61+
/**
62+
* @param TypeReference $type
63+
* @param string $assetKey
64+
* @param Context|callable $context
65+
* @return CategorySetAssetCustomTypeAction
66+
*/
67+
public static function ofTypeAssetKeyAndName(TypeReference $type, $assetKey, $context = null)
68+
{
69+
return static::of($context)->setType($type)->setAssetKey($assetKey);
70+
}
5771
}

src/Core/Request/Categories/Command/CategorySetAssetDescriptionAction.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* @method CategorySetAssetDescriptionAction setAssetId(string $assetId = null)
1919
* @method LocalizedString getDescription()
2020
* @method CategorySetAssetDescriptionAction setDescription(LocalizedString $description = null)
21+
* @method string getAssetKey()
22+
* @method CategorySetAssetDescriptionAction setAssetKey(string $assetKey = null)
2123
*/
2224
class CategorySetAssetDescriptionAction extends AbstractAction
2325
{
@@ -26,6 +28,7 @@ public function fieldDefinitions()
2628
return [
2729
'action' => [static::TYPE => 'string'],
2830
'assetId' => [static::TYPE => 'string'],
31+
'assetKey' => [static::TYPE => 'string'],
2932
'description' => [static::TYPE => LocalizedString::class],
3033
];
3134
}
@@ -49,4 +52,14 @@ public static function ofAssetId($assetId, $context = null)
4952
{
5053
return static::of($context)->setAssetId($assetId);
5154
}
55+
56+
/**
57+
* @param string $assetKey
58+
* @param Context|callable $context
59+
* @return CategorySetAssetDescriptionAction
60+
*/
61+
public static function ofAssetKey($assetKey, $context = null)
62+
{
63+
return static::of($context)->setAssetKey($assetKey);
64+
}
5265
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* @author @jenschude <jens.schulze@commercetools.de>
4+
*/
5+
6+
namespace Commercetools\Core\Request\Categories\Command;
7+
8+
use Commercetools\Core\Model\Common\Context;
9+
use Commercetools\Core\Model\Common\LocalizedString;
10+
use Commercetools\Core\Request\AbstractAction;
11+
12+
/**
13+
* @package Commercetools\Core\Request\Categories\Command
14+
* @link https://docs.commercetools.com/http-api-projects-products.html#set-asset-key
15+
* @method string getAction()
16+
* @method CategorySetAssetKeyAction setAction(string $action = null)
17+
* @method string getAssetId()
18+
* @method CategorySetAssetKeyAction setAssetId(string $assetId = null)
19+
* @method string getAssetKey()
20+
* @method CategorySetAssetKeyAction setAssetKey(string $assetKey = null)
21+
* @method LocalizedString getName()
22+
* @method CategorySetAssetKeyAction setName(LocalizedString $name = null)
23+
*/
24+
class CategorySetAssetKeyAction extends AbstractAction
25+
{
26+
public function fieldDefinitions()
27+
{
28+
return [
29+
'action' => [static::TYPE => 'string'],
30+
'assetId' => [static::TYPE => 'string'],
31+
'assetKey' => [static::TYPE => 'string'],
32+
'name' => [static::TYPE => LocalizedString::class],
33+
];
34+
}
35+
36+
/**
37+
* @param array $data
38+
* @param Context|callable $context
39+
*/
40+
public function __construct(array $data = [], $context = null)
41+
{
42+
parent::__construct($data, $context);
43+
$this->setAction('changeAssetName');
44+
}
45+
46+
/**
47+
* @param string $assetId
48+
* @param Context|callable $context
49+
* @return CategorySetAssetKeyAction
50+
*/
51+
public static function ofAssetId($assetId, $context = null)
52+
{
53+
return static::of($context)->setAssetId($assetId);
54+
}
55+
56+
/**
57+
* @param string $assetId
58+
* @param string $assetKey
59+
* @param Context|callable $context
60+
* @return CategorySetAssetKeyAction
61+
*/
62+
public static function ofAssetIdAndAssetKey($assetId, $assetKey, $context = null)
63+
{
64+
return static::of($context)->setAssetId($assetId)->setAssetKey($assetKey);
65+
}
66+
}

src/Core/Request/Categories/Command/CategorySetAssetSourcesAction.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* @method CategorySetAssetSourcesAction setAssetId(string $assetId = null)
1919
* @method AssetSourceCollection getSources()
2020
* @method CategorySetAssetSourcesAction setSources(AssetSourceCollection $sources = null)
21+
* @method string getAssetKey()
22+
* @method CategorySetAssetSourcesAction setAssetKey(string $assetKey = null)
2123
*/
2224
class CategorySetAssetSourcesAction extends AbstractAction
2325
{
@@ -26,6 +28,7 @@ public function fieldDefinitions()
2628
return [
2729
'action' => [static::TYPE => 'string'],
2830
'assetId' => [static::TYPE => 'string'],
31+
'assetKey' => [static::TYPE => 'string'],
2932
'sources' => [static::TYPE => AssetSourceCollection::class],
3033
];
3134
}
@@ -49,4 +52,14 @@ public static function ofAssetId($assetId, $context = null)
4952
{
5053
return static::of($context)->setAssetId($assetId);
5154
}
55+
56+
/**
57+
* @param string $assetKey
58+
* @param Context|callable $context
59+
* @return CategorySetAssetSourcesAction
60+
*/
61+
public static function ofAssetKey($assetKey, $context = null)
62+
{
63+
return static::of($context)->setAssetKey($assetKey);
64+
}
5265
}

0 commit comments

Comments
 (0)