class SimilarProductPairSchema(helpers.BaseSchema):
    confidence = marshmallow.fields.Float(allow_none=True, missing=None)
    products = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".SimilarProductSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):

        return models.SimilarProductPair(**data)
class TypeChangeLocalizedEnumValueLabelActionSchema(TypeUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.TypeChangeLocalizedEnumValueLabelAction`."""

    field_name = marshmallow.fields.String(allow_none=True, data_key="fieldName")
    value = helpers.LazyNestedField(
        nested="commercetools._schemas._type.CustomFieldLocalizedEnumValueSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.TypeChangeLocalizedEnumValueLabelAction(**data)
Exemple #3
0
class ProductDiscountValueAbsoluteDraftSchema(ProductDiscountValueDraftSchema):
    """Marshmallow schema for :class:`commercetools.types.ProductDiscountValueAbsoluteDraft`."""

    money = helpers.LazyNestedField(
        nested="commercetools._schemas._common.MoneySchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["type"]
        return types.ProductDiscountValueAbsoluteDraft(**data)
class ReviewReferenceSchema(ReferenceSchema):
    """Marshmallow schema for :class:`commercetools.types.ReviewReference`."""

    obj = helpers.LazyNestedField(
        nested="commercetools._schemas._review.ReviewSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["type_id"]
        return types.ReviewReference(**data)
class TypeAddFieldDefinitionActionSchema(TypeUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.TypeAddFieldDefinitionAction`."""

    field_definition = helpers.LazyNestedField(
        nested="commercetools._schemas._type.FieldDefinitionSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        data_key="fieldDefinition",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.TypeAddFieldDefinitionAction(**data)
Exemple #6
0
class DuplicateVariantValuesErrorSchema(ErrorObjectSchema):
    """Marshmallow schema for :class:`commercetools.types.DuplicateVariantValuesError`."""

    variant_values = helpers.LazyNestedField(
        nested="commercetools._schemas._error.VariantValuesSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        data_key="variantValues",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["code"]
        return types.DuplicateVariantValuesError(**data)
class ImageSchema(marshmallow.Schema):
    """Marshmallow schema for :class:`commercetools.types.Image`."""

    url = marshmallow.fields.String(allow_none=True)
    dimensions = helpers.LazyNestedField(
        nested="commercetools._schemas._common.ImageDimensionsSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )
    label = marshmallow.fields.String(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.Image(**data)
Exemple #8
0
class PaymentSetAmountRefundedActionSchema(PaymentUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.PaymentSetAmountRefundedAction`."""

    amount = helpers.LazyNestedField(
        nested="commercetools._schemas._common.MoneySchema",
        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.PaymentSetAmountRefundedAction(**data)
Exemple #9
0
class ReviewSetCustomerActionSchema(ReviewUpdateActionSchema):
    customer = helpers.LazyNestedField(
        nested=helpers.absmod(__name__,
                              ".customer.CustomerResourceIdentifierSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return models.ReviewSetCustomerAction(**data)
Exemple #10
0
class ProjectSetExternalOAuthActionSchema(ProjectUpdateActionSchema):
    external_o_auth = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".ExternalOAuthSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="externalOAuth",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return models.ProjectSetExternalOAuthAction(**data)
Exemple #11
0
class PaymentAddInterfaceInteractionActionSchema(PaymentUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.PaymentAddInterfaceInteractionAction`."""

    type = helpers.LazyNestedField(
        nested="commercetools._schemas._type.TypeResourceIdentifierSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )
    fields = FieldContainerField(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.PaymentAddInterfaceInteractionAction(**data)
class ExtensionChangeTriggersActionSchema(ExtensionUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.ExtensionChangeTriggersAction`."""

    triggers = helpers.LazyNestedField(
        nested="commercetools._schemas._extension.ExtensionTriggerSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.ExtensionChangeTriggersAction(**data)
Exemple #13
0
class CategoryChangeParentActionSchema(CategoryUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.CategoryChangeParentAction`."""

    parent = helpers.LazyNestedField(
        nested=
        "commercetools._schemas._category.CategoryResourceIdentifierSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.CategoryChangeParentAction(**data)
Exemple #14
0
class CategoryAddAssetActionSchema(CategoryUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.CategoryAddAssetAction`."""

    asset = helpers.LazyNestedField(
        nested="commercetools._schemas._common.AssetDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )
    position = marshmallow.fields.Integer(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.CategoryAddAssetAction(**data)
class ReviewTransitionStateActionSchema(ReviewUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.ReviewTransitionStateAction`."""

    state = helpers.LazyNestedField(
        nested="commercetools._schemas._state.StateResourceIdentifierSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )
    force = marshmallow.fields.Bool(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.ReviewTransitionStateAction(**data)
class ChannelSetAddressActionSchema(ChannelUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.ChannelSetAddressAction`."""

    address = helpers.LazyNestedField(
        nested="commercetools._schemas._common.AddressSchema",
        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.ChannelSetAddressAction(**data)
Exemple #17
0
class DuplicateAttributeValuesErrorSchema(ErrorObjectSchema):
    """Marshmallow schema for :class:`commercetools.types.DuplicateAttributeValuesError`."""

    attributes = helpers.LazyNestedField(
        nested="commercetools._schemas._product.AttributeSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["code"]
        return types.DuplicateAttributeValuesError(**data)
Exemple #18
0
class CustomFieldLocalizedEnumTypeSchema(FieldTypeSchema):
    values = helpers.LazyNestedField(
        nested=helpers.absmod(__name__,
                              ".CustomFieldLocalizedEnumValueSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["name"]
        return models.CustomFieldLocalizedEnumType(**data)
class TaxCategoryAddTaxRateActionSchema(TaxCategoryUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.TaxCategoryAddTaxRateAction`."""

    tax_rate = helpers.LazyNestedField(
        nested="commercetools._schemas._tax_category.TaxRateDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        data_key="taxRate",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.TaxCategoryAddTaxRateAction(**data)
class CustomFieldLocalizedEnumTypeSchema(FieldTypeSchema):
    """Marshmallow schema for :class:`commercetools.types.CustomFieldLocalizedEnumType`."""

    values = helpers.LazyNestedField(
        nested="commercetools._schemas._type.CustomFieldLocalizedEnumValueSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["name"]
        return types.CustomFieldLocalizedEnumType(**data)
class PriceTierDraftSchema(marshmallow.Schema):
    """Marshmallow schema for :class:`commercetools.types.PriceTierDraft`."""

    minimum_quantity = marshmallow.fields.Integer(allow_none=True,
                                                  data_key="minimumQuantity")
    value = helpers.LazyNestedField(
        nested="commercetools._schemas._common.MoneySchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.PriceTierDraft(**data)
class ReviewSetCustomerActionSchema(ReviewUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.ReviewSetCustomerAction`."""

    customer = helpers.LazyNestedField(
        nested="commercetools._schemas._customer.CustomerResourceIdentifierSchema",
        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.ReviewSetCustomerAction(**data)
Exemple #23
0
class StateSetTransitionsActionSchema(StateUpdateActionSchema):
    transitions = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".StateResourceIdentifierSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return models.StateSetTransitionsAction(**data)
Exemple #24
0
class CustomerSigninSchema(helpers.BaseSchema):
    email = marshmallow.fields.String(allow_none=True, missing=None)
    password = marshmallow.fields.String(allow_none=True, missing=None)
    anonymous_cart_id = marshmallow.fields.String(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="anonymousCartId",
    )
    anonymous_cart = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".cart.CartResourceIdentifierSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="anonymousCart",
    )
    anonymous_cart_sign_in_mode = marshmallow_enum.EnumField(
        AnonymousCartSignInMode,
        by_value=True,
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="anonymousCartSignInMode",
    )
    anonymous_id = marshmallow.fields.String(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="anonymousId",
    )
    update_product_data = marshmallow.fields.Boolean(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="updateProductData",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):

        return models.CustomerSignin(**data)
Exemple #25
0
class ProjectSetExternalOAuthActionSchema(ProjectUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.ProjectSetExternalOAuthAction`."""

    external_oauth = helpers.LazyNestedField(
        nested="commercetools._schemas._project.ExternalOAuthSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="externalOAuth",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.ProjectSetExternalOAuthAction(**data)
Exemple #26
0
class PriceTierDraftSchema(helpers.BaseSchema):
    minimum_quantity = marshmallow.fields.Integer(
        allow_none=True, missing=None, data_key="minimumQuantity"
    )
    value = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".MoneySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):

        return models.PriceTierDraft(**data)
Exemple #27
0
class SubscriptionSetMessagesActionSchema(SubscriptionUpdateActionSchema):
    """Marshmallow schema for :class:`commercetools.types.SubscriptionSetMessagesAction`."""

    messages = helpers.LazyNestedField(
        nested="commercetools._schemas._subscription.MessageSubscriptionSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.SubscriptionSetMessagesAction(**data)
class StoreSetSupplyChannelsActionSchema(StoreUpdateActionSchema):
    supply_channels = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".channel.ChannelResourceIdentifierSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="supplyChannels",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return models.StoreSetSupplyChannelsAction(**data)
Exemple #29
0
class ProductTypeAddPlainEnumValueActionSchema(ProductTypeUpdateActionSchema):
    attribute_name = marshmallow.fields.String(allow_none=True,
                                               missing=None,
                                               data_key="attributeName")
    value = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".AttributePlainEnumValueSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return models.ProductTypeAddPlainEnumValueAction(**data)
class ShippingMethodChangeTaxCategoryActionSchema(
        ShippingMethodUpdateActionSchema):
    tax_category = helpers.LazyNestedField(
        nested=helpers.absmod(
            __name__, ".tax_category.TaxCategoryResourceIdentifierSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
        data_key="taxCategory",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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