Skip to content

Commit b1ab04f

Browse files
committed
Update platform sdk
1 parent 53ec306 commit b1ab04f

File tree

9 files changed

+126
-117
lines changed

9 files changed

+126
-117
lines changed

src/commercetools/platform/models/_schemas/cart.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939

4040
# Marshmallow Schemas
4141
class CartSchema(BaseResourceSchema):
42-
key = marshmallow.fields.String(allow_none=True, missing=None)
42+
key = marshmallow.fields.String(
43+
allow_none=True, metadata={"omit_empty": True}, missing=None
44+
)
4345
last_modified_by = helpers.LazyNestedField(
4446
nested=helpers.absmod(__name__, ".common.LastModifiedBySchema"),
4547
allow_none=True,
@@ -260,6 +262,9 @@ def post_load(self, data, **kwargs):
260262

261263
class CartDraftSchema(helpers.BaseSchema):
262264
currency = marshmallow.fields.String(allow_none=True, missing=None)
265+
key = marshmallow.fields.String(
266+
allow_none=True, metadata={"omit_empty": True}, missing=None
267+
)
263268
customer_id = marshmallow.fields.String(
264269
allow_none=True,
265270
metadata={"omit_empty": True},

src/commercetools/platform/models/_schemas/channel.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,12 @@ class ChannelUpdateSchema(helpers.BaseSchema):
231231
"setAddress": helpers.absmod(
232232
__name__, ".ChannelSetAddressActionSchema"
233233
),
234-
"setAddressCustomType": helpers.absmod(
235-
__name__, ".ChannelSetAddressCustomTypeActionSchema"
236-
),
237234
"setAddressCustomField": helpers.absmod(
238235
__name__, ".ChannelSetAddressCustomFieldActionSchema"
239236
),
237+
"setAddressCustomType": helpers.absmod(
238+
__name__, ".ChannelSetAddressCustomTypeActionSchema"
239+
),
240240
"setCustomField": helpers.absmod(
241241
__name__, ".ChannelSetCustomFieldActionSchema"
242242
),
@@ -364,6 +364,21 @@ def post_load(self, data, **kwargs):
364364
return models.ChannelSetAddressAction(**data)
365365

366366

367+
class ChannelSetAddressCustomFieldActionSchema(ChannelUpdateActionSchema):
368+
name = marshmallow.fields.String(allow_none=True, missing=None)
369+
value = marshmallow.fields.Raw(
370+
allow_none=True, metadata={"omit_empty": True}, missing=None
371+
)
372+
373+
class Meta:
374+
unknown = marshmallow.EXCLUDE
375+
376+
@marshmallow.post_load
377+
def post_load(self, data, **kwargs):
378+
del data["action"]
379+
return models.ChannelSetAddressCustomFieldAction(**data)
380+
381+
367382
class ChannelSetAddressCustomTypeActionSchema(ChannelUpdateActionSchema):
368383
type = helpers.LazyNestedField(
369384
nested=helpers.absmod(__name__, ".type.TypeResourceIdentifierSchema"),
@@ -388,21 +403,6 @@ def post_load(self, data, **kwargs):
388403
return models.ChannelSetAddressCustomTypeAction(**data)
389404

390405

391-
class ChannelSetAddressCustomFieldActionSchema(ChannelUpdateActionSchema):
392-
name = marshmallow.fields.String(allow_none=True, missing=None)
393-
value = marshmallow.fields.Raw(
394-
allow_none=True, metadata={"omit_empty": True}, missing=None
395-
)
396-
397-
class Meta:
398-
unknown = marshmallow.EXCLUDE
399-
400-
@marshmallow.post_load
401-
def post_load(self, data, **kwargs):
402-
del data["action"]
403-
return models.ChannelSetAddressCustomFieldAction(**data)
404-
405-
406406
class ChannelSetCustomFieldActionSchema(ChannelUpdateActionSchema):
407407
name = marshmallow.fields.String(allow_none=True, missing=None)
408408
value = marshmallow.fields.Raw(

src/commercetools/platform/models/_schemas/customer.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -602,12 +602,12 @@ class CustomerUpdateSchema(helpers.BaseSchema):
602602
"removeStore": helpers.absmod(
603603
__name__, ".CustomerRemoveStoreActionSchema"
604604
),
605-
"setAddressCustomType": helpers.absmod(
606-
__name__, ".CustomerSetAddressCustomTypeActionSchema"
607-
),
608605
"setAddressCustomField": helpers.absmod(
609606
__name__, ".CustomerSetAddressCustomFieldActionSchema"
610607
),
608+
"setAddressCustomType": helpers.absmod(
609+
__name__, ".CustomerSetAddressCustomTypeActionSchema"
610+
),
611611
"setCompanyName": helpers.absmod(
612612
__name__, ".CustomerSetCompanyNameActionSchema"
613613
),
@@ -886,6 +886,24 @@ def post_load(self, data, **kwargs):
886886
return models.CustomerRemoveStoreAction(**data)
887887

888888

889+
class CustomerSetAddressCustomFieldActionSchema(CustomerUpdateActionSchema):
890+
address_id = marshmallow.fields.String(
891+
allow_none=True, missing=None, data_key="addressId"
892+
)
893+
name = marshmallow.fields.String(allow_none=True, missing=None)
894+
value = marshmallow.fields.Raw(
895+
allow_none=True, metadata={"omit_empty": True}, missing=None
896+
)
897+
898+
class Meta:
899+
unknown = marshmallow.EXCLUDE
900+
901+
@marshmallow.post_load
902+
def post_load(self, data, **kwargs):
903+
del data["action"]
904+
return models.CustomerSetAddressCustomFieldAction(**data)
905+
906+
889907
class CustomerSetAddressCustomTypeActionSchema(CustomerUpdateActionSchema):
890908
type = helpers.LazyNestedField(
891909
nested=helpers.absmod(__name__, ".type.TypeResourceIdentifierSchema"),
@@ -913,24 +931,6 @@ def post_load(self, data, **kwargs):
913931
return models.CustomerSetAddressCustomTypeAction(**data)
914932

915933

916-
class CustomerSetAddressCustomFieldActionSchema(CustomerUpdateActionSchema):
917-
address_id = marshmallow.fields.String(
918-
allow_none=True, missing=None, data_key="addressId"
919-
)
920-
name = marshmallow.fields.String(allow_none=True, missing=None)
921-
value = marshmallow.fields.Raw(
922-
allow_none=True, metadata={"omit_empty": True}, missing=None
923-
)
924-
925-
class Meta:
926-
unknown = marshmallow.EXCLUDE
927-
928-
@marshmallow.post_load
929-
def post_load(self, data, **kwargs):
930-
del data["action"]
931-
return models.CustomerSetAddressCustomFieldAction(**data)
932-
933-
934934
class CustomerSetCompanyNameActionSchema(CustomerUpdateActionSchema):
935935
company_name = marshmallow.fields.String(
936936
allow_none=True,

src/commercetools/platform/models/_schemas/me.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131

3232
# Marshmallow Schemas
3333
class MyCartSchema(BaseResourceSchema):
34+
key = marshmallow.fields.String(
35+
allow_none=True, metadata={"omit_empty": True}, missing=None
36+
)
3437
last_modified_by = helpers.LazyNestedField(
3538
nested=helpers.absmod(__name__, ".common.LastModifiedBySchema"),
3639
allow_none=True,
@@ -1563,7 +1566,7 @@ class MyCartAddLineItemActionSchema(MyCartUpdateActionSchema):
15631566
sku = marshmallow.fields.String(
15641567
allow_none=True, metadata={"omit_empty": True}, missing=None
15651568
)
1566-
quantity = marshmallow.fields.Float(
1569+
quantity = marshmallow.fields.Integer(
15671570
allow_none=True, metadata={"omit_empty": True}, missing=None
15681571
)
15691572
supply_channel = helpers.LazyNestedField(
@@ -1656,7 +1659,7 @@ class MyCartChangeLineItemQuantityActionSchema(MyCartUpdateActionSchema):
16561659
line_item_id = marshmallow.fields.String(
16571660
allow_none=True, missing=None, data_key="lineItemId"
16581661
)
1659-
quantity = marshmallow.fields.Float(allow_none=True, missing=None)
1662+
quantity = marshmallow.fields.Integer(allow_none=True, missing=None)
16601663
external_price = helpers.LazyNestedField(
16611664
nested=helpers.absmod(__name__, ".common.MoneySchema"),
16621665
allow_none=True,
@@ -1750,7 +1753,7 @@ class MyCartRemoveLineItemActionSchema(MyCartUpdateActionSchema):
17501753
line_item_id = marshmallow.fields.String(
17511754
allow_none=True, missing=None, data_key="lineItemId"
17521755
)
1753-
quantity = marshmallow.fields.Float(
1756+
quantity = marshmallow.fields.Integer(
17541757
allow_none=True, metadata={"omit_empty": True}, missing=None
17551758
)
17561759
external_price = helpers.LazyNestedField(

src/commercetools/platform/models/cart.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164

165165
class Cart(BaseResource):
166166
#: User-specific unique identifier of the cart.
167-
key: str
167+
key: typing.Optional[str]
168168
#: Present on resources updated after 1/02/2019 except for events not tracked.
169169
last_modified_by: typing.Optional["LastModifiedBy"]
170170
#: Present on resources created after 1/02/2019 except for events not tracked.
@@ -228,7 +228,7 @@ def __init__(
228228
version: int,
229229
created_at: datetime.datetime,
230230
last_modified_at: datetime.datetime,
231-
key: str,
231+
key: typing.Optional[str] = None,
232232
last_modified_by: typing.Optional["LastModifiedBy"] = None,
233233
created_by: typing.Optional["CreatedBy"] = None,
234234
customer_id: typing.Optional[str] = None,
@@ -311,6 +311,8 @@ def serialize(self) -> typing.Dict[str, typing.Any]:
311311
class CartDraft(_BaseType):
312312
#: A three-digit currency code as per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).
313313
currency: str
314+
#: User-specific unique identifier of the cart.
315+
key: typing.Optional[str]
314316
#: Id of an existing Customer.
315317
customer_id: typing.Optional[str]
316318
customer_email: typing.Optional[str]
@@ -368,6 +370,7 @@ def __init__(
368370
self,
369371
*,
370372
currency: str,
373+
key: typing.Optional[str] = None,
371374
customer_id: typing.Optional[str] = None,
372375
customer_email: typing.Optional[str] = None,
373376
customer_group: typing.Optional["CustomerGroupResourceIdentifier"] = None,
@@ -395,6 +398,7 @@ def __init__(
395398
discount_codes: typing.Optional[typing.List["str"]] = None
396399
):
397400
self.currency = currency
401+
self.key = key
398402
self.customer_id = customer_id
399403
self.customer_email = customer_email
400404
self.customer_group = customer_group

src/commercetools/platform/models/channel.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,14 @@ def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "ChannelUpdateAction
305305
from ._schemas.channel import ChannelSetAddressActionSchema
306306

307307
return ChannelSetAddressActionSchema().load(data)
308-
if data["action"] == "setAddressCustomType":
309-
from ._schemas.channel import ChannelSetAddressCustomTypeActionSchema
310-
311-
return ChannelSetAddressCustomTypeActionSchema().load(data)
312308
if data["action"] == "setAddressCustomField":
313309
from ._schemas.channel import ChannelSetAddressCustomFieldActionSchema
314310

315311
return ChannelSetAddressCustomFieldActionSchema().load(data)
312+
if data["action"] == "setAddressCustomType":
313+
from ._schemas.channel import ChannelSetAddressCustomTypeActionSchema
314+
315+
return ChannelSetAddressCustomTypeActionSchema().load(data)
316316
if data["action"] == "setCustomField":
317317
from ._schemas.channel import ChannelSetCustomFieldActionSchema
318318

@@ -460,6 +460,29 @@ def serialize(self) -> typing.Dict[str, typing.Any]:
460460
return ChannelSetAddressActionSchema().dump(self)
461461

462462

463+
class ChannelSetAddressCustomFieldAction(ChannelUpdateAction):
464+
name: str
465+
value: typing.Optional[typing.Any]
466+
467+
def __init__(self, *, name: str, value: typing.Optional[typing.Any] = None):
468+
self.name = name
469+
self.value = value
470+
super().__init__(action="setAddressCustomField")
471+
472+
@classmethod
473+
def deserialize(
474+
cls, data: typing.Dict[str, typing.Any]
475+
) -> "ChannelSetAddressCustomFieldAction":
476+
from ._schemas.channel import ChannelSetAddressCustomFieldActionSchema
477+
478+
return ChannelSetAddressCustomFieldActionSchema().load(data)
479+
480+
def serialize(self) -> typing.Dict[str, typing.Any]:
481+
from ._schemas.channel import ChannelSetAddressCustomFieldActionSchema
482+
483+
return ChannelSetAddressCustomFieldActionSchema().dump(self)
484+
485+
463486
class ChannelSetAddressCustomTypeAction(ChannelUpdateAction):
464487
type: typing.Optional["TypeResourceIdentifier"]
465488
fields: typing.Optional["FieldContainer"]
@@ -488,29 +511,6 @@ def serialize(self) -> typing.Dict[str, typing.Any]:
488511
return ChannelSetAddressCustomTypeActionSchema().dump(self)
489512

490513

491-
class ChannelSetAddressCustomFieldAction(ChannelUpdateAction):
492-
name: str
493-
value: typing.Optional[typing.Any]
494-
495-
def __init__(self, *, name: str, value: typing.Optional[typing.Any] = None):
496-
self.name = name
497-
self.value = value
498-
super().__init__(action="setAddressCustomField")
499-
500-
@classmethod
501-
def deserialize(
502-
cls, data: typing.Dict[str, typing.Any]
503-
) -> "ChannelSetAddressCustomFieldAction":
504-
from ._schemas.channel import ChannelSetAddressCustomFieldActionSchema
505-
506-
return ChannelSetAddressCustomFieldActionSchema().load(data)
507-
508-
def serialize(self) -> typing.Dict[str, typing.Any]:
509-
from ._schemas.channel import ChannelSetAddressCustomFieldActionSchema
510-
511-
return ChannelSetAddressCustomFieldActionSchema().dump(self)
512-
513-
514514
class ChannelSetCustomFieldAction(ChannelUpdateAction):
515515
name: str
516516
value: typing.Optional[typing.Any]

src/commercetools/platform/models/customer.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -705,14 +705,14 @@ def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "CustomerUpdateActio
705705
from ._schemas.customer import CustomerRemoveStoreActionSchema
706706

707707
return CustomerRemoveStoreActionSchema().load(data)
708-
if data["action"] == "setAddressCustomType":
709-
from ._schemas.customer import CustomerSetAddressCustomTypeActionSchema
710-
711-
return CustomerSetAddressCustomTypeActionSchema().load(data)
712708
if data["action"] == "setAddressCustomField":
713709
from ._schemas.customer import CustomerSetAddressCustomFieldActionSchema
714710

715711
return CustomerSetAddressCustomFieldActionSchema().load(data)
712+
if data["action"] == "setAddressCustomType":
713+
from ._schemas.customer import CustomerSetAddressCustomTypeActionSchema
714+
715+
return CustomerSetAddressCustomTypeActionSchema().load(data)
716716
if data["action"] == "setCompanyName":
717717
from ._schemas.customer import CustomerSetCompanyNameActionSchema
718718

@@ -1047,6 +1047,33 @@ def serialize(self) -> typing.Dict[str, typing.Any]:
10471047
return CustomerRemoveStoreActionSchema().dump(self)
10481048

10491049

1050+
class CustomerSetAddressCustomFieldAction(CustomerUpdateAction):
1051+
address_id: str
1052+
name: str
1053+
value: typing.Optional[typing.Any]
1054+
1055+
def __init__(
1056+
self, *, address_id: str, name: str, value: typing.Optional[typing.Any] = None
1057+
):
1058+
self.address_id = address_id
1059+
self.name = name
1060+
self.value = value
1061+
super().__init__(action="setAddressCustomField")
1062+
1063+
@classmethod
1064+
def deserialize(
1065+
cls, data: typing.Dict[str, typing.Any]
1066+
) -> "CustomerSetAddressCustomFieldAction":
1067+
from ._schemas.customer import CustomerSetAddressCustomFieldActionSchema
1068+
1069+
return CustomerSetAddressCustomFieldActionSchema().load(data)
1070+
1071+
def serialize(self) -> typing.Dict[str, typing.Any]:
1072+
from ._schemas.customer import CustomerSetAddressCustomFieldActionSchema
1073+
1074+
return CustomerSetAddressCustomFieldActionSchema().dump(self)
1075+
1076+
10501077
class CustomerSetAddressCustomTypeAction(CustomerUpdateAction):
10511078
type: typing.Optional["TypeResourceIdentifier"]
10521079
fields: typing.Optional["FieldContainer"]
@@ -1078,33 +1105,6 @@ def serialize(self) -> typing.Dict[str, typing.Any]:
10781105
return CustomerSetAddressCustomTypeActionSchema().dump(self)
10791106

10801107

1081-
class CustomerSetAddressCustomFieldAction(CustomerUpdateAction):
1082-
address_id: str
1083-
name: str
1084-
value: typing.Optional[typing.Any]
1085-
1086-
def __init__(
1087-
self, *, address_id: str, name: str, value: typing.Optional[typing.Any] = None
1088-
):
1089-
self.address_id = address_id
1090-
self.name = name
1091-
self.value = value
1092-
super().__init__(action="setAddressCustomField")
1093-
1094-
@classmethod
1095-
def deserialize(
1096-
cls, data: typing.Dict[str, typing.Any]
1097-
) -> "CustomerSetAddressCustomFieldAction":
1098-
from ._schemas.customer import CustomerSetAddressCustomFieldActionSchema
1099-
1100-
return CustomerSetAddressCustomFieldActionSchema().load(data)
1101-
1102-
def serialize(self) -> typing.Dict[str, typing.Any]:
1103-
from ._schemas.customer import CustomerSetAddressCustomFieldActionSchema
1104-
1105-
return CustomerSetAddressCustomFieldActionSchema().dump(self)
1106-
1107-
11081108
class CustomerSetCompanyNameAction(CustomerUpdateAction):
11091109
#: If not defined, the company name is unset.
11101110
company_name: typing.Optional[str]

0 commit comments

Comments
 (0)