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

Commit

Permalink
fix(CustomTypes): update to breaking changes of the API
Browse files Browse the repository at this point in the history
BREAKING CHANGE: update actions for changing the order of custom fields have been changed
  • Loading branch information
Jens Schulze committed Oct 5, 2015
1 parent b2d704f commit 5e23104
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 63 deletions.
52 changes: 6 additions & 46 deletions features/request/Type/TypeUpdate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -249,19 +249,7 @@ Feature: I want to update a type
"""
{
"action": "changeFieldDefinitionOrder",
"attributes": [
{
"type": {
"name": "String"
},
"name": "custom-string",
"label": {
"en": "Custom String"
},
"isRequired": false,
"inputHint": "SingleLine"
}
]
"fieldNames": ["field1", "field2"]
}
"""
Then the path should be "types/id"
Expand All @@ -273,19 +261,7 @@ Feature: I want to update a type
"actions": [
{
"action": "changeFieldDefinitionOrder",
"attributes": [
{
"type": {
"name": "String"
},
"name": "custom-string",
"label": {
"en": "Custom String"
},
"isRequired": false,
"inputHint": "SingleLine"
}
]
"fieldNames": ["field1", "field2"]
}
]
}
Expand All @@ -299,10 +275,7 @@ Feature: I want to update a type
{
"action": "changeEnumValueOrder",
"fieldName": "<field-name>",
"values": [{
"key": "enumkey",
"label": "Enum Label"
}]
"keys": [ "enumkey1", "enumkey2"]
}
"""
Then the path should be "types/id"
Expand All @@ -315,10 +288,7 @@ Feature: I want to update a type
{
"action": "changeEnumValueOrder",
"fieldName": "<field-name>",
"values": [{
"key": "enumkey",
"label": "Enum Label"
}]
"keys": [ "enumkey1", "enumkey2"]
}
]
}
Expand All @@ -332,12 +302,7 @@ Feature: I want to update a type
{
"action": "changeLocalizedEnumValueOrder",
"fieldName": "<field-name>",
"values": [{
"key": "enumkey",
"label": {
"en": "Enum Label"
}
}]
"keys": [ "enumkey1", "enumkey2"]
}
"""
Then the path should be "types/id"
Expand All @@ -350,12 +315,7 @@ Feature: I want to update a type
{
"action": "changeLocalizedEnumValueOrder",
"fieldName": "<field-name>",
"values": [{
"key": "enumkey",
"label": {
"en": "Enum Label"
}
}]
"keys": [ "enumkey1", "enumkey2"]
}
]
}
Expand Down
12 changes: 6 additions & 6 deletions src/Request/Types/Command/TypeChangeEnumValueOrderAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* @method TypeChangeEnumValueOrderAction setAction(string $action = null)
* @method string getFieldName()
* @method TypeChangeEnumValueOrderAction setFieldName(string $fieldName = null)
* @method EnumCollection getValues()
* @method TypeChangeEnumValueOrderAction setValues(EnumCollection $values = null)
* @method array getKeys()
* @method TypeChangeEnumValueOrderAction setKeys(array $keys = null)
*/
class TypeChangeEnumValueOrderAction extends AbstractAction
{
Expand All @@ -26,7 +26,7 @@ public function fieldDefinitions()
return [
'action' => [static::TYPE => 'string'],
'fieldName' => [static::TYPE => 'string'],
'values' => [static::TYPE => '\Commercetools\Core\Model\Common\EnumCollection']
'keys' => [static::TYPE => 'array']
];
}

Expand All @@ -41,12 +41,12 @@ public function __construct(array $data = [], $context = null)
}

/**
* @param EnumCollection $enums
* @param array $keys
* @param Context|callable $context
* @return TypeChangeEnumValueOrderAction
*/
public static function ofEnums(EnumCollection $enums, $context = null)
public static function ofEnums(array $keys, $context = null)
{
return static::of($context)->setValues($enums);
return static::of($context)->setKeys($keys);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
*
* @method string getAction()
* @method TypeChangeFieldDefinitionOrderAction setAction(string $action = null)
* @method FieldDefinitionCollection getFieldDefinitions()
* @method TypeChangeFieldDefinitionOrderAction setFieldDefinitions(FieldDefinitionCollection $fieldDefinitions = null)
* @method array getFieldNames()
* @method TypeChangeFieldDefinitionOrderAction setFieldNames(array $fieldNames = null)
*/
class TypeChangeFieldDefinitionOrderAction extends AbstractAction
{
public function fieldDefinitions()
{
return [
'action' => [static::TYPE => 'string'],
'fieldDefinitions' => [static::TYPE => '\Commercetools\Core\Model\Type\FieldDefinitionCollection'],
'fieldNames' => [static::TYPE => 'array'],
];
}

Expand All @@ -42,8 +42,8 @@ public function __construct(array $data = [], $context = null)
* @param Context|callable $context
* @return TypeChangeFieldDefinitionOrderAction
*/
public static function ofFieldDefinitions(FieldDefinitionCollection $fieldDefinitions, $context = null)
public static function ofFieldDefinitions(array $fieldNames, $context = null)
{
return static::of($context)->setFieldDefinitions($fieldDefinitions);
return static::of($context)->setFieldNames($fieldNames);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* @method TypeChangeLocalizedEnumValueOrderAction setAction(string $action = null)
* @method string getFieldName()
* @method TypeChangeLocalizedEnumValueOrderAction setFieldName(string $fieldName = null)
* @method LocalizedEnumCollection getValues()
* @method TypeChangeLocalizedEnumValueOrderAction setValues(LocalizedEnumCollection $values = null)
* @method array getKeys()
* @method TypeChangeLocalizedEnumValueOrderAction setKeys(array $keys = null)
*/
class TypeChangeLocalizedEnumValueOrderAction extends AbstractAction
{
Expand All @@ -27,7 +27,7 @@ public function fieldDefinitions()
return [
'action' => [static::TYPE => 'string'],
'fieldName' => [static::TYPE => 'string'],
'values' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedEnumCollection']
'keys' => [static::TYPE => 'array']
];
}

Expand All @@ -42,12 +42,12 @@ public function __construct(array $data = [], $context = null)
}

/**
* @param LocalizedEnumCollection $enums
* @param array $keys
* @param Context|callable $context
* @return TypeChangeLocalizedEnumValueOrderAction
*/
public static function ofEnums(LocalizedEnumCollection $enums, $context = null)
public static function ofEnums(array $keys, $context = null)
{
return static::of($context)->setValues($enums);
return static::of($context)->setKeys($keys);
}
}

0 comments on commit 5e23104

Please # to comment.