Skip to content

Commit a7123ec

Browse files
authored
Add custom fields to Address + update actions
1 parent b18a1a2 commit a7123ec

File tree

13 files changed

+1651
-6
lines changed

13 files changed

+1651
-6
lines changed

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

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,12 @@ class CartUpdateSchema(helpers.BaseSchema):
565565
"setBillingAddress": helpers.absmod(
566566
__name__, ".CartSetBillingAddressActionSchema"
567567
),
568+
"setBillingAddressCustomField": helpers.absmod(
569+
__name__, ".CartSetBillingAddressCustomFieldActionSchema"
570+
),
571+
"setBillingAddressCustomType": helpers.absmod(
572+
__name__, ".CartSetBillingAddressCustomTypeActionSchema"
573+
),
568574
"setCartTotalTax": helpers.absmod(
569575
__name__, ".CartSetCartTotalTaxActionSchema"
570576
),
@@ -605,6 +611,18 @@ class CartUpdateSchema(helpers.BaseSchema):
605611
"setDeleteDaysAfterLastModification": helpers.absmod(
606612
__name__, ".CartSetDeleteDaysAfterLastModificationActionSchema"
607613
),
614+
"setDeliveryAddressCustomField": helpers.absmod(
615+
__name__, ".CartSetDeliveryAddressCustomFieldActionSchema"
616+
),
617+
"setDeliveryAddressCustomType": helpers.absmod(
618+
__name__, ".CartSetDeliveryAddressCustomTypeActionSchema"
619+
),
620+
"setItemShippingAddressCustomField": helpers.absmod(
621+
__name__, ".CartSetItemShippingAddressCustomFieldActionSchema"
622+
),
623+
"setItemShippingAddressCustomType": helpers.absmod(
624+
__name__, ".CartSetItemShippingAddressCustomTypeActionSchema"
625+
),
608626
"setKey": helpers.absmod(__name__, ".CartSetKeyActionSchema"),
609627
"setLineItemCustomField": helpers.absmod(
610628
__name__, ".CartSetLineItemCustomFieldActionSchema"
@@ -634,6 +652,12 @@ class CartUpdateSchema(helpers.BaseSchema):
634652
"setShippingAddress": helpers.absmod(
635653
__name__, ".CartSetShippingAddressActionSchema"
636654
),
655+
"setShippingAddressCustomField": helpers.absmod(
656+
__name__, ".CartSetShippingAddressCustomFieldActionSchema"
657+
),
658+
"setShippingAddressCustomType": helpers.absmod(
659+
__name__, ".CartSetShippingAddressCustomTypeActionSchema"
660+
),
637661
"setShippingMethod": helpers.absmod(
638662
__name__, ".CartSetShippingMethodActionSchema"
639663
),
@@ -2231,6 +2255,45 @@ def post_load(self, data, **kwargs):
22312255
return models.CartSetBillingAddressAction(**data)
22322256

22332257

2258+
class CartSetBillingAddressCustomFieldActionSchema(CartUpdateActionSchema):
2259+
name = marshmallow.fields.String(allow_none=True, missing=None)
2260+
value = marshmallow.fields.Raw(
2261+
allow_none=True, metadata={"omit_empty": True}, missing=None
2262+
)
2263+
2264+
class Meta:
2265+
unknown = marshmallow.EXCLUDE
2266+
2267+
@marshmallow.post_load
2268+
def post_load(self, data, **kwargs):
2269+
del data["action"]
2270+
return models.CartSetBillingAddressCustomFieldAction(**data)
2271+
2272+
2273+
class CartSetBillingAddressCustomTypeActionSchema(CartUpdateActionSchema):
2274+
type = helpers.LazyNestedField(
2275+
nested=helpers.absmod(__name__, ".type.TypeResourceIdentifierSchema"),
2276+
allow_none=True,
2277+
unknown=marshmallow.EXCLUDE,
2278+
metadata={"omit_empty": True},
2279+
missing=None,
2280+
)
2281+
fields = FieldContainerField(
2282+
allow_none=True,
2283+
values=marshmallow.fields.Raw(allow_none=True),
2284+
metadata={"omit_empty": True},
2285+
missing=None,
2286+
)
2287+
2288+
class Meta:
2289+
unknown = marshmallow.EXCLUDE
2290+
2291+
@marshmallow.post_load
2292+
def post_load(self, data, **kwargs):
2293+
del data["action"]
2294+
return models.CartSetBillingAddressCustomTypeAction(**data)
2295+
2296+
22342297
class CartSetCartTotalTaxActionSchema(CartUpdateActionSchema):
22352298
external_total_gross = helpers.LazyNestedField(
22362299
nested=helpers.absmod(__name__, ".common.MoneySchema"),
@@ -2528,6 +2591,96 @@ def post_load(self, data, **kwargs):
25282591
return models.CartSetDeleteDaysAfterLastModificationAction(**data)
25292592

25302593

2594+
class CartSetDeliveryAddressCustomFieldActionSchema(CartUpdateActionSchema):
2595+
delivery_id = marshmallow.fields.String(
2596+
allow_none=True, missing=None, data_key="deliveryId"
2597+
)
2598+
type = helpers.LazyNestedField(
2599+
nested=helpers.absmod(__name__, ".type.TypeResourceIdentifierSchema"),
2600+
allow_none=True,
2601+
unknown=marshmallow.EXCLUDE,
2602+
metadata={"omit_empty": True},
2603+
missing=None,
2604+
)
2605+
fields = FieldContainerField(
2606+
allow_none=True,
2607+
values=marshmallow.fields.Raw(allow_none=True),
2608+
metadata={"omit_empty": True},
2609+
missing=None,
2610+
)
2611+
2612+
class Meta:
2613+
unknown = marshmallow.EXCLUDE
2614+
2615+
@marshmallow.post_load
2616+
def post_load(self, data, **kwargs):
2617+
del data["action"]
2618+
return models.CartSetDeliveryAddressCustomFieldAction(**data)
2619+
2620+
2621+
class CartSetDeliveryAddressCustomTypeActionSchema(CartUpdateActionSchema):
2622+
delivery_id = marshmallow.fields.String(
2623+
allow_none=True, missing=None, data_key="deliveryId"
2624+
)
2625+
name = marshmallow.fields.String(allow_none=True, missing=None)
2626+
value = marshmallow.fields.Raw(
2627+
allow_none=True, metadata={"omit_empty": True}, missing=None
2628+
)
2629+
2630+
class Meta:
2631+
unknown = marshmallow.EXCLUDE
2632+
2633+
@marshmallow.post_load
2634+
def post_load(self, data, **kwargs):
2635+
del data["action"]
2636+
return models.CartSetDeliveryAddressCustomTypeAction(**data)
2637+
2638+
2639+
class CartSetItemShippingAddressCustomFieldActionSchema(CartUpdateActionSchema):
2640+
address_key = marshmallow.fields.String(
2641+
allow_none=True, missing=None, data_key="addressKey"
2642+
)
2643+
name = marshmallow.fields.String(allow_none=True, missing=None)
2644+
value = marshmallow.fields.Raw(
2645+
allow_none=True, metadata={"omit_empty": True}, missing=None
2646+
)
2647+
2648+
class Meta:
2649+
unknown = marshmallow.EXCLUDE
2650+
2651+
@marshmallow.post_load
2652+
def post_load(self, data, **kwargs):
2653+
del data["action"]
2654+
return models.CartSetItemShippingAddressCustomFieldAction(**data)
2655+
2656+
2657+
class CartSetItemShippingAddressCustomTypeActionSchema(CartUpdateActionSchema):
2658+
address_key = marshmallow.fields.String(
2659+
allow_none=True, missing=None, data_key="addressKey"
2660+
)
2661+
type = helpers.LazyNestedField(
2662+
nested=helpers.absmod(__name__, ".type.TypeResourceIdentifierSchema"),
2663+
allow_none=True,
2664+
unknown=marshmallow.EXCLUDE,
2665+
metadata={"omit_empty": True},
2666+
missing=None,
2667+
)
2668+
fields = FieldContainerField(
2669+
allow_none=True,
2670+
values=marshmallow.fields.Raw(allow_none=True),
2671+
metadata={"omit_empty": True},
2672+
missing=None,
2673+
)
2674+
2675+
class Meta:
2676+
unknown = marshmallow.EXCLUDE
2677+
2678+
@marshmallow.post_load
2679+
def post_load(self, data, **kwargs):
2680+
del data["action"]
2681+
return models.CartSetItemShippingAddressCustomTypeAction(**data)
2682+
2683+
25312684
class CartSetKeyActionSchema(CartUpdateActionSchema):
25322685
key = marshmallow.fields.String(
25332686
allow_none=True, metadata={"omit_empty": True}, missing=None
@@ -2751,6 +2904,45 @@ def post_load(self, data, **kwargs):
27512904
return models.CartSetShippingAddressAction(**data)
27522905

27532906

2907+
class CartSetShippingAddressCustomFieldActionSchema(CartUpdateActionSchema):
2908+
name = marshmallow.fields.String(allow_none=True, missing=None)
2909+
value = marshmallow.fields.Raw(
2910+
allow_none=True, metadata={"omit_empty": True}, missing=None
2911+
)
2912+
2913+
class Meta:
2914+
unknown = marshmallow.EXCLUDE
2915+
2916+
@marshmallow.post_load
2917+
def post_load(self, data, **kwargs):
2918+
del data["action"]
2919+
return models.CartSetShippingAddressCustomFieldAction(**data)
2920+
2921+
2922+
class CartSetShippingAddressCustomTypeActionSchema(CartUpdateActionSchema):
2923+
type = helpers.LazyNestedField(
2924+
nested=helpers.absmod(__name__, ".type.TypeResourceIdentifierSchema"),
2925+
allow_none=True,
2926+
unknown=marshmallow.EXCLUDE,
2927+
metadata={"omit_empty": True},
2928+
missing=None,
2929+
)
2930+
fields = FieldContainerField(
2931+
allow_none=True,
2932+
values=marshmallow.fields.Raw(allow_none=True),
2933+
metadata={"omit_empty": True},
2934+
missing=None,
2935+
)
2936+
2937+
class Meta:
2938+
unknown = marshmallow.EXCLUDE
2939+
2940+
@marshmallow.post_load
2941+
def post_load(self, data, **kwargs):
2942+
del data["action"]
2943+
return models.CartSetShippingAddressCustomTypeAction(**data)
2944+
2945+
27542946
class CartSetShippingMethodActionSchema(CartUpdateActionSchema):
27552947
shipping_method = helpers.LazyNestedField(
27562948
nested=helpers.absmod(

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ class ChannelUpdateSchema(helpers.BaseSchema):
231231
"setAddress": helpers.absmod(
232232
__name__, ".ChannelSetAddressActionSchema"
233233
),
234+
"setAddressCustomType": helpers.absmod(
235+
__name__, ".ChannelSetAddressCustomTypeActionSchema"
236+
),
237+
"setAddressCustomField": helpers.absmod(
238+
__name__, ".ChannelSetAddressCustomFieldActionSchema"
239+
),
234240
"setCustomField": helpers.absmod(
235241
__name__, ".ChannelSetCustomFieldActionSchema"
236242
),
@@ -358,6 +364,45 @@ def post_load(self, data, **kwargs):
358364
return models.ChannelSetAddressAction(**data)
359365

360366

367+
class ChannelSetAddressCustomTypeActionSchema(ChannelUpdateActionSchema):
368+
type = helpers.LazyNestedField(
369+
nested=helpers.absmod(__name__, ".type.TypeResourceIdentifierSchema"),
370+
allow_none=True,
371+
unknown=marshmallow.EXCLUDE,
372+
metadata={"omit_empty": True},
373+
missing=None,
374+
)
375+
fields = FieldContainerField(
376+
allow_none=True,
377+
values=marshmallow.fields.Raw(allow_none=True),
378+
metadata={"omit_empty": True},
379+
missing=None,
380+
)
381+
382+
class Meta:
383+
unknown = marshmallow.EXCLUDE
384+
385+
@marshmallow.post_load
386+
def post_load(self, data, **kwargs):
387+
del data["action"]
388+
return models.ChannelSetAddressCustomTypeAction(**data)
389+
390+
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+
361406
class ChannelSetCustomFieldActionSchema(ChannelUpdateActionSchema):
362407
name = marshmallow.fields.String(allow_none=True, missing=None)
363408
value = marshmallow.fields.Raw(

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ class AddressSchema(helpers.BaseSchema):
180180
missing=None,
181181
data_key="externalId",
182182
)
183+
custom = helpers.LazyNestedField(
184+
nested=helpers.absmod(__name__, ".type.CustomFieldsSchema"),
185+
allow_none=True,
186+
unknown=marshmallow.EXCLUDE,
187+
metadata={"omit_empty": True},
188+
missing=None,
189+
)
183190

184191
class Meta:
185192
unknown = marshmallow.EXCLUDE

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,12 @@ class CustomerUpdateSchema(helpers.BaseSchema):
602602
"removeStore": helpers.absmod(
603603
__name__, ".CustomerRemoveStoreActionSchema"
604604
),
605+
"setAddressCustomType": helpers.absmod(
606+
__name__, ".CustomerSetAddressCustomTypeActionSchema"
607+
),
608+
"setAddressCustomField": helpers.absmod(
609+
__name__, ".CustomerSetAddressCustomFieldActionSchema"
610+
),
605611
"setCompanyName": helpers.absmod(
606612
__name__, ".CustomerSetCompanyNameActionSchema"
607613
),
@@ -880,6 +886,51 @@ def post_load(self, data, **kwargs):
880886
return models.CustomerRemoveStoreAction(**data)
881887

882888

889+
class CustomerSetAddressCustomTypeActionSchema(CustomerUpdateActionSchema):
890+
type = helpers.LazyNestedField(
891+
nested=helpers.absmod(__name__, ".type.TypeResourceIdentifierSchema"),
892+
allow_none=True,
893+
unknown=marshmallow.EXCLUDE,
894+
metadata={"omit_empty": True},
895+
missing=None,
896+
)
897+
fields = FieldContainerField(
898+
allow_none=True,
899+
values=marshmallow.fields.Raw(allow_none=True),
900+
metadata={"omit_empty": True},
901+
missing=None,
902+
)
903+
address_id = marshmallow.fields.String(
904+
allow_none=True, missing=None, data_key="addressId"
905+
)
906+
907+
class Meta:
908+
unknown = marshmallow.EXCLUDE
909+
910+
@marshmallow.post_load
911+
def post_load(self, data, **kwargs):
912+
del data["action"]
913+
return models.CustomerSetAddressCustomTypeAction(**data)
914+
915+
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+
883934
class CustomerSetCompanyNameActionSchema(CustomerUpdateActionSchema):
884935
company_name = marshmallow.fields.String(
885936
allow_none=True,

0 commit comments

Comments
 (0)