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

Commit 5a7716d

Browse files
author
Jens Schulze
committed
feat(Category): add assets to categories
Closes #285
1 parent 312cf6f commit 5a7716d

14 files changed

+665
-3
lines changed

src/Model/Category/Category.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Commercetools\Core\Model\Common\LocalizedString;
1010
use Commercetools\Core\Model\CustomField\CustomFieldObject;
1111
use Commercetools\Core\Model\Common\DateTimeDecorator;
12+
use Commercetools\Core\Model\Common\AssetCollection;
1213

1314
/**
1415
* @package Commercetools\Core\Model\Category
@@ -43,6 +44,8 @@
4344
* @method Category setMetaTitle(LocalizedString $metaTitle = null)
4445
* @method LocalizedString getMetaKeywords()
4546
* @method Category setMetaKeywords(LocalizedString $metaKeywords = null)
47+
* @method AssetCollection getAssets()
48+
* @method Category setAssets(AssetCollection $assets = null)
4649
* @method CategoryReference getReference()
4750
*/
4851
class Category extends Resource
@@ -71,6 +74,7 @@ public function fieldDefinitions()
7174
'metaTitle' => [static::TYPE => 'Commercetools\Core\Model\Common\LocalizedString'],
7275
'metaKeywords' => [static::TYPE => 'Commercetools\Core\Model\Common\LocalizedString'],
7376
'custom' => [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObject'],
77+
'assets' => [static::TYPE => '\Commercetools\Core\Model\Common\AssetCollection']
7478
];
7579
}
7680
}

src/Model/Category/CategoryDraft.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Commercetools\Core\Model\Common\JsonObject;
1111
use Commercetools\Core\Model\Common\LocalizedString;
1212
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft;
13+
use Commercetools\Core\Model\Common\AssetDraftCollection;
1314

1415
/**
1516
* @package Commercetools\Core\Model\Category
@@ -34,6 +35,8 @@
3435
* @method CategoryDraft setMetaTitle(LocalizedString $metaTitle = null)
3536
* @method LocalizedString getMetaKeywords()
3637
* @method CategoryDraft setMetaKeywords(LocalizedString $metaKeywords = null)
38+
* @method AssetDraftCollection getAssets()
39+
* @method CategoryDraft setAssets(AssetDraftCollection $assets = null)
3740
*/
3841
class CategoryDraft extends JsonObject
3942
{
@@ -50,6 +53,7 @@ public function fieldDefinitions()
5053
'metaTitle' => [static::TYPE => 'Commercetools\Core\Model\Common\LocalizedString'],
5154
'metaKeywords' => [static::TYPE => 'Commercetools\Core\Model\Common\LocalizedString'],
5255
'custom' => [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObjectDraft'],
56+
'assets' => [static::TYPE => '\Commercetools\Core\Model\Common\AssetDraftCollection']
5357
];
5458
}
5559

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* @author @jayS-de <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\Request\AbstractAction;
10+
use Commercetools\Core\Model\Common\AssetDraft;
11+
12+
/**
13+
* @package Commercetools\Core\Request\Categories\Command
14+
* @link https://dev.commercetools.com/http-api-projects-products.html#add-asset
15+
* @method string getAction()
16+
* @method CategoryAddAssetAction setAction(string $action = null)
17+
* @method AssetDraft getAsset()
18+
* @method CategoryAddAssetAction setAsset(AssetDraft $asset = null)
19+
*/
20+
class CategoryAddAssetAction extends AbstractAction
21+
{
22+
public function fieldDefinitions()
23+
{
24+
return [
25+
'action' => [static::TYPE => 'string'],
26+
'asset' => [static::TYPE => '\Commercetools\Core\Model\Common\AssetDraft'],
27+
];
28+
}
29+
30+
/**
31+
* @param array $data
32+
* @param Context|callable $context
33+
*/
34+
public function __construct(array $data = [], $context = null)
35+
{
36+
parent::__construct($data, $context);
37+
$this->setAction('addAsset');
38+
}
39+
40+
/**
41+
* @param AssetDraft $asset
42+
* @param Context|callable $context
43+
* @return CategoryAddAssetAction
44+
*/
45+
public static function ofAsset(AssetDraft $asset, $context = null)
46+
{
47+
return static::of($context)->setAsset($asset);
48+
}
49+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* @author @jayS-de <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://dev.commercetools.com/http-api-projects-products.html#change-asset-name
15+
* @method string getAction()
16+
* @method CategoryChangeAssetNameAction setAction(string $action = null)
17+
* @method LocalizedString getName()
18+
* @method CategoryChangeAssetNameAction setName(LocalizedString $name = null)
19+
* @method string getAssetId()
20+
* @method CategoryChangeAssetNameAction setAssetId(string $assetId = null)
21+
*/
22+
class CategoryChangeAssetNameAction extends AbstractAction
23+
{
24+
public function fieldDefinitions()
25+
{
26+
return [
27+
'action' => [static::TYPE => 'string'],
28+
'assetId' => [static::TYPE => 'string'],
29+
'name' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'],
30+
];
31+
}
32+
33+
/**
34+
* @param array $data
35+
* @param Context|callable $context
36+
*/
37+
public function __construct(array $data = [], $context = null)
38+
{
39+
parent::__construct($data, $context);
40+
$this->setAction('changeAssetName');
41+
}
42+
43+
/**
44+
* @param string $assetId
45+
* @param LocalizedString $name
46+
* @param Context|callable $context
47+
* @return CategoryChangeAssetNameAction
48+
*/
49+
public static function ofAssetIdAndName($assetId, LocalizedString $name, $context = null)
50+
{
51+
return static::of($context)->setAssetId($assetId)->setName($name);
52+
}
53+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* @author @jayS-de <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\Request\AbstractAction;
10+
use Commercetools\Core\Model\Common\AssetDraft;
11+
12+
/**
13+
* @package Commercetools\Core\Request\Categories\Command
14+
*
15+
* @method string getAction()
16+
* @method CategoryChangeAssetOrderAction setAction(string $action = null)
17+
* @method array getAssetOrder()
18+
* @method CategoryChangeAssetOrderAction setAssetOrder(array $assetOrder = null)
19+
*/
20+
class CategoryChangeAssetOrderAction extends AbstractAction
21+
{
22+
public function fieldDefinitions()
23+
{
24+
return [
25+
'action' => [static::TYPE => 'string'],
26+
'assetOrder' => [static::TYPE => 'array'],
27+
];
28+
}
29+
30+
/**
31+
* @param array $data
32+
* @param Context|callable $context
33+
*/
34+
public function __construct(array $data = [], $context = null)
35+
{
36+
parent::__construct($data, $context);
37+
$this->setAction('changeAssetOrder');
38+
}
39+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* @author @jayS-de <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\Request\AbstractAction;
10+
11+
/**
12+
* @package Commercetools\Core\Request\Categories\Command
13+
* @link https://dev.commercetools.com/http-api-projects-products.html#remove-asset
14+
* @method string getAction()
15+
* @method CategoryRemoveAssetAction setAction(string $action = null)
16+
* @method string getAssetId()
17+
* @method CategoryRemoveAssetAction setAssetId(string $assetId = null)
18+
*/
19+
class CategoryRemoveAssetAction extends AbstractAction
20+
{
21+
public function fieldDefinitions()
22+
{
23+
return [
24+
'action' => [static::TYPE => 'string'],
25+
'assetId' => [static::TYPE => 'string'],
26+
];
27+
}
28+
29+
/**
30+
* @param array $data
31+
* @param Context|callable $context
32+
*/
33+
public function __construct(array $data = [], $context = null)
34+
{
35+
parent::__construct($data, $context);
36+
$this->setAction('removeAsset');
37+
}
38+
39+
/**
40+
* @param string $assetId
41+
* @param Context|callable $context
42+
* @return CategoryRemoveAssetAction
43+
*/
44+
public static function ofAssetId($assetId, $context = null)
45+
{
46+
return static::of($context)->setAssetId($assetId);
47+
}
48+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* @author @jayS-de <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\Request\CustomField\Command\SetCustomFieldAction;
10+
11+
/**
12+
* @package Commercetools\Core\Request\Categories\Command
13+
* @link https://dev.commercetools.com/http-api-projects-products.html#set-asset-customfield
14+
*
15+
* @method string getAction()
16+
* @method CategorySetAssetCustomFieldAction setAction(string $action = null)
17+
* @method string getAssetId()
18+
* @method CategorySetAssetCustomFieldAction setAssetId(string $assetId = null)
19+
* @method string getName()
20+
* @method CategorySetAssetCustomFieldAction setName(string $name = null)
21+
* @method mixed getValue()
22+
* @method CategorySetAssetCustomFieldAction setValue($value = null)
23+
*/
24+
class CategorySetAssetCustomFieldAction extends SetCustomFieldAction
25+
{
26+
public function fieldDefinitions()
27+
{
28+
return [
29+
'action' => [static::TYPE => 'string'],
30+
'assetId' => [static::TYPE => 'string'],
31+
'name' => [static::TYPE => 'string'],
32+
'value' => [static::TYPE => null],
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('setAssetCustomField');
44+
}
45+
46+
/**
47+
* @param string $assetId
48+
* @param string $name
49+
* @param Context|callable $context
50+
* @return CategorySetAssetCustomFieldAction
51+
*/
52+
public static function ofAssetIdAndName($assetId, $name, $context = null)
53+
{
54+
return static::of($context)->setAssetId($assetId)->setName($name);
55+
}
56+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* @author @jayS-de <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\Request\CustomField\Command\SetCustomTypeAction;
10+
use Commercetools\Core\Model\CustomField\FieldContainer;
11+
use Commercetools\Core\Model\Type\TypeReference;
12+
13+
/**
14+
* @package Commercetools\Core\Request\Categories\Command
15+
* @link https://dev.commercetools.com/http-api-projects-products.html#set-asset-custom-type
16+
* @method string getAction()
17+
* @method CategorySetAssetCustomTypeAction setAction(string $action = null)
18+
* @method string getAssetId()
19+
* @method CategorySetAssetCustomTypeAction setAssetId(string $assetId = null)
20+
* @method TypeReference getType()
21+
* @method CategorySetAssetCustomTypeAction setType(TypeReference $type = null)
22+
* @method FieldContainer getFields()
23+
* @method CategorySetAssetCustomTypeAction setFields(FieldContainer $fields = null)
24+
*/
25+
class CategorySetAssetCustomTypeAction extends SetCustomTypeAction
26+
{
27+
public function fieldDefinitions()
28+
{
29+
return [
30+
'action' => [static::TYPE => 'string'],
31+
'assetId' => [static::TYPE => 'string'],
32+
'type' => [static::TYPE => '\Commercetools\Core\Model\Type\TypeReference'],
33+
'fields' => [static::TYPE => '\Commercetools\Core\Model\CustomField\FieldContainer'],
34+
];
35+
}
36+
37+
/**
38+
* @param array $data
39+
* @param Context|callable $context
40+
*/
41+
public function __construct(array $data = [], $context = null)
42+
{
43+
parent::__construct($data, $context);
44+
$this->setAction('setAssetCustomType');
45+
}
46+
47+
/**
48+
* @param TypeReference $type
49+
* @param string $assetId
50+
* @param Context|callable $context
51+
* @return CategorySetAssetCustomTypeAction
52+
*/
53+
public static function ofTypeAssetIdAndName(TypeReference $type, $assetId, $context = null)
54+
{
55+
return static::of($context)->setType($type)->setAssetId($assetId);
56+
}
57+
}

0 commit comments

Comments
 (0)