Skip to content

Commit deeb3a2

Browse files
committed
Update with latest commercetools-api-reference version
See commercetools/commercetools-api-reference@c69daca
1 parent f7d3a27 commit deeb3a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2445
-311
lines changed

src/commercetools/schemas/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from ._discount_code import * # noqa
1313
from ._error import * # noqa
1414
from ._extension import * # noqa
15+
from ._graph_ql import * # noqa
1516
from ._inventory import * # noqa
1617
from ._me import * # noqa
1718
from ._message import * # noqa

src/commercetools/schemas/_cart.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
from commercetools import helpers, types
77
from commercetools.schemas._common import (
8+
BaseResourceSchema,
89
LocalizedStringField,
9-
LoggedResourceSchema,
1010
ReferenceSchema,
1111
ResourceIdentifierSchema,
1212
)
@@ -275,8 +275,28 @@ def post_load(self, data, **kwargs):
275275
return types.CartResourceIdentifier(**data)
276276

277277

278-
class CartSchema(LoggedResourceSchema):
278+
class CartSchema(BaseResourceSchema):
279279
"Marshmallow schema for :class:`commercetools.types.Cart`."
280+
id = marshmallow.fields.String(allow_none=True)
281+
version = marshmallow.fields.Integer(allow_none=True)
282+
created_at = marshmallow.fields.DateTime(allow_none=True, data_key="createdAt")
283+
last_modified_at = marshmallow.fields.DateTime(
284+
allow_none=True, data_key="lastModifiedAt"
285+
)
286+
last_modified_by = marshmallow.fields.Nested(
287+
nested="commercetools.schemas._common.LastModifiedBySchema",
288+
unknown=marshmallow.EXCLUDE,
289+
allow_none=True,
290+
missing=None,
291+
data_key="lastModifiedBy",
292+
)
293+
created_by = marshmallow.fields.Nested(
294+
nested="commercetools.schemas._common.CreatedBySchema",
295+
unknown=marshmallow.EXCLUDE,
296+
allow_none=True,
297+
missing=None,
298+
data_key="createdBy",
299+
)
280300
customer_id = marshmallow.fields.String(
281301
allow_none=True, missing=None, data_key="customerId"
282302
)
@@ -1139,12 +1159,8 @@ class TaxPortionDraftSchema(marshmallow.Schema):
11391159
"Marshmallow schema for :class:`commercetools.types.TaxPortionDraft`."
11401160
name = marshmallow.fields.String(allow_none=True, missing=None)
11411161
rate = marshmallow.fields.Float(allow_none=True)
1142-
amount = helpers.Discriminator(
1143-
discriminator_field=("type", "type"),
1144-
discriminator_schemas={
1145-
"centPrecision": "commercetools.schemas._common.CentPrecisionMoneyDraftSchema",
1146-
"highPrecision": "commercetools.schemas._common.HighPrecisionMoneyDraftSchema",
1147-
},
1162+
amount = marshmallow.fields.Nested(
1163+
nested="commercetools.schemas._common.MoneySchema",
11481164
unknown=marshmallow.EXCLUDE,
11491165
allow_none=True,
11501166
)

src/commercetools/schemas/_cart_discount.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
from commercetools import helpers, types
77
from commercetools.schemas._common import (
8+
BaseResourceSchema,
89
LocalizedStringField,
9-
LoggedResourceSchema,
1010
ReferenceSchema,
1111
ResourceIdentifierSchema,
1212
)
@@ -164,8 +164,28 @@ def post_load(self, data, **kwargs):
164164
return types.CartDiscountResourceIdentifier(**data)
165165

166166

167-
class CartDiscountSchema(LoggedResourceSchema):
167+
class CartDiscountSchema(BaseResourceSchema):
168168
"Marshmallow schema for :class:`commercetools.types.CartDiscount`."
169+
id = marshmallow.fields.String(allow_none=True)
170+
version = marshmallow.fields.Integer(allow_none=True)
171+
created_at = marshmallow.fields.DateTime(allow_none=True, data_key="createdAt")
172+
last_modified_at = marshmallow.fields.DateTime(
173+
allow_none=True, data_key="lastModifiedAt"
174+
)
175+
last_modified_by = marshmallow.fields.Nested(
176+
nested="commercetools.schemas._common.LastModifiedBySchema",
177+
unknown=marshmallow.EXCLUDE,
178+
allow_none=True,
179+
missing=None,
180+
data_key="lastModifiedBy",
181+
)
182+
created_by = marshmallow.fields.Nested(
183+
nested="commercetools.schemas._common.CreatedBySchema",
184+
unknown=marshmallow.EXCLUDE,
185+
allow_none=True,
186+
missing=None,
187+
data_key="createdBy",
188+
)
169189
name = LocalizedStringField(allow_none=True)
170190
key = marshmallow.fields.String(allow_none=True, missing=None)
171191
description = LocalizedStringField(allow_none=True, missing=None)

src/commercetools/schemas/_category.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
from commercetools import helpers, types
66
from commercetools.schemas._common import (
7+
BaseResourceSchema,
78
LocalizedStringField,
8-
LoggedResourceSchema,
99
ReferenceSchema,
1010
ResourceIdentifierSchema,
1111
)
@@ -144,8 +144,28 @@ def post_load(self, data, **kwargs):
144144
return types.CategoryResourceIdentifier(**data)
145145

146146

147-
class CategorySchema(LoggedResourceSchema):
147+
class CategorySchema(BaseResourceSchema):
148148
"Marshmallow schema for :class:`commercetools.types.Category`."
149+
id = marshmallow.fields.String(allow_none=True)
150+
version = marshmallow.fields.Integer(allow_none=True)
151+
created_at = marshmallow.fields.DateTime(allow_none=True, data_key="createdAt")
152+
last_modified_at = marshmallow.fields.DateTime(
153+
allow_none=True, data_key="lastModifiedAt"
154+
)
155+
last_modified_by = marshmallow.fields.Nested(
156+
nested="commercetools.schemas._common.LastModifiedBySchema",
157+
unknown=marshmallow.EXCLUDE,
158+
allow_none=True,
159+
missing=None,
160+
data_key="lastModifiedBy",
161+
)
162+
created_by = marshmallow.fields.Nested(
163+
nested="commercetools.schemas._common.CreatedBySchema",
164+
unknown=marshmallow.EXCLUDE,
165+
allow_none=True,
166+
missing=None,
167+
data_key="createdBy",
168+
)
149169
name = LocalizedStringField(allow_none=True)
150170
slug = LocalizedStringField(allow_none=True)
151171
description = LocalizedStringField(allow_none=True, missing=None)

src/commercetools/schemas/_channel.py

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
from commercetools import helpers, types
77
from commercetools.schemas._common import (
8+
BaseResourceSchema,
89
LocalizedStringField,
9-
LoggedResourceSchema,
1010
ReferenceSchema,
1111
ResourceIdentifierSchema,
1212
)
@@ -53,8 +53,11 @@ class ChannelDraftSchema(marshmallow.Schema):
5353
allow_none=True,
5454
missing=None,
5555
)
56-
geo_location = marshmallow.fields.Nested(
57-
nested="commercetools.schemas._common.GeoJsonPointSchema",
56+
geo_location = helpers.Discriminator(
57+
discriminator_field=("type", "type"),
58+
discriminator_schemas={
59+
"Point": "commercetools.schemas._common.GeoJsonPointSchema"
60+
},
5861
unknown=marshmallow.EXCLUDE,
5962
allow_none=True,
6063
missing=None,
@@ -120,8 +123,28 @@ def post_load(self, data, **kwargs):
120123
return types.ChannelResourceIdentifier(**data)
121124

122125

123-
class ChannelSchema(LoggedResourceSchema):
126+
class ChannelSchema(BaseResourceSchema):
124127
"Marshmallow schema for :class:`commercetools.types.Channel`."
128+
id = marshmallow.fields.String(allow_none=True)
129+
version = marshmallow.fields.Integer(allow_none=True)
130+
created_at = marshmallow.fields.DateTime(allow_none=True, data_key="createdAt")
131+
last_modified_at = marshmallow.fields.DateTime(
132+
allow_none=True, data_key="lastModifiedAt"
133+
)
134+
last_modified_by = marshmallow.fields.Nested(
135+
nested="commercetools.schemas._common.LastModifiedBySchema",
136+
unknown=marshmallow.EXCLUDE,
137+
allow_none=True,
138+
missing=None,
139+
data_key="lastModifiedBy",
140+
)
141+
created_by = marshmallow.fields.Nested(
142+
nested="commercetools.schemas._common.CreatedBySchema",
143+
unknown=marshmallow.EXCLUDE,
144+
allow_none=True,
145+
missing=None,
146+
data_key="createdBy",
147+
)
125148
key = marshmallow.fields.String(allow_none=True)
126149
roles = marshmallow.fields.List(
127150
marshmallow_enum.EnumField(types.ChannelRoleEnum, by_value=True)
@@ -147,8 +170,11 @@ class ChannelSchema(LoggedResourceSchema):
147170
allow_none=True,
148171
missing=None,
149172
)
150-
geo_location = marshmallow.fields.Nested(
151-
nested="commercetools.schemas._common.GeoJsonPointSchema",
173+
geo_location = helpers.Discriminator(
174+
discriminator_field=("type", "type"),
175+
discriminator_schemas={
176+
"Point": "commercetools.schemas._common.GeoJsonPointSchema"
177+
},
152178
unknown=marshmallow.EXCLUDE,
153179
allow_none=True,
154180
missing=None,
@@ -330,8 +356,11 @@ def post_load(self, data, **kwargs):
330356

331357
class ChannelSetGeoLocationActionSchema(ChannelUpdateActionSchema):
332358
"Marshmallow schema for :class:`commercetools.types.ChannelSetGeoLocationAction`."
333-
geo_location = marshmallow.fields.Nested(
334-
nested="commercetools.schemas._common.GeoJsonPointSchema",
359+
geo_location = helpers.Discriminator(
360+
discriminator_field=("type", "type"),
361+
discriminator_schemas={
362+
"Point": "commercetools.schemas._common.GeoJsonPointSchema"
363+
},
335364
unknown=marshmallow.EXCLUDE,
336365
allow_none=True,
337366
missing=None,

src/commercetools/schemas/_common.py

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
"ImageSchema",
2626
"KeyReferenceSchema",
2727
"LastModifiedBySchema",
28-
"LoggedResourceSchema",
2928
"MoneySchema",
3029
"PagedQueryResponseSchema",
3130
"PriceDraftSchema",
3231
"PriceSchema",
3332
"PriceTierDraftSchema",
3433
"PriceTierSchema",
34+
"QueryPriceSchema",
3535
"ReferenceSchema",
3636
"ResourceIdentifierSchema",
3737
"ScopedPriceSchema",
@@ -516,6 +516,62 @@ def post_load(self, data, **kwargs):
516516
return types.PriceTier(**data)
517517

518518

519+
class QueryPriceSchema(marshmallow.Schema):
520+
"Marshmallow schema for :class:`commercetools.types.QueryPrice`."
521+
id = marshmallow.fields.String(allow_none=True)
522+
value = marshmallow.fields.Nested(
523+
nested="commercetools.schemas._common.MoneySchema",
524+
unknown=marshmallow.EXCLUDE,
525+
allow_none=True,
526+
)
527+
country = marshmallow.fields.String(missing=None)
528+
customer_group = marshmallow.fields.Nested(
529+
nested="commercetools.schemas._customer_group.CustomerGroupReferenceSchema",
530+
unknown=marshmallow.EXCLUDE,
531+
allow_none=True,
532+
missing=None,
533+
data_key="customerGroup",
534+
)
535+
channel = marshmallow.fields.Nested(
536+
nested="commercetools.schemas._channel.ChannelReferenceSchema",
537+
unknown=marshmallow.EXCLUDE,
538+
allow_none=True,
539+
missing=None,
540+
)
541+
valid_from = marshmallow.fields.DateTime(
542+
allow_none=True, missing=None, data_key="validFrom"
543+
)
544+
valid_until = marshmallow.fields.DateTime(
545+
allow_none=True, missing=None, data_key="validUntil"
546+
)
547+
discounted = marshmallow.fields.Nested(
548+
nested="commercetools.schemas._common.DiscountedPriceSchema",
549+
unknown=marshmallow.EXCLUDE,
550+
allow_none=True,
551+
missing=None,
552+
)
553+
custom = marshmallow.fields.Nested(
554+
nested="commercetools.schemas._type.CustomFieldsSchema",
555+
unknown=marshmallow.EXCLUDE,
556+
allow_none=True,
557+
missing=None,
558+
)
559+
tiers = marshmallow.fields.Nested(
560+
nested="commercetools.schemas._common.PriceTierDraftSchema",
561+
unknown=marshmallow.EXCLUDE,
562+
allow_none=True,
563+
many=True,
564+
missing=None,
565+
)
566+
567+
class Meta:
568+
unknown = marshmallow.EXCLUDE
569+
570+
@marshmallow.post_load
571+
def post_load(self, data, **kwargs):
572+
return types.QueryPrice(**data)
573+
574+
519575
class ReferenceSchema(marshmallow.Schema):
520576
"Marshmallow schema for :class:`commercetools.types.Reference`."
521577
type_id = marshmallow_enum.EnumField(
@@ -731,31 +787,6 @@ def post_load(self, data, **kwargs):
731787
return types.LastModifiedBy(**data)
732788

733789

734-
class LoggedResourceSchema(BaseResourceSchema):
735-
"Marshmallow schema for :class:`commercetools.types.LoggedResource`."
736-
last_modified_by = marshmallow.fields.Nested(
737-
nested="commercetools.schemas._common.LastModifiedBySchema",
738-
unknown=marshmallow.EXCLUDE,
739-
allow_none=True,
740-
missing=None,
741-
data_key="lastModifiedBy",
742-
)
743-
created_by = marshmallow.fields.Nested(
744-
nested="commercetools.schemas._common.CreatedBySchema",
745-
unknown=marshmallow.EXCLUDE,
746-
allow_none=True,
747-
missing=None,
748-
data_key="createdBy",
749-
)
750-
751-
class Meta:
752-
unknown = marshmallow.EXCLUDE
753-
754-
@marshmallow.post_load
755-
def post_load(self, data, **kwargs):
756-
return types.LoggedResource(**data)
757-
758-
759790
class TypedMoneyDraftSchema(MoneySchema):
760791
"Marshmallow schema for :class:`commercetools.types.TypedMoneyDraft`."
761792
type = marshmallow_enum.EnumField(types.MoneyType, by_value=True)

src/commercetools/schemas/_custom_object.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import marshmallow
44

55
from commercetools import types
6-
from commercetools.schemas._common import LoggedResourceSchema, ReferenceSchema
6+
from commercetools.schemas._common import BaseResourceSchema, ReferenceSchema
77

88
__all__ = [
99
"CustomObjectDraftSchema",
@@ -67,8 +67,28 @@ def post_load(self, data, **kwargs):
6767
return types.CustomObjectReference(**data)
6868

6969

70-
class CustomObjectSchema(LoggedResourceSchema):
70+
class CustomObjectSchema(BaseResourceSchema):
7171
"Marshmallow schema for :class:`commercetools.types.CustomObject`."
72+
id = marshmallow.fields.String(allow_none=True)
73+
version = marshmallow.fields.Integer(allow_none=True)
74+
created_at = marshmallow.fields.DateTime(allow_none=True, data_key="createdAt")
75+
last_modified_at = marshmallow.fields.DateTime(
76+
allow_none=True, data_key="lastModifiedAt"
77+
)
78+
last_modified_by = marshmallow.fields.Nested(
79+
nested="commercetools.schemas._common.LastModifiedBySchema",
80+
unknown=marshmallow.EXCLUDE,
81+
allow_none=True,
82+
missing=None,
83+
data_key="lastModifiedBy",
84+
)
85+
created_by = marshmallow.fields.Nested(
86+
nested="commercetools.schemas._common.CreatedBySchema",
87+
unknown=marshmallow.EXCLUDE,
88+
allow_none=True,
89+
missing=None,
90+
data_key="createdBy",
91+
)
7292
container = marshmallow.fields.String(allow_none=True)
7393
key = marshmallow.fields.String(allow_none=True)
7494
value = marshmallow.fields.Raw(allow_none=True)

0 commit comments

Comments
 (0)