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

Commit

Permalink
feat(ProductType): add key to product type
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Schulze committed Feb 17, 2016
1 parent 6893790 commit 4e1d393
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Model/ProductType/ProductType.php
Expand Up @@ -25,6 +25,8 @@
* @method ProductType setDescription(string $description = null)
* @method AttributeDefinitionCollection getAttributes()
* @method ProductType setAttributes(AttributeDefinitionCollection $attributes = null)
* @method string getKey()
* @method ProductType setKey(string $key = null)
*/
class ProductType extends Resource
{
Expand All @@ -44,6 +46,7 @@ public function fieldDefinitions()
static::TYPE => '\DateTime',
static::DECORATOR => '\Commercetools\Core\Model\Common\DateTimeDecorator'
],
'key' => [static::TYPE => 'string'],
'name' => [static::TYPE => 'string'],
'description' => [static::TYPE => 'string'],
'attributes' => [static::TYPE => '\Commercetools\Core\Model\ProductType\AttributeDefinitionCollection']
Expand Down
3 changes: 3 additions & 0 deletions src/Model/ProductType/ProductTypeDraft.php
Expand Up @@ -17,13 +17,16 @@
* @method ProductTypeDraft setDescription(string $description = null)
* @method AttributeDefinitionCollection getAttributes()
* @method ProductTypeDraft setAttributes(AttributeDefinitionCollection $attributes = null)
* @method string getKey()
* @method ProductTypeDraft setKey(string $key = null)
*/
class ProductTypeDraft extends JsonObject
{
public function fieldDefinitions()
{
return [
'name' => [static::TYPE => 'string'],
'key' => [static::TYPE => 'string'],
'description' => [static::TYPE => 'string'],
'attributes' => [static::TYPE => '\Commercetools\Core\Model\ProductType\AttributeDefinitionCollection'],
];
Expand Down
48 changes: 48 additions & 0 deletions src/Request/ProductTypes/Command/ProductTypeSetKeyAction.php
@@ -0,0 +1,48 @@
<?php
/**
* @author @jayS-de <jens.schulze@commercetools.de>
*/

namespace Commercetools\Core\Request\ProductTypes\Command;

use Commercetools\Core\Model\Common\Context;
use Commercetools\Core\Request\AbstractAction;

/**
* @package Commercetools\Core\Request\ProductTypes\Command
* @link https://dev.commercetools.com/http-api-projects-productTypes.html#set-key
* @method string getAction()
* @method ProductTypeSetKeyAction setAction(string $action = null)
* @method string getKey()
* @method ProductTypeSetKeyAction setKey(string $key = null)
*/
class ProductTypeSetKeyAction extends AbstractAction
{
public function fieldDefinitions()
{
return [
'action' => [static::TYPE => 'string'],
'key' => [static::TYPE => 'string']
];
}

/**
* @param array $data
* @param Context|callable $context
*/
public function __construct(array $data = [], $context = null)
{
parent::__construct($data, $context);
$this->setAction('setKey');
}

/**
* @param string $name
* @param Context|callable $context
* @return ProductTypeSetKeyAction
*/
public static function ofKey($key, $context = null)
{
return static::of($context)->setKey($key);
}
}
2 changes: 2 additions & 0 deletions tests/fixtures/models.yaml
Expand Up @@ -749,6 +749,7 @@ productType:
- version
- createdAt
- lastModifiedAt
- key
- name
- description
- attributes
Expand All @@ -757,6 +758,7 @@ productTypeDraft:
domain: productType
model: ProductTypeDraft
fields:
- key
- name
- description
- attributes
Expand Down

0 comments on commit 4e1d393

Please sign in to comment.