Exemple #1
0
class CartDiscountChangeTargetActionSchema(CartDiscountUpdateActionSchema):
    target = helpers.Discriminator(
        allow_none=True,
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "customLineItems": helpers.absmod(
                __name__, ".CartDiscountCustomLineItemsTargetSchema"
            ),
            "lineItems": helpers.absmod(__name__, ".CartDiscountLineItemsTargetSchema"),
            "shipping": helpers.absmod(
                __name__, ".CartDiscountShippingCostTargetSchema"
            ),
            "multiBuyCustomLineItems": helpers.absmod(
                __name__, ".MultiBuyCustomLineItemsTargetSchema"
            ),
            "multiBuyLineItems": helpers.absmod(
                __name__, ".MultiBuyLineItemsTargetSchema"
            ),
        },
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return models.CartDiscountChangeTargetAction(**data)
Exemple #2
0
class VariantValuesSchema(helpers.BaseSchema):
    sku = marshmallow.fields.String(
        allow_none=True, metadata={"omit_empty": True}, missing=None
    )
    prices = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.PriceDraftSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )
    attributes = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".product.AttributeSchema"),
        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.VariantValues(**data)
Exemple #3
0
class MissingAttributesMetaSchema(helpers.BaseSchema):
    product_level = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".MissingAttributesDetailsSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
        data_key="productLevel",
    )
    variant_level = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".MissingAttributesDetailsSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
        data_key="variantLevel",
    )
    product_type_ids = marshmallow.fields.List(
        marshmallow.fields.String(allow_none=True),
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="productTypeIds",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.MissingAttributesMeta(**data)
Exemple #4
0
class MissingAttributesPagedQueryResultSchema(helpers.BaseSchema):
    count = marshmallow.fields.Integer(allow_none=True, missing=None)
    total = marshmallow.fields.Integer(allow_none=True, missing=None)
    offset = marshmallow.fields.Integer(allow_none=True, missing=None)
    results = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".MissingAttributesSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )
    meta = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".MissingAttributesMetaSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.MissingAttributesPagedQueryResult(**data)
Exemple #5
0
class TaxedPriceSchema(helpers.BaseSchema):
    total_net = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.MoneySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
        data_key="totalNet",
    )
    total_gross = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.MoneySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
        data_key="totalGross",
    )
    tax_portions = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".TaxPortionSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
        data_key="taxPortions",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.TaxedPrice(**data)
Exemple #6
0
class CartDiscountValueGiftLineItemDraftSchema(CartDiscountValueDraftSchema):
    product = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".product.ProductResourceIdentifierSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )
    variant_id = marshmallow.fields.Integer(
        allow_none=True, missing=None, data_key="variantId"
    )
    supply_channel = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".channel.ChannelResourceIdentifierSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="supplyChannel",
    )
    distribution_channel = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".channel.ChannelResourceIdentifierSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="distributionChannel",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["type"]
        return models.CartDiscountValueGiftLineItemDraft(**data)
class CartScoreTierSchema(ShippingRatePriceTierSchema):
    score = marshmallow.fields.Float(allow_none=True, missing=None)
    price = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.MoneySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
    )
    price_function = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".PriceFunctionSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="priceFunction",
    )
    is_matching = marshmallow.fields.Boolean(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="isMatching",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["type"]
        return models.CartScoreTier(**data)
Exemple #8
0
class DeliverySchema(helpers.BaseSchema):
    id = marshmallow.fields.String(allow_none=True, missing=None)
    created_at = marshmallow.fields.DateTime(allow_none=True,
                                             missing=None,
                                             data_key="createdAt")
    items = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".DeliveryItemSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )
    parcels = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".ParcelSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )
    address = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.AddressSchema"),
        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):

        return models.Delivery(**data)
Exemple #9
0
class AssetSchema(helpers.BaseSchema):
    key = marshmallow.fields.String(allow_none=True, missing=None)
    sources = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".AssetSourceSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )
    name = LocalizedStringField(allow_none=True, missing=None)
    description = LocalizedStringField(allow_none=True,
                                       metadata={"omit_empty": True},
                                       missing=None)
    tags = marshmallow.fields.List(
        marshmallow.fields.String(allow_none=True),
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
    )
    custom = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".customfields.CustomSchema"),
        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):

        return models.Asset(**data)
Exemple #10
0
class DiscountedPriceSchema(helpers.BaseSchema):
    value = helpers.Discriminator(
        allow_none=True,
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "highPrecision": helpers.absmod(__name__,
                                            ".HighPrecisionMoneySchema"),
            "centPrecision": helpers.absmod(__name__, ".MoneySchema"),
        },
        missing=None,
    )
    discount = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".ProductDiscountKeyReferenceSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.DiscountedPrice(**data)
Exemple #11
0
class CustomerGroupUpdateSchema(helpers.BaseSchema):
    version = marshmallow.fields.Integer(allow_none=True, missing=None)
    actions = marshmallow.fields.List(
        helpers.Discriminator(
            allow_none=True,
            discriminator_field=("action", "action"),
            discriminator_schemas={
                "changeName": helpers.absmod(
                    __name__, ".CustomerGroupChangeNameActionSchema"
                ),
                "setCustomField": helpers.absmod(
                    __name__, ".CustomerGroupSetCustomFieldActionSchema"
                ),
                "setCustomType": helpers.absmod(
                    __name__, ".CustomerGroupSetCustomTypeActionSchema"
                ),
                "setKey": helpers.absmod(__name__, ".CustomerGroupSetKeyActionSchema"),
            },
        ),
        allow_none=True,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.CustomerGroupUpdate(**data)
class ZoneUpdateSchema(helpers.BaseSchema):
    version = marshmallow.fields.Integer(allow_none=True, missing=None)
    actions = marshmallow.fields.List(
        helpers.Discriminator(
            allow_none=True,
            discriminator_field=("action", "action"),
            discriminator_schemas={
                "addLocation":
                helpers.absmod(__name__, ".ZoneAddLocationActionSchema"),
                "changeName":
                helpers.absmod(__name__, ".ZoneChangeNameActionSchema"),
                "removeLocation":
                helpers.absmod(__name__, ".ZoneRemoveLocationActionSchema"),
                "setDescription":
                helpers.absmod(__name__, ".ZoneSetDescriptionActionSchema"),
                "setKey":
                helpers.absmod(__name__, ".ZoneSetKeyActionSchema"),
            },
        ),
        allow_none=True,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.ZoneUpdate(**data)
class SubscriptionUpdateSchema(helpers.BaseSchema):
    version = marshmallow.fields.Integer(allow_none=True, missing=None)
    actions = marshmallow.fields.List(
        helpers.Discriminator(
            allow_none=True,
            discriminator_field=("action", "action"),
            discriminator_schemas={
                "changeDestination":
                helpers.absmod(__name__,
                               ".SubscriptionChangeDestinationActionSchema"),
                "setChanges":
                helpers.absmod(__name__,
                               ".SubscriptionSetChangesActionSchema"),
                "setKey":
                helpers.absmod(__name__, ".SubscriptionSetKeyActionSchema"),
                "setMessages":
                helpers.absmod(__name__,
                               ".SubscriptionSetMessagesActionSchema"),
            },
        ),
        allow_none=True,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.SubscriptionUpdate(**data)
class SimilarProductSchema(helpers.BaseSchema):
    product = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.ProductReferenceSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
    )
    variant_id = marshmallow.fields.Integer(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="variantId",
    )
    meta = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".SimilarProductMetaSchema"),
        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):

        return models.SimilarProduct(**data)
class ShippingMethodSchema(BaseResourceSchema):
    last_modified_by = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.LastModifiedBySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="lastModifiedBy",
    )
    created_by = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.CreatedBySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="createdBy",
    )
    key = marshmallow.fields.String(allow_none=True,
                                    metadata={"omit_empty": True},
                                    missing=None)
    name = marshmallow.fields.String(allow_none=True, missing=None)
    description = marshmallow.fields.String(allow_none=True,
                                            metadata={"omit_empty": True},
                                            missing=None)
    localized_description = LocalizedStringField(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="localizedDescription",
    )
    tax_category = helpers.LazyNestedField(
        nested=helpers.absmod(__name__,
                              ".tax_category.TaxCategoryReferenceSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
        data_key="taxCategory",
    )
    zone_rates = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".ZoneRateSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
        data_key="zoneRates",
    )
    is_default = marshmallow.fields.Boolean(allow_none=True,
                                            missing=None,
                                            data_key="isDefault")
    predicate = marshmallow.fields.String(allow_none=True,
                                          metadata={"omit_empty": True},
                                          missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.ShippingMethod(**data)
Exemple #16
0
class CartClassificationTierSchema(ShippingRatePriceTierSchema):
    value = marshmallow.fields.String(allow_none=True, missing=None)
    price = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.MoneySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )
    tiers = marshmallow.fields.List(
        helpers.Discriminator(
            allow_none=True,
            discriminator_field=("type", "type"),
            discriminator_schemas={
                "CartClassification":
                helpers.absmod(__name__, ".CartClassificationTierSchema")
            },
        ),
        allow_none=True,
        missing=None,
    )
    is_matching = marshmallow.fields.Boolean(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="isMatching",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["type"]
        return models.CartClassificationTier(**data)
Exemple #17
0
class CartDiscountChangeValueActionSchema(CartDiscountUpdateActionSchema):
    value = helpers.Discriminator(
        allow_none=True,
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "absolute": helpers.absmod(
                __name__, ".CartDiscountValueAbsoluteDraftSchema"
            ),
            "giftLineItem": helpers.absmod(
                __name__, ".CartDiscountValueGiftLineItemDraftSchema"
            ),
            "relative": helpers.absmod(
                __name__, ".CartDiscountValueRelativeDraftSchema"
            ),
        },
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return models.CartDiscountChangeValueAction(**data)
Exemple #18
0
class CustomLineItemTaxedPriceSchema(helpers.BaseSchema):
    total_net = helpers.Discriminator(
        allow_none=True,
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "highPrecision":
            helpers.absmod(__name__, ".common.HighPrecisionMoneySchema"),
            "centPrecision":
            helpers.absmod(__name__, ".common.MoneySchema"),
        },
        missing=None,
        data_key="totalNet",
    )
    total_gross = helpers.Discriminator(
        allow_none=True,
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "highPrecision":
            helpers.absmod(__name__, ".common.HighPrecisionMoneySchema"),
            "centPrecision":
            helpers.absmod(__name__, ".common.MoneySchema"),
        },
        missing=None,
        data_key="totalGross",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.CustomLineItemTaxedPrice(**data)
Exemple #19
0
class CustomObjectSchema(BaseResourceSchema):
    last_modified_by = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.LastModifiedBySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="lastModifiedBy",
    )
    created_by = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.CreatedBySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="createdBy",
    )
    container = marshmallow.fields.String(allow_none=True, missing=None)
    key = marshmallow.fields.String(allow_none=True, missing=None)
    value = marshmallow.fields.Raw(allow_none=True, missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.CustomObject(**data)
Exemple #20
0
class CartDiscountValueAbsoluteSchema(CartDiscountValueSchema):
    money = marshmallow.fields.List(
        helpers.Discriminator(
            allow_none=True,
            discriminator_field=("type", "type"),
            discriminator_schemas={
                "centPrecision": helpers.absmod(
                    __name__, ".common.CentPrecisionMoneySchema"
                ),
                "highPrecision": helpers.absmod(
                    __name__, ".common.HighPrecisionMoneySchema"
                ),
            },
        ),
        allow_none=True,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["type"]
        return models.CartDiscountValueAbsolute(**data)
class ProjectCategoryRecommendationPagedQueryResponseSchema(
        helpers.BaseSchema):
    count = marshmallow.fields.Integer(allow_none=True, missing=None)
    total = marshmallow.fields.Integer(allow_none=True, missing=None)
    offset = marshmallow.fields.Integer(allow_none=True, missing=None)
    results = helpers.LazyNestedField(
        nested=helpers.absmod(__name__,
                              ".ProjectCategoryRecommendationSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )
    meta = helpers.LazyNestedField(
        nested=helpers.absmod(__name__,
                              ".ProjectCategoryRecommendationMetaSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.ProjectCategoryRecommendationPagedQueryResponse(**data)
class StoreSchema(BaseResourceSchema):
    last_modified_by = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.LastModifiedBySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="lastModifiedBy",
    )
    created_by = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.CreatedBySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="createdBy",
    )
    key = marshmallow.fields.String(allow_none=True, missing=None)
    name = LocalizedStringField(
        allow_none=True, metadata={"omit_empty": True}, missing=None
    )
    languages = marshmallow.fields.List(
        marshmallow.fields.String(allow_none=True),
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
    )
    distribution_channels = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".channel.ChannelReferenceSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
        data_key="distributionChannels",
    )
    supply_channels = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".channel.ChannelReferenceSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="supplyChannels",
    )
    custom = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".type.CustomFieldsSchema"),
        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):

        return models.Store(**data)
class SubscriptionDraftSchema(helpers.BaseSchema):
    changes = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".ChangeSubscriptionSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
    )
    destination = helpers.Discriminator(
        allow_none=True,
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "EventGrid":
            helpers.absmod(__name__, ".AzureEventGridDestinationSchema"),
            "AzureServiceBus":
            helpers.absmod(__name__, ".AzureServiceBusDestinationSchema"),
            "GoogleCloudPubSub":
            helpers.absmod(__name__, ".GoogleCloudPubSubDestinationSchema"),
            "IronMQ":
            helpers.absmod(__name__, ".IronMqDestinationSchema"),
            "SNS":
            helpers.absmod(__name__, ".SnsDestinationSchema"),
            "SQS":
            helpers.absmod(__name__, ".SqsDestinationSchema"),
        },
        missing=None,
    )
    key = marshmallow.fields.String(allow_none=True,
                                    metadata={"omit_empty": True},
                                    missing=None)
    messages = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".MessageSubscriptionSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
    )
    format = helpers.Discriminator(
        allow_none=True,
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "CloudEvents":
            helpers.absmod(__name__, ".DeliveryCloudEventsFormatSchema"),
            "Platform":
            helpers.absmod(__name__, ".DeliveryPlatformFormatSchema"),
        },
        metadata={"omit_empty": True},
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.SubscriptionDraft(**data)
class InventoryEntrySchema(BaseResourceSchema):
    last_modified_by = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.LastModifiedBySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="lastModifiedBy",
    )
    created_by = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.CreatedBySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="createdBy",
    )
    sku = marshmallow.fields.String(allow_none=True, missing=None)
    supply_channel = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".channel.ChannelResourceIdentifierSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="supplyChannel",
    )
    quantity_on_stock = marshmallow.fields.Integer(
        allow_none=True, missing=None, data_key="quantityOnStock"
    )
    available_quantity = marshmallow.fields.Integer(
        allow_none=True, missing=None, data_key="availableQuantity"
    )
    restockable_in_days = marshmallow.fields.Integer(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="restockableInDays",
    )
    expected_delivery = marshmallow.fields.DateTime(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="expectedDelivery",
    )
    custom = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".type.CustomFieldsSchema"),
        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):

        return models.InventoryEntry(**data)
Exemple #25
0
class StateSchema(BaseResourceSchema):
    last_modified_by = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.LastModifiedBySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="lastModifiedBy",
    )
    created_by = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.CreatedBySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="createdBy",
    )
    key = marshmallow.fields.String(allow_none=True, missing=None)
    type = marshmallow_enum.EnumField(StateTypeEnum,
                                      by_value=True,
                                      allow_none=True,
                                      missing=None)
    name = LocalizedStringField(allow_none=True,
                                metadata={"omit_empty": True},
                                missing=None)
    description = LocalizedStringField(allow_none=True,
                                       metadata={"omit_empty": True},
                                       missing=None)
    initial = marshmallow.fields.Boolean(allow_none=True, missing=None)
    built_in = marshmallow.fields.Boolean(allow_none=True,
                                          missing=None,
                                          data_key="builtIn")
    roles = marshmallow.fields.List(
        marshmallow_enum.EnumField(StateRoleEnum,
                                   by_value=True,
                                   allow_none=True),
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
    )
    transitions = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".StateReferenceSchema"),
        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):

        return models.State(**data)
Exemple #26
0
class MissingAttributesSchema(helpers.BaseSchema):
    product = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.ProductReferenceSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )
    product_type = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.ProductTypeReferenceSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
        data_key="productType",
    )
    variant_id = marshmallow.fields.Integer(allow_none=True,
                                            missing=None,
                                            data_key="variantId")
    missing_attribute_values = marshmallow.fields.List(
        marshmallow.fields.String(allow_none=True),
        allow_none=True,
        missing=None,
        data_key="missingAttributeValues",
    )
    missing_attribute_names = marshmallow.fields.List(
        marshmallow.fields.String(allow_none=True),
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="missingAttributeNames",
    )
    attribute_count = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".AttributeCountSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="attributeCount",
    )
    attribute_coverage = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".AttributeCoverageSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="attributeCoverage",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.MissingAttributes(**data)
class SimilarProductSearchRequestSchema(helpers.BaseSchema):
    limit = marshmallow.fields.Integer(allow_none=True,
                                       metadata={"omit_empty": True},
                                       missing=None)
    offset = marshmallow.fields.Integer(allow_none=True,
                                        metadata={"omit_empty": True},
                                        missing=None)
    language = marshmallow.fields.String(allow_none=True,
                                         metadata={"omit_empty": True},
                                         missing=None)
    currency_code = marshmallow.fields.String(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="currencyCode",
    )
    similarity_measures = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".SimilarityMeasuresSchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="similarityMeasures",
    )
    product_set_selectors = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".ProductSetSelectorSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="productSetSelectors",
    )
    confidence_min = marshmallow.fields.Float(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="confidenceMin",
    )
    confidence_max = marshmallow.fields.Float(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="confidenceMax",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.SimilarProductSearchRequest(**data)
class ExtensionSchema(BaseResourceSchema):
    last_modified_by = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.LastModifiedBySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="lastModifiedBy",
    )
    created_by = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.CreatedBySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="createdBy",
    )
    key = marshmallow.fields.String(allow_none=True,
                                    metadata={"omit_empty": True},
                                    missing=None)
    destination = helpers.Discriminator(
        allow_none=True,
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "AWSLambda":
            helpers.absmod(__name__, ".ExtensionAWSLambdaDestinationSchema"),
            "HTTP":
            helpers.absmod(__name__, ".ExtensionHttpDestinationSchema"),
        },
        missing=None,
    )
    triggers = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".ExtensionTriggerSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )
    timeout_in_ms = marshmallow.fields.Integer(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="timeoutInMs",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.Extension(**data)
Exemple #29
0
class ProductDiscountDraftSchema(helpers.BaseSchema):
    name = LocalizedStringField(allow_none=True, missing=None)
    key = marshmallow.fields.String(
        allow_none=True, metadata={"omit_empty": True}, missing=None
    )
    description = LocalizedStringField(
        allow_none=True, metadata={"omit_empty": True}, missing=None
    )
    value = helpers.Discriminator(
        allow_none=True,
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "absolute": helpers.absmod(
                __name__, ".ProductDiscountValueAbsoluteDraftSchema"
            ),
            "external": helpers.absmod(
                __name__, ".ProductDiscountValueExternalDraftSchema"
            ),
            "relative": helpers.absmod(
                __name__, ".ProductDiscountValueRelativeDraftSchema"
            ),
        },
        missing=None,
    )
    predicate = marshmallow.fields.String(allow_none=True, missing=None)
    sort_order = marshmallow.fields.String(
        allow_none=True, missing=None, data_key="sortOrder"
    )
    is_active = marshmallow.fields.Boolean(
        allow_none=True, missing=None, data_key="isActive"
    )
    valid_from = marshmallow.fields.DateTime(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="validFrom",
    )
    valid_until = marshmallow.fields.DateTime(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="validUntil",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.ProductDiscountDraft(**data)
Exemple #30
0
class ProductDiscountUpdateSchema(helpers.BaseSchema):
    version = marshmallow.fields.Integer(allow_none=True, missing=None)
    actions = marshmallow.fields.List(
        helpers.Discriminator(
            allow_none=True,
            discriminator_field=("action", "action"),
            discriminator_schemas={
                "changeIsActive": helpers.absmod(
                    __name__, ".ProductDiscountChangeIsActiveActionSchema"
                ),
                "changeName": helpers.absmod(
                    __name__, ".ProductDiscountChangeNameActionSchema"
                ),
                "changePredicate": helpers.absmod(
                    __name__, ".ProductDiscountChangePredicateActionSchema"
                ),
                "changeSortOrder": helpers.absmod(
                    __name__, ".ProductDiscountChangeSortOrderActionSchema"
                ),
                "changeValue": helpers.absmod(
                    __name__, ".ProductDiscountChangeValueActionSchema"
                ),
                "setDescription": helpers.absmod(
                    __name__, ".ProductDiscountSetDescriptionActionSchema"
                ),
                "setKey": helpers.absmod(
                    __name__, ".ProductDiscountSetKeyActionSchema"
                ),
                "setValidFrom": helpers.absmod(
                    __name__, ".ProductDiscountSetValidFromActionSchema"
                ),
                "setValidFromAndUntil": helpers.absmod(
                    __name__, ".ProductDiscountSetValidFromAndUntilActionSchema"
                ),
                "setValidUntil": helpers.absmod(
                    __name__, ".ProductDiscountSetValidUntilActionSchema"
                ),
            },
        ),
        allow_none=True,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.ProductDiscountUpdate(**data)