Exemple #1
0
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 StateDraftSchema(marshmallow.Schema):
    """Marshmallow schema for :class:`commercetools.types.StateDraft`."""

    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, missing=None)
    roles = marshmallow.fields.List(marshmallow_enum.EnumField(
        types.StateRoleEnum, by_value=True),
                                    missing=None)
    transitions = helpers.LazyNestedField(
        nested="commercetools._schemas._state.StateResourceIdentifierSchema",
        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.StateDraft(**data)
class TypeDraftSchema(marshmallow.Schema):
    """Marshmallow schema for :class:`commercetools.types.TypeDraft`."""

    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 = helpers.LazyNestedField(
        nested="commercetools._schemas._type.FieldDefinitionSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        missing=None,
        data_key="fieldDefinitions",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.TypeDraft(**data)
Exemple #4
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 = helpers.LazyNestedField(
        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 = helpers.LazyNestedField(
        nested="commercetools._schemas._type.CustomFieldsDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    groups = marshmallow.fields.List(
        helpers.LazyNestedField(
            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, **kwargs):
        return types.DiscountCodeDraft(**data)
class ShoppingListDraftSchema(marshmallow.Schema):
    """Marshmallow schema for :class:`commercetools.types.ShoppingListDraft`."""

    custom = helpers.LazyNestedField(
        nested="commercetools._schemas._type.CustomFieldsDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    customer = helpers.LazyNestedField(
        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 = helpers.LazyNestedField(
        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 = helpers.LazyNestedField(
        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 StoreDraftSchema(marshmallow.Schema):
    """Marshmallow schema for :class:`commercetools.types.StoreDraft`."""

    key = marshmallow.fields.String(allow_none=True)
    name = LocalizedStringField(allow_none=True)
    languages = marshmallow.fields.List(
        marshmallow.fields.String(allow_none=True), missing=None
    )
    distribution_channels = helpers.LazyNestedField(
        nested="commercetools._schemas._channel.ChannelResourceIdentifierSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        missing=None,
        data_key="distributionChannels",
    )
    supply_channels = helpers.LazyNestedField(
        nested="commercetools._schemas._channel.ChannelResourceIdentifierSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        missing=None,
        data_key="supplyChannels",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.StoreDraft(**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)
Exemple #9
0
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 = helpers.LazyNestedField(
        nested=
        "commercetools._schemas._tax_category.TaxCategoryResourceIdentifierSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        data_key="taxCategory",
    )
    zone_rates = helpers.LazyNestedField(
        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 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 = helpers.LazyNestedField(
        nested="commercetools._schemas._common.LastModifiedBySchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="lastModifiedBy",
    )
    created_by = helpers.LazyNestedField(
        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 = helpers.LazyNestedField(
        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 ShoppingListLineItemSchema(marshmallow.Schema):
    """Marshmallow schema for :class:`commercetools.types.ShoppingListLineItem`."""

    added_at = marshmallow.fields.DateTime(allow_none=True, data_key="addedAt")
    custom = helpers.LazyNestedField(
        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 = helpers.LazyNestedField(
        nested=
        "commercetools._schemas._product_type.ProductTypeReferenceSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        data_key="productType",
    )
    quantity = marshmallow.fields.Integer(allow_none=True)
    variant = helpers.LazyNestedField(
        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)
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 = helpers.LazyNestedField(
        nested="commercetools._schemas._common.LastModifiedBySchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="lastModifiedBy",
    )
    created_by = helpers.LazyNestedField(
        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 = helpers.LazyNestedField(
        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)
class TextLineItemSchema(marshmallow.Schema):
    """Marshmallow schema for :class:`commercetools.types.TextLineItem`."""

    added_at = marshmallow.fields.DateTime(allow_none=True, data_key="addedAt")
    custom = helpers.LazyNestedField(
        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)
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 TypeSetDescriptionActionSchema(TypeUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.TypeSetDescriptionAction`."""

    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.TypeSetDescriptionAction(**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, **kwargs):
        return types.CustomFieldLocalizedEnumValue(**data)
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)
Exemple #18
0
class CartDiscountChangeNameActionSchema(CartDiscountUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.CartDiscountChangeNameAction`."""

    name = LocalizedStringField(allow_none=True)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.CartDiscountChangeNameAction(**data)
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)
Exemple #20
0
class ShippingMethodSchema(BaseResourceSchema):
    """Marshmallow schema for :class:`commercetools.types.ShippingMethod`."""

    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 = helpers.LazyNestedField(
        nested="commercetools._schemas._common.LastModifiedBySchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="lastModifiedBy",
    )
    created_by = helpers.LazyNestedField(
        nested="commercetools._schemas._common.CreatedBySchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="createdBy",
    )
    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 = helpers.LazyNestedField(
        nested=
        "commercetools._schemas._tax_category.TaxCategoryReferenceSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        data_key="taxCategory",
    )
    zone_rates = helpers.LazyNestedField(
        nested="commercetools._schemas._shipping_method.ZoneRateSchema",
        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.ShippingMethod(**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 = helpers.LazyNestedField(
        nested="commercetools._schemas._common.AddressSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    custom = helpers.LazyNestedField(
        nested="commercetools._schemas._type.CustomFieldsDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    geo_location = helpers.Discriminator(
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "Point": "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)
Exemple #22
0
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)
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 = helpers.LazyNestedField(
        nested="commercetools._schemas._common.LastModifiedBySchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="lastModifiedBy",
    )
    created_by = helpers.LazyNestedField(
        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)
    languages = marshmallow.fields.List(
        marshmallow.fields.String(allow_none=True), missing=None
    )
    distribution_channels = helpers.LazyNestedField(
        nested="commercetools._schemas._channel.ChannelReferenceSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        data_key="distributionChannels",
    )
    supply_channels = helpers.LazyNestedField(
        nested="commercetools._schemas._channel.ChannelResourceIdentifierSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        missing=None,
        data_key="supplyChannels",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.Store(**data)
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 = helpers.LazyNestedField(
        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)
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)
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)
Exemple #27
0
class ProductTypeSetInputTipActionSchema(ProductTypeUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.ProductTypeSetInputTipAction`."""

    attribute_name = marshmallow.fields.String(allow_none=True,
                                               data_key="attributeName")
    input_tip = LocalizedStringField(allow_none=True,
                                     missing=None,
                                     data_key="inputTip")

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.ProductTypeSetInputTipAction(**data)
Exemple #28
0
class CategorySetAssetDescriptionActionSchema(CategoryUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.CategorySetAssetDescriptionAction`."""

    asset_id = marshmallow.fields.String(allow_none=True,
                                         missing=None,
                                         data_key="assetId")
    asset_key = marshmallow.fields.String(allow_none=True,
                                          missing=None,
                                          data_key="assetKey")
    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.CategorySetAssetDescriptionAction(**data)
Exemple #29
0
class CategoryDraftSchema(marshmallow.Schema):
    """Marshmallow schema for :class:`commercetools.types.CategoryDraft`."""

    name = LocalizedStringField(allow_none=True)
    slug = LocalizedStringField(allow_none=True)
    description = LocalizedStringField(allow_none=True, missing=None)
    parent = helpers.LazyNestedField(
        nested=
        "commercetools._schemas._category.CategoryResourceIdentifierSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    order_hint = marshmallow.fields.String(allow_none=True,
                                           missing=None,
                                           data_key="orderHint")
    external_id = marshmallow.fields.String(allow_none=True,
                                            missing=None,
                                            data_key="externalId")
    meta_title = LocalizedStringField(allow_none=True,
                                      missing=None,
                                      data_key="metaTitle")
    meta_description = LocalizedStringField(allow_none=True,
                                            missing=None,
                                            data_key="metaDescription")
    meta_keywords = LocalizedStringField(allow_none=True,
                                         missing=None,
                                         data_key="metaKeywords")
    custom = helpers.LazyNestedField(
        nested="commercetools._schemas._type.CustomFieldsDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    assets = helpers.LazyNestedField(
        nested="commercetools._schemas._common.AssetDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        missing=None,
    )
    key = marshmallow.fields.String(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.CategoryDraft(**data)
class ExtensionUpdateActionsFailedErrorSchema(ErrorObjectSchema):
    """Marshmallow schema for :class:`commercetools.types.ExtensionUpdateActionsFailedError`."""

    localized_message = LocalizedStringField(allow_none=True,
                                             missing=None,
                                             data_key="localizedMessage")
    extension_extra_info = marshmallow.fields.Dict(
        allow_none=True, missing=None, data_key="extensionExtraInfo")
    error_by_extension = helpers.LazyNestedField(
        nested="commercetools._schemas._error.ErrorByExtensionSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        data_key="errorByExtension",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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