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

Commit 5e23104

Browse files
author
Jens Schulze
committed
fix(CustomTypes): update to breaking changes of the API
BREAKING CHANGE: update actions for changing the order of custom fields have been changed
1 parent b2d704f commit 5e23104

File tree

4 files changed

+23
-63
lines changed

4 files changed

+23
-63
lines changed

features/request/Type/TypeUpdate.feature

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -249,19 +249,7 @@ Feature: I want to update a type
249249
"""
250250
{
251251
"action": "changeFieldDefinitionOrder",
252-
"attributes": [
253-
{
254-
"type": {
255-
"name": "String"
256-
},
257-
"name": "custom-string",
258-
"label": {
259-
"en": "Custom String"
260-
},
261-
"isRequired": false,
262-
"inputHint": "SingleLine"
263-
}
264-
]
252+
"fieldNames": ["field1", "field2"]
265253
}
266254
"""
267255
Then the path should be "types/id"
@@ -273,19 +261,7 @@ Feature: I want to update a type
273261
"actions": [
274262
{
275263
"action": "changeFieldDefinitionOrder",
276-
"attributes": [
277-
{
278-
"type": {
279-
"name": "String"
280-
},
281-
"name": "custom-string",
282-
"label": {
283-
"en": "Custom String"
284-
},
285-
"isRequired": false,
286-
"inputHint": "SingleLine"
287-
}
288-
]
264+
"fieldNames": ["field1", "field2"]
289265
}
290266
]
291267
}
@@ -299,10 +275,7 @@ Feature: I want to update a type
299275
{
300276
"action": "changeEnumValueOrder",
301277
"fieldName": "<field-name>",
302-
"values": [{
303-
"key": "enumkey",
304-
"label": "Enum Label"
305-
}]
278+
"keys": [ "enumkey1", "enumkey2"]
306279
}
307280
"""
308281
Then the path should be "types/id"
@@ -315,10 +288,7 @@ Feature: I want to update a type
315288
{
316289
"action": "changeEnumValueOrder",
317290
"fieldName": "<field-name>",
318-
"values": [{
319-
"key": "enumkey",
320-
"label": "Enum Label"
321-
}]
291+
"keys": [ "enumkey1", "enumkey2"]
322292
}
323293
]
324294
}
@@ -332,12 +302,7 @@ Feature: I want to update a type
332302
{
333303
"action": "changeLocalizedEnumValueOrder",
334304
"fieldName": "<field-name>",
335-
"values": [{
336-
"key": "enumkey",
337-
"label": {
338-
"en": "Enum Label"
339-
}
340-
}]
305+
"keys": [ "enumkey1", "enumkey2"]
341306
}
342307
"""
343308
Then the path should be "types/id"
@@ -350,12 +315,7 @@ Feature: I want to update a type
350315
{
351316
"action": "changeLocalizedEnumValueOrder",
352317
"fieldName": "<field-name>",
353-
"values": [{
354-
"key": "enumkey",
355-
"label": {
356-
"en": "Enum Label"
357-
}
358-
}]
318+
"keys": [ "enumkey1", "enumkey2"]
359319
}
360320
]
361321
}

src/Request/Types/Command/TypeChangeEnumValueOrderAction.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* @method TypeChangeEnumValueOrderAction setAction(string $action = null)
1717
* @method string getFieldName()
1818
* @method TypeChangeEnumValueOrderAction setFieldName(string $fieldName = null)
19-
* @method EnumCollection getValues()
20-
* @method TypeChangeEnumValueOrderAction setValues(EnumCollection $values = null)
19+
* @method array getKeys()
20+
* @method TypeChangeEnumValueOrderAction setKeys(array $keys = null)
2121
*/
2222
class TypeChangeEnumValueOrderAction extends AbstractAction
2323
{
@@ -26,7 +26,7 @@ public function fieldDefinitions()
2626
return [
2727
'action' => [static::TYPE => 'string'],
2828
'fieldName' => [static::TYPE => 'string'],
29-
'values' => [static::TYPE => '\Commercetools\Core\Model\Common\EnumCollection']
29+
'keys' => [static::TYPE => 'array']
3030
];
3131
}
3232

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

4343
/**
44-
* @param EnumCollection $enums
44+
* @param array $keys
4545
* @param Context|callable $context
4646
* @return TypeChangeEnumValueOrderAction
4747
*/
48-
public static function ofEnums(EnumCollection $enums, $context = null)
48+
public static function ofEnums(array $keys, $context = null)
4949
{
50-
return static::of($context)->setValues($enums);
50+
return static::of($context)->setKeys($keys);
5151
}
5252
}

src/Request/Types/Command/TypeChangeFieldDefinitionOrderAction.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
*
1515
* @method string getAction()
1616
* @method TypeChangeFieldDefinitionOrderAction setAction(string $action = null)
17-
* @method FieldDefinitionCollection getFieldDefinitions()
18-
* @method TypeChangeFieldDefinitionOrderAction setFieldDefinitions(FieldDefinitionCollection $fieldDefinitions = null)
17+
* @method array getFieldNames()
18+
* @method TypeChangeFieldDefinitionOrderAction setFieldNames(array $fieldNames = null)
1919
*/
2020
class TypeChangeFieldDefinitionOrderAction extends AbstractAction
2121
{
2222
public function fieldDefinitions()
2323
{
2424
return [
2525
'action' => [static::TYPE => 'string'],
26-
'fieldDefinitions' => [static::TYPE => '\Commercetools\Core\Model\Type\FieldDefinitionCollection'],
26+
'fieldNames' => [static::TYPE => 'array'],
2727
];
2828
}
2929

@@ -42,8 +42,8 @@ public function __construct(array $data = [], $context = null)
4242
* @param Context|callable $context
4343
* @return TypeChangeFieldDefinitionOrderAction
4444
*/
45-
public static function ofFieldDefinitions(FieldDefinitionCollection $fieldDefinitions, $context = null)
45+
public static function ofFieldDefinitions(array $fieldNames, $context = null)
4646
{
47-
return static::of($context)->setFieldDefinitions($fieldDefinitions);
47+
return static::of($context)->setFieldNames($fieldNames);
4848
}
4949
}

src/Request/Types/Command/TypeChangeLocalizedEnumValueOrderAction.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* @method TypeChangeLocalizedEnumValueOrderAction setAction(string $action = null)
1818
* @method string getFieldName()
1919
* @method TypeChangeLocalizedEnumValueOrderAction setFieldName(string $fieldName = null)
20-
* @method LocalizedEnumCollection getValues()
21-
* @method TypeChangeLocalizedEnumValueOrderAction setValues(LocalizedEnumCollection $values = null)
20+
* @method array getKeys()
21+
* @method TypeChangeLocalizedEnumValueOrderAction setKeys(array $keys = null)
2222
*/
2323
class TypeChangeLocalizedEnumValueOrderAction extends AbstractAction
2424
{
@@ -27,7 +27,7 @@ public function fieldDefinitions()
2727
return [
2828
'action' => [static::TYPE => 'string'],
2929
'fieldName' => [static::TYPE => 'string'],
30-
'values' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedEnumCollection']
30+
'keys' => [static::TYPE => 'array']
3131
];
3232
}
3333

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

4444
/**
45-
* @param LocalizedEnumCollection $enums
45+
* @param array $keys
4646
* @param Context|callable $context
4747
* @return TypeChangeLocalizedEnumValueOrderAction
4848
*/
49-
public static function ofEnums(LocalizedEnumCollection $enums, $context = null)
49+
public static function ofEnums(array $keys, $context = null)
5050
{
51-
return static::of($context)->setValues($enums);
51+
return static::of($context)->setKeys($keys);
5252
}
5353
}

0 commit comments

Comments
 (0)