Example #1
0
class StateSchema(LoggedResourceSchema):
    "Marshmallow schema for :class:`commercetools.types.State`."
    key = marshmallow.fields.String(allow_none=True)
    type = marshmallow_enum.EnumField(types.StateTypeEnum, by_value=True)
    name = LocalizedStringField(allow_none=True, missing=None)
    description = LocalizedStringField(allow_none=True, missing=None)
    initial = marshmallow.fields.Bool(allow_none=True)
    built_in = marshmallow.fields.Bool(allow_none=True, data_key="builtIn")
    roles = marshmallow.fields.List(marshmallow_enum.EnumField(
        types.StateRoleEnum, by_value=True),
                                    missing=None)
    transitions = marshmallow.fields.Nested(
        nested="commercetools.schemas._state.StateReferenceSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.State(**data)
class ProductDiscountDraftSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.ProductDiscountDraft`."
    name = LocalizedStringField(allow_none=True)
    key = marshmallow.fields.String(allow_none=True, missing=None)
    description = LocalizedStringField(allow_none=True, missing=None)
    value = helpers.Discriminator(
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "absolute":
            "commercetools.schemas._product_discount.ProductDiscountValueAbsoluteDraftSchema",
            "external":
            "commercetools.schemas._product_discount.ProductDiscountValueExternalDraftSchema",
            "relative":
            "commercetools.schemas._product_discount.ProductDiscountValueRelativeDraftSchema",
        },
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )
    predicate = marshmallow.fields.String(allow_none=True)
    sort_order = marshmallow.fields.String(allow_none=True,
                                           data_key="sortOrder")
    is_active = marshmallow.fields.Bool(allow_none=True, data_key="isActive")
    valid_from = marshmallow.fields.DateTime(allow_none=True,
                                             missing=None,
                                             data_key="validFrom")
    valid_until = marshmallow.fields.DateTime(allow_none=True,
                                              missing=None,
                                              data_key="validUntil")

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.ProductDiscountDraft(**data)
class ChannelDraftSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.ChannelDraft`."
    key = marshmallow.fields.String(allow_none=True)
    roles = marshmallow.fields.List(marshmallow_enum.EnumField(
        types.ChannelRoleEnum, by_value=True),
                                    missing=None)
    name = LocalizedStringField(allow_none=True, missing=None)
    description = LocalizedStringField(allow_none=True, missing=None)
    address = marshmallow.fields.Nested(
        nested="commercetools.schemas._common.AddressSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    custom = marshmallow.fields.Nested(
        nested="commercetools.schemas._type.CustomFieldsDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    geo_location = marshmallow.fields.Nested(
        nested="commercetools.schemas._common.GeoJsonPointSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="geoLocation",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.ChannelDraft(**data)
class CartDiscountDraftSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.CartDiscountDraft`."
    name = LocalizedStringField(allow_none=True)
    key = marshmallow.fields.String(allow_none=True, missing=None)
    description = LocalizedStringField(allow_none=True, missing=None)
    value = helpers.Discriminator(
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "absolute": "commercetools.schemas._cart_discount.CartDiscountValueAbsoluteSchema",
            "giftLineItem": "commercetools.schemas._cart_discount.CartDiscountValueGiftLineItemSchema",
            "relative": "commercetools.schemas._cart_discount.CartDiscountValueRelativeSchema",
        },
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )
    cart_predicate = marshmallow.fields.String(
        allow_none=True, data_key="cartPredicate"
    )
    target = helpers.Discriminator(
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "customLineItems": "commercetools.schemas._cart_discount.CartDiscountCustomLineItemsTargetSchema",
            "lineItems": "commercetools.schemas._cart_discount.CartDiscountLineItemsTargetSchema",
            "shipping": "commercetools.schemas._cart_discount.CartDiscountShippingCostTargetSchema",
            "multiBuyCustomLineItems": "commercetools.schemas._cart_discount.MultiBuyCustomLineItemsTargetSchema",
            "multiBuyLineItems": "commercetools.schemas._cart_discount.MultiBuyLineItemsTargetSchema",
        },
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    sort_order = marshmallow.fields.String(allow_none=True, data_key="sortOrder")
    is_active = marshmallow.fields.Bool(
        allow_none=True, missing=None, data_key="isActive"
    )
    valid_from = marshmallow.fields.DateTime(
        allow_none=True, missing=None, data_key="validFrom"
    )
    valid_until = marshmallow.fields.DateTime(
        allow_none=True, missing=None, data_key="validUntil"
    )
    requires_discount_code = marshmallow.fields.Bool(
        allow_none=True, data_key="requiresDiscountCode"
    )
    stacking_mode = marshmallow_enum.EnumField(
        types.StackingMode, by_value=True, missing=None, data_key="stackingMode"
    )
    custom = marshmallow.fields.Nested(
        nested="commercetools.schemas._type.CustomFieldsSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data):
        return types.CartDiscountDraft(**data)
Example #5
0
class AttributeDefinitionSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.AttributeDefinition`."
    type = helpers.Discriminator(
        discriminator_field=("name", "name"),
        discriminator_schemas={
            "boolean":
            "commercetools.schemas._product_type.AttributeBooleanTypeSchema",
            "datetime":
            "commercetools.schemas._product_type.AttributeDateTimeTypeSchema",
            "date":
            "commercetools.schemas._product_type.AttributeDateTypeSchema",
            "enum":
            "commercetools.schemas._product_type.AttributeEnumTypeSchema",
            "ltext":
            "commercetools.schemas._product_type.AttributeLocalizableTextTypeSchema",
            "lenum":
            "commercetools.schemas._product_type.AttributeLocalizedEnumTypeSchema",
            "money":
            "commercetools.schemas._product_type.AttributeMoneyTypeSchema",
            "nested":
            "commercetools.schemas._product_type.AttributeNestedTypeSchema",
            "number":
            "commercetools.schemas._product_type.AttributeNumberTypeSchema",
            "reference":
            "commercetools.schemas._product_type.AttributeReferenceTypeSchema",
            "set":
            "commercetools.schemas._product_type.AttributeSetTypeSchema",
            "text":
            "commercetools.schemas._product_type.AttributeTextTypeSchema",
            "time":
            "commercetools.schemas._product_type.AttributeTimeTypeSchema",
        },
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )
    name = marshmallow.fields.String(allow_none=True)
    label = LocalizedStringField(allow_none=True)
    is_required = marshmallow.fields.Bool(allow_none=True,
                                          data_key="isRequired")
    attribute_constraint = marshmallow_enum.EnumField(
        types.AttributeConstraintEnum,
        by_value=True,
        data_key="attributeConstraint")
    input_tip = LocalizedStringField(allow_none=True,
                                     missing=None,
                                     data_key="inputTip")
    input_hint = marshmallow_enum.EnumField(types.TextInputHint,
                                            by_value=True,
                                            data_key="inputHint")
    is_searchable = marshmallow.fields.Bool(allow_none=True,
                                            data_key="isSearchable")

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.AttributeDefinition(**data)
class DiscountCodeDraftSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.DiscountCodeDraft`."
    name = LocalizedStringField(allow_none=True, missing=None)
    description = LocalizedStringField(allow_none=True, missing=None)
    code = marshmallow.fields.String(allow_none=True)
    cart_discounts = marshmallow.fields.Nested(
        nested="commercetools.schemas._cart_discount.CartDiscountResourceIdentifierSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        data_key="cartDiscounts",
    )
    cart_predicate = marshmallow.fields.String(
        allow_none=True, missing=None, data_key="cartPredicate"
    )
    is_active = marshmallow.fields.Bool(
        allow_none=True, missing=None, data_key="isActive"
    )
    max_applications = marshmallow.fields.Integer(
        allow_none=True, missing=None, data_key="maxApplications"
    )
    max_applications_per_customer = marshmallow.fields.Integer(
        allow_none=True, missing=None, data_key="maxApplicationsPerCustomer"
    )
    custom = marshmallow.fields.Nested(
        nested="commercetools.schemas._type.CustomFieldsDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    groups = marshmallow.fields.List(
        marshmallow.fields.Nested(
            nested="commercetools.schemas.None.stringSchema",
            unknown=marshmallow.EXCLUDE,
            allow_none=True,
        ),
        allow_none=True,
        missing=None,
    )
    valid_from = marshmallow.fields.DateTime(
        allow_none=True, missing=None, data_key="validFrom"
    )
    valid_until = marshmallow.fields.DateTime(
        allow_none=True, missing=None, data_key="validUntil"
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data):
        return types.DiscountCodeDraft(**data)
Example #7
0
class ShoppingListDraftSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.ShoppingListDraft`."
    custom = marshmallow.fields.Nested(
        nested="commercetools.schemas._type.CustomFieldsDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    customer = marshmallow.fields.Nested(
        nested=
        "commercetools.schemas._customer.CustomerResourceIdentifierSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    delete_days_after_last_modification = marshmallow.fields.Integer(
        allow_none=True,
        missing=None,
        data_key="deleteDaysAfterLastModification")
    description = LocalizedStringField(allow_none=True, missing=None)
    key = marshmallow.fields.String(allow_none=True, missing=None)
    line_items = marshmallow.fields.Nested(
        nested=
        "commercetools.schemas._shopping_list.ShoppingListLineItemDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        missing=None,
        data_key="lineItems",
    )
    name = LocalizedStringField(allow_none=True)
    slug = LocalizedStringField(allow_none=True, missing=None)
    text_line_items = marshmallow.fields.Nested(
        nested="commercetools.schemas._shopping_list.TextLineItemDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        missing=None,
        data_key="textLineItems",
    )
    anonymous_id = marshmallow.fields.String(allow_none=True,
                                             missing=None,
                                             data_key="anonymousId")

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.ShoppingListDraft(**data)
class ShippingMethodDraftSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.ShippingMethodDraft`."
    key = marshmallow.fields.String(allow_none=True, missing=None)
    name = marshmallow.fields.String(allow_none=True)
    description = marshmallow.fields.String(allow_none=True, missing=None)
    localized_description = LocalizedStringField(
        allow_none=True, missing=None, data_key="localizedDescription")
    tax_category = marshmallow.fields.Nested(
        nested=
        "commercetools.schemas._tax_category.TaxCategoryResourceIdentifierSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        data_key="taxCategory",
    )
    zone_rates = marshmallow.fields.Nested(
        nested="commercetools.schemas._shipping_method.ZoneRateDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        data_key="zoneRates",
    )
    is_default = marshmallow.fields.Bool(allow_none=True, data_key="isDefault")
    predicate = marshmallow.fields.String(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.ShippingMethodDraft(**data)
class FieldDefinitionSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.FieldDefinition`."
    type = helpers.Discriminator(
        discriminator_field=("name", "name"),
        discriminator_schemas={
            "Boolean": "commercetools.schemas._type.CustomFieldBooleanTypeSchema",
            "DateTime": "commercetools.schemas._type.CustomFieldDateTimeTypeSchema",
            "Date": "commercetools.schemas._type.CustomFieldDateTypeSchema",
            "Enum": "commercetools.schemas._type.CustomFieldEnumTypeSchema",
            "LocalizedEnum": "commercetools.schemas._type.CustomFieldLocalizedEnumTypeSchema",
            "LocalizedString": "commercetools.schemas._type.CustomFieldLocalizedStringTypeSchema",
            "Money": "commercetools.schemas._type.CustomFieldMoneyTypeSchema",
            "Number": "commercetools.schemas._type.CustomFieldNumberTypeSchema",
            "Reference": "commercetools.schemas._type.CustomFieldReferenceTypeSchema",
            "Set": "commercetools.schemas._type.CustomFieldSetTypeSchema",
            "String": "commercetools.schemas._type.CustomFieldStringTypeSchema",
            "Time": "commercetools.schemas._type.CustomFieldTimeTypeSchema",
        },
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )
    name = marshmallow.fields.String(allow_none=True)
    label = LocalizedStringField(allow_none=True)
    required = marshmallow.fields.Bool(allow_none=True)
    input_hint = marshmallow_enum.EnumField(
        types.TypeTextInputHint, by_value=True, missing=None, data_key="inputHint"
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.FieldDefinition(**data)
Example #10
0
class StoreSchema(BaseResourceSchema):
    "Marshmallow schema for :class:`commercetools.types.Store`."
    id = marshmallow.fields.String(allow_none=True)
    version = marshmallow.fields.Integer(allow_none=True)
    created_at = marshmallow.fields.DateTime(allow_none=True,
                                             data_key="createdAt")
    last_modified_at = marshmallow.fields.DateTime(allow_none=True,
                                                   data_key="lastModifiedAt")
    last_modified_by = marshmallow.fields.Nested(
        nested="commercetools.schemas._common.LastModifiedBySchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="lastModifiedBy",
    )
    created_by = marshmallow.fields.Nested(
        nested="commercetools.schemas._common.CreatedBySchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="createdBy",
    )
    key = marshmallow.fields.String(allow_none=True)
    name = LocalizedStringField(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.Store(**data)
class StateSchema(BaseResourceSchema):
    "Marshmallow schema for :class:`commercetools.types.State`."
    id = marshmallow.fields.String(allow_none=True)
    version = marshmallow.fields.Integer(allow_none=True)
    created_at = marshmallow.fields.DateTime(allow_none=True,
                                             data_key="createdAt")
    last_modified_at = marshmallow.fields.DateTime(allow_none=True,
                                                   data_key="lastModifiedAt")
    last_modified_by = marshmallow.fields.Nested(
        nested="commercetools.schemas._common.LastModifiedBySchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="lastModifiedBy",
    )
    created_by = marshmallow.fields.Nested(
        nested="commercetools.schemas._common.CreatedBySchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="createdBy",
    )
    key = marshmallow.fields.String(allow_none=True)
    type = marshmallow_enum.EnumField(types.StateTypeEnum, by_value=True)
    name = LocalizedStringField(allow_none=True, missing=None)
    description = LocalizedStringField(allow_none=True, missing=None)
    initial = marshmallow.fields.Bool(allow_none=True)
    built_in = marshmallow.fields.Bool(allow_none=True, data_key="builtIn")
    roles = marshmallow.fields.List(marshmallow_enum.EnumField(
        types.StateRoleEnum, by_value=True),
                                    missing=None)
    transitions = marshmallow.fields.Nested(
        nested="commercetools.schemas._state.StateReferenceSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.State(**data)
Example #12
0
class TypeSchema(BaseResourceSchema):
    "Marshmallow schema for :class:`commercetools.types.Type`."
    id = marshmallow.fields.String(allow_none=True)
    version = marshmallow.fields.Integer(allow_none=True)
    created_at = marshmallow.fields.DateTime(allow_none=True,
                                             data_key="createdAt")
    last_modified_at = marshmallow.fields.DateTime(allow_none=True,
                                                   data_key="lastModifiedAt")
    last_modified_by = marshmallow.fields.Nested(
        nested="commercetools.schemas._common.LastModifiedBySchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="lastModifiedBy",
    )
    created_by = marshmallow.fields.Nested(
        nested="commercetools.schemas._common.CreatedBySchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="createdBy",
    )
    key = marshmallow.fields.String(allow_none=True)
    name = LocalizedStringField(allow_none=True)
    description = LocalizedStringField(allow_none=True, missing=None)
    resource_type_ids = marshmallow.fields.List(
        marshmallow_enum.EnumField(types.ResourceTypeId, by_value=True),
        data_key="resourceTypeIds",
    )
    field_definitions = marshmallow.fields.Nested(
        nested="commercetools.schemas._type.FieldDefinitionSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        data_key="fieldDefinitions",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.Type(**data)
Example #13
0
class ShoppingListLineItemSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.ShoppingListLineItem`."
    added_at = marshmallow.fields.DateTime(allow_none=True, data_key="addedAt")
    custom = marshmallow.fields.Nested(
        nested="commercetools.schemas._type.CustomFieldsSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    deactivated_at = marshmallow.fields.DateTime(allow_none=True,
                                                 missing=None,
                                                 data_key="deactivatedAt")
    id = marshmallow.fields.String(allow_none=True)
    name = LocalizedStringField(allow_none=True)
    product_id = marshmallow.fields.String(allow_none=True,
                                           data_key="productId")
    product_slug = LocalizedStringField(allow_none=True,
                                        missing=None,
                                        data_key="productSlug")
    product_type = marshmallow.fields.Nested(
        nested="commercetools.schemas._product_type.ProductTypeReferenceSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        data_key="productType",
    )
    quantity = marshmallow.fields.Integer(allow_none=True)
    variant = marshmallow.fields.Nested(
        nested="commercetools.schemas._product.ProductVariantSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    variant_id = marshmallow.fields.Integer(allow_none=True,
                                            missing=None,
                                            data_key="variantId")

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.ShoppingListLineItem(**data)
Example #14
0
class PaymentSetMethodInfoNameActionSchema(PaymentUpdateActionSchema):
    "Marshmallow schema for :class:`commercetools.types.PaymentSetMethodInfoNameAction`."
    name = LocalizedStringField(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.PaymentSetMethodInfoNameAction(**data)
Example #15
0
class ShoppingListSetSlugActionSchema(ShoppingListUpdateActionSchema):
    "Marshmallow schema for :class:`commercetools.types.ShoppingListSetSlugAction`."
    slug = LocalizedStringField(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.ShoppingListSetSlugAction(**data)
class CartDiscountSetDescriptionActionSchema(CartDiscountUpdateActionSchema):
    "Marshmallow schema for :class:`commercetools.types.CartDiscountSetDescriptionAction`."
    description = LocalizedStringField(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data):
        del data["action"]
        return types.CartDiscountSetDescriptionAction(**data)
class StateSetDescriptionActionSchema(StateUpdateActionSchema):
    "Marshmallow schema for :class:`commercetools.types.StateSetDescriptionAction`."
    description = LocalizedStringField(allow_none=True)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.StateSetDescriptionAction(**data)
class CategoryChangeSlugActionSchema(CategoryUpdateActionSchema):
    "Marshmallow schema for :class:`commercetools.types.CategoryChangeSlugAction`."
    slug = LocalizedStringField(allow_none=True)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data):
        del data["action"]
        return types.CategoryChangeSlugAction(**data)
class StoreSchema(BaseResourceSchema):
    "Marshmallow schema for :class:`commercetools.types.Store`."
    key = marshmallow.fields.String(allow_none=True)
    name = LocalizedStringField(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data):
        return types.Store(**data)
class ChannelChangeNameActionSchema(ChannelUpdateActionSchema):
    "Marshmallow schema for :class:`commercetools.types.ChannelChangeNameAction`."
    name = LocalizedStringField(allow_none=True)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.ChannelChangeNameAction(**data)
Example #21
0
class StoreDraftSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.StoreDraft`."
    key = marshmallow.fields.String(allow_none=True)
    name = LocalizedStringField(allow_none=True)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.StoreDraft(**data)
class DiscountCodeSetNameActionSchema(DiscountCodeUpdateActionSchema):
    "Marshmallow schema for :class:`commercetools.types.DiscountCodeSetNameAction`."
    name = LocalizedStringField(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data):
        del data["action"]
        return types.DiscountCodeSetNameAction(**data)
class CustomFieldLocalizedEnumValueSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.CustomFieldLocalizedEnumValue`."
    key = marshmallow.fields.String(allow_none=True)
    label = LocalizedStringField(allow_none=True)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data):
        return types.CustomFieldLocalizedEnumValue(**data)
Example #24
0
class TextLineItemSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.TextLineItem`."
    added_at = marshmallow.fields.DateTime(allow_none=True, data_key="addedAt")
    custom = marshmallow.fields.Nested(
        nested="commercetools.schemas._type.CustomFieldsSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    description = LocalizedStringField(allow_none=True, missing=None)
    id = marshmallow.fields.String(allow_none=True)
    name = LocalizedStringField(allow_none=True)
    quantity = marshmallow.fields.Integer(allow_none=True)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.TextLineItem(**data)
Example #25
0
class TypeChangeLabelActionSchema(TypeUpdateActionSchema):
    "Marshmallow schema for :class:`commercetools.types.TypeChangeLabelAction`."
    field_name = marshmallow.fields.String(allow_none=True, data_key="fieldName")
    label = LocalizedStringField(allow_none=True)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.TypeChangeLabelAction(**data)
class ChannelSchema(LoggedResourceSchema):
    "Marshmallow schema for :class:`commercetools.types.Channel`."
    key = marshmallow.fields.String(allow_none=True)
    roles = marshmallow.fields.List(
        marshmallow_enum.EnumField(types.ChannelRoleEnum, by_value=True))
    name = LocalizedStringField(allow_none=True, missing=None)
    description = LocalizedStringField(allow_none=True, missing=None)
    address = marshmallow.fields.Nested(
        nested="commercetools.schemas._common.AddressSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    review_rating_statistics = marshmallow.fields.Nested(
        nested="commercetools.schemas._review.ReviewRatingStatisticsSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="reviewRatingStatistics",
    )
    custom = marshmallow.fields.Nested(
        nested="commercetools.schemas._type.CustomFieldsSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    geo_location = marshmallow.fields.Nested(
        nested="commercetools.schemas._common.GeoJsonPointSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="geoLocation",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data):
        return types.Channel(**data)
class CategorySetMetaTitleActionSchema(CategoryUpdateActionSchema):
    "Marshmallow schema for :class:`commercetools.types.CategorySetMetaTitleAction`."
    meta_title = LocalizedStringField(
        allow_none=True, missing=None, data_key="metaTitle"
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.CategorySetMetaTitleAction(**data)
Example #28
0
class ShoppingListAddTextLineItemActionSchema(ShoppingListUpdateActionSchema):
    "Marshmallow schema for :class:`commercetools.types.ShoppingListAddTextLineItemAction`."
    name = LocalizedStringField(allow_none=True)
    description = LocalizedStringField(allow_none=True, missing=None)
    quantity = marshmallow.fields.Integer(allow_none=True, missing=None)
    added_at = marshmallow.fields.DateTime(allow_none=True,
                                           missing=None,
                                           data_key="addedAt")
    custom = marshmallow.fields.Nested(
        nested="commercetools.schemas._type.CustomFieldsDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.ShoppingListAddTextLineItemAction(**data)
Example #29
0
class PaymentMethodInfoSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.PaymentMethodInfo`."
    payment_interface = marshmallow.fields.String(allow_none=True,
                                                  missing=None,
                                                  data_key="paymentInterface")
    method = marshmallow.fields.String(allow_none=True, missing=None)
    name = LocalizedStringField(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.PaymentMethodInfo(**data)
Example #30
0
class ShoppingListSetTextLineItemDescriptionActionSchema(
        ShoppingListUpdateActionSchema):
    "Marshmallow schema for :class:`commercetools.types.ShoppingListSetTextLineItemDescriptionAction`."
    text_line_item_id = marshmallow.fields.String(allow_none=True,
                                                  data_key="textLineItemId")
    description = LocalizedStringField(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.ShoppingListSetTextLineItemDescriptionAction(**data)