class TransactionDraftSchema(helpers.BaseSchema):
    timestamp = marshmallow.fields.DateTime(allow_none=True,
                                            metadata={"omit_empty": True},
                                            missing=None)
    type = marshmallow_enum.EnumField(TransactionType,
                                      by_value=True,
                                      allow_none=True,
                                      missing=None)
    amount = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".common.MoneySchema"),
        allow_none=True,
        unknown=marshmallow.EXCLUDE,
        missing=None,
    )
    interaction_id = marshmallow.fields.String(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="interactionId",
    )
    state = marshmallow_enum.EnumField(
        TransactionState,
        by_value=True,
        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.TransactionDraft(**data)
Esempio n. 2
0
class TransactionSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.Transaction`."
    id = marshmallow.fields.String(allow_none=True)
    timestamp = marshmallow.fields.DateTime(allow_none=True, missing=None)
    type = marshmallow_enum.EnumField(types.TransactionType, by_value=True)
    amount = helpers.Discriminator(
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "centPrecision":
            "commercetools.schemas._common.CentPrecisionMoneySchema",
            "highPrecision":
            "commercetools.schemas._common.HighPrecisionMoneySchema",
        },
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )
    interaction_id = marshmallow.fields.String(allow_none=True,
                                               missing=None,
                                               data_key="interactionId")
    state = marshmallow_enum.EnumField(types.TransactionState,
                                       by_value=True,
                                       missing=None)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.Transaction(**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)
Esempio n. 4
0
class StateSchema(LoggedResourceSchema):
    "Marshmallow schema for :class:`commercetools.types.State`."
    key = marshmallow.fields.String(allow_none=True)
    type = marshmallow_enum.EnumField(types.StateTypeEnum, by_value=True)
    name = LocalizedStringField(allow_none=True, missing=None)
    description = LocalizedStringField(allow_none=True, missing=None)
    initial = marshmallow.fields.Bool(allow_none=True)
    built_in = marshmallow.fields.Bool(allow_none=True, data_key="builtIn")
    roles = marshmallow.fields.List(marshmallow_enum.EnumField(
        types.StateRoleEnum, by_value=True),
                                    missing=None)
    transitions = marshmallow.fields.Nested(
        nested="commercetools.schemas._state.StateReferenceSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        many=True,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.State(**data)
Esempio n. 5
0
class AttributeDefinitionSchema(marshmallow.Schema):
    """Marshmallow schema for :class:`commercetools.types.AttributeDefinition`."""

    type = helpers.Discriminator(
        discriminator_field=("name", "name"),
        discriminator_schemas={
            "boolean":
            "commercetools._schemas._product_type.AttributeBooleanTypeSchema",
            "datetime":
            "commercetools._schemas._product_type.AttributeDateTimeTypeSchema",
            "date":
            "commercetools._schemas._product_type.AttributeDateTypeSchema",
            "enum":
            "commercetools._schemas._product_type.AttributeEnumTypeSchema",
            "ltext":
            "commercetools._schemas._product_type.AttributeLocalizableTextTypeSchema",
            "lenum":
            "commercetools._schemas._product_type.AttributeLocalizedEnumTypeSchema",
            "money":
            "commercetools._schemas._product_type.AttributeMoneyTypeSchema",
            "nested":
            "commercetools._schemas._product_type.AttributeNestedTypeSchema",
            "number":
            "commercetools._schemas._product_type.AttributeNumberTypeSchema",
            "reference":
            "commercetools._schemas._product_type.AttributeReferenceTypeSchema",
            "set":
            "commercetools._schemas._product_type.AttributeSetTypeSchema",
            "text":
            "commercetools._schemas._product_type.AttributeTextTypeSchema",
            "time":
            "commercetools._schemas._product_type.AttributeTimeTypeSchema",
        },
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )
    name = marshmallow.fields.String(allow_none=True)
    label = LocalizedStringField(allow_none=True)
    is_required = marshmallow.fields.Bool(allow_none=True,
                                          data_key="isRequired")
    attribute_constraint = marshmallow_enum.EnumField(
        types.AttributeConstraintEnum,
        by_value=True,
        data_key="attributeConstraint")
    input_tip = LocalizedStringField(allow_none=True,
                                     missing=None,
                                     data_key="inputTip")
    input_hint = marshmallow_enum.EnumField(types.TextInputHint,
                                            by_value=True,
                                            data_key="inputHint")
    is_searchable = marshmallow.fields.Bool(allow_none=True,
                                            data_key="isSearchable")

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.AttributeDefinition(**data)
Esempio n. 6
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)
class ExtensionTriggerSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.ExtensionTrigger`."
    resource_type_id = marshmallow_enum.EnumField(
        types.ExtensionResourceTypeId,
        by_value=True,
        data_key="resourceTypeId")
    actions = marshmallow.fields.List(
        marshmallow_enum.EnumField(types.ExtensionAction, by_value=True))

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data):
        return types.ExtensionTrigger(**data)
Esempio n. 8
0
class JobResult:
    """Get job results response data.

    Properties:
        id: Unique job id.
        result: Job result.
        status: Current job status.
    """

    id: UUID  # pylint: disable=invalid-name
    status: JobStatus = dataclasses.field(metadata={
        "marshmallow_field":
        marshmallow_enum.EnumField(JobStatus, by_value=True)
    })
    error_message: typing.Optional[str] = dataclasses.field(default=None)
    result: typing.Optional[typing.Any] = dataclasses.field(default=None)

    def __post_init__(self):
        """See base class documentation."""
        if self.status == JobStatus.ERROR:
            if not self.error_message:
                raise ValueError("Missing error messsage")
            if self.result:
                raise ValueError("Failed job cannot have result field")

        if self.status == JobStatus.COMPLETE:
            if not self.result:
                raise ValueError("Missing job result")
            if self.error_message:
                raise ValueError(
                    "Completed job cannot have error_message field")
class CartDiscountDraftSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.CartDiscountDraft`."
    name = LocalizedStringField(allow_none=True)
    key = marshmallow.fields.String(allow_none=True, missing=None)
    description = LocalizedStringField(allow_none=True, missing=None)
    value = helpers.Discriminator(
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "absolute": "commercetools.schemas._cart_discount.CartDiscountValueAbsoluteSchema",
            "giftLineItem": "commercetools.schemas._cart_discount.CartDiscountValueGiftLineItemSchema",
            "relative": "commercetools.schemas._cart_discount.CartDiscountValueRelativeSchema",
        },
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )
    cart_predicate = marshmallow.fields.String(
        allow_none=True, data_key="cartPredicate"
    )
    target = helpers.Discriminator(
        discriminator_field=("type", "type"),
        discriminator_schemas={
            "customLineItems": "commercetools.schemas._cart_discount.CartDiscountCustomLineItemsTargetSchema",
            "lineItems": "commercetools.schemas._cart_discount.CartDiscountLineItemsTargetSchema",
            "shipping": "commercetools.schemas._cart_discount.CartDiscountShippingCostTargetSchema",
            "multiBuyCustomLineItems": "commercetools.schemas._cart_discount.MultiBuyCustomLineItemsTargetSchema",
            "multiBuyLineItems": "commercetools.schemas._cart_discount.MultiBuyLineItemsTargetSchema",
        },
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    sort_order = marshmallow.fields.String(allow_none=True, data_key="sortOrder")
    is_active = marshmallow.fields.Bool(
        allow_none=True, missing=None, data_key="isActive"
    )
    valid_from = marshmallow.fields.DateTime(
        allow_none=True, missing=None, data_key="validFrom"
    )
    valid_until = marshmallow.fields.DateTime(
        allow_none=True, missing=None, data_key="validUntil"
    )
    requires_discount_code = marshmallow.fields.Bool(
        allow_none=True, data_key="requiresDiscountCode"
    )
    stacking_mode = marshmallow_enum.EnumField(
        types.StackingMode, by_value=True, missing=None, data_key="stackingMode"
    )
    custom = marshmallow.fields.Nested(
        nested="commercetools.schemas._type.CustomFieldsSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data):
        return types.CartDiscountDraft(**data)
Esempio n. 10
0
class EventCommandReceived(LinterFix, AbstractCommand):
    chat_type: ChatType = field(metadata={
        "marshmallow_field":
        marshmallow_enum.EnumField(ChatType, by_value=True)
    })
    user_id_in_messenger: Optional[str]
    is_redirect: bool = False  # TODO: Legacy - удалить
    bot_user_id: Optional[int] = None
    message_id_in_messenger: Optional[str] = None
    reply_id_in_messenger: Optional[str] = None
    chat_avatar_in_messenger: Optional[str] = field(
        default=None,
        metadata={
            "marshmallow_field": marshmallow.fields.Url(allow_none=True)
        })
    chat_name_in_messenger: Optional[str] = None
    chat_url_in_messenger: Optional[str] = field(
        default=None,
        metadata={
            "marshmallow_field": marshmallow.fields.Url(allow_none=True)
        })

    user_name_in_messenger: Optional[str] = None
    user_url_in_messenger: Optional[str] = field(
        default=None,
        metadata={
            "marshmallow_field": marshmallow.fields.Url(allow_none=True)
        })
    user_avatar_in_messenger: Optional[str] = field(
        default=None,
        metadata={
            "marshmallow_field": marshmallow.fields.Url(allow_none=True)
        })
    ts_in_messenger: Optional[datetime] = None
Esempio n. 11
0
class TypeDraftSchema(helpers.BaseSchema):
    key = marshmallow.fields.String(allow_none=True, missing=None)
    name = LocalizedStringField(allow_none=True, missing=None)
    description = LocalizedStringField(allow_none=True,
                                       metadata={"omit_empty": True},
                                       missing=None)
    resource_type_ids = marshmallow.fields.List(
        marshmallow_enum.EnumField(ResourceTypeId,
                                   by_value=True,
                                   allow_none=True),
        allow_none=True,
        missing=None,
        data_key="resourceTypeIds",
    )
    field_definitions = helpers.LazyNestedField(
        nested=helpers.absmod(__name__, ".FieldDefinitionSchema"),
        allow_none=True,
        many=True,
        unknown=marshmallow.EXCLUDE,
        metadata={"omit_empty": True},
        missing=None,
        data_key="fieldDefinitions",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

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

        return models.TypeDraft(**data)
Esempio n. 12
0
class Payload:
    Schema: ClassVar[Type[marshmallow.Schema]] = marshmallow.Schema

    direction: MessageDirection = field(default=MessageDirection.RECEIVED,
                                        metadata={
                                            "marshmallow_field":
                                            marshmallow_enum.EnumField(
                                                MessageDirection,
                                                by_value=True)
                                        })
    text: Optional[str] = None
    contact: Optional[Contact] = None
    image_url: Optional[str] = field(
        default=None,
        metadata={
            "marshmallow_field": marshmallow.fields.Url(allow_none=True)
        })
    file_url: Optional[str] = field(default=None,
                                    metadata={
                                        "marshmallow_field":
                                        marshmallow.fields.Url(allow_none=True)
                                    })
    video_url: Optional[str] = field(
        default=None,
        metadata={
            "marshmallow_field": marshmallow.fields.Url(allow_none=True)
        })
    inline: Optional[InlineButton] = None
    command: Optional[str] = None
    voice: Optional[bytes] = None
    carousel: Optional[List[GenericTemplate]] = None
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)
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)
Esempio n. 15
0
class OkMessage(LinterFix):
    """Класс данных для хранения информации о сообщении ОК."""

    Schema: ClassVar[Type[marshmallow.Schema]] = marshmallow.Schema

    text: Optional[str] = None
    seq: Optional[int] = None
    attachment: Optional[OkAttachment] = None
    attachments: Optional[List[OkAttachment]] = field(
        default=None,
        metadata={
            "marshmallow_field": marshmallow.fields.List(
                marshmallow.fields.Nested(OkAttachment.Schema()),
                allow_none=True,
                # validate=marshmallow.validate.Length(max=3),
            )
        }
    )
    mid: Optional[str] = None
    privacyWarning: Optional[OkPrivacyWarningType] = field(
        default=None,
        metadata={
            "marshmallow_field": marshmallow_enum.EnumField(OkPrivacyWarningType, by_value=True)
        }
    )
    reply_to: Optional[str] = None
Esempio n. 16
0
class ChannelDraftSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.ChannelDraft`."
    key = marshmallow.fields.String(allow_none=True)
    roles = marshmallow.fields.List(marshmallow_enum.EnumField(
        types.ChannelRoleEnum, by_value=True),
                                    missing=None)
    name = LocalizedStringField(allow_none=True, missing=None)
    description = LocalizedStringField(allow_none=True, missing=None)
    address = marshmallow.fields.Nested(
        nested="commercetools.schemas._common.AddressSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    custom = marshmallow.fields.Nested(
        nested="commercetools.schemas._type.CustomFieldsDraftSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
    )
    geo_location = marshmallow.fields.Nested(
        nested="commercetools.schemas._common.GeoJsonPointSchema",
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
        missing=None,
        data_key="geoLocation",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.ChannelDraft(**data)
class CustomerSigninSchema(marshmallow.Schema):
    """Marshmallow schema for :class:`commercetools.types.CustomerSignin`."""

    email = marshmallow.fields.String(allow_none=True)
    password = marshmallow.fields.String(allow_none=True)
    anonymous_cart_id = marshmallow.fields.String(
        allow_none=True, missing=None, data_key="anonymousCartId"
    )
    anonymous_cart_sign_in_mode = marshmallow_enum.EnumField(
        types.AnonymousCartSignInMode,
        by_value=True,
        missing=None,
        data_key="anonymousCartSignInMode",
    )
    anonymous_id = marshmallow.fields.String(
        allow_none=True, missing=None, data_key="anonymousId"
    )
    update_product_data = marshmallow.fields.Bool(
        allow_none=True, missing=None, data_key="updateProductData"
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.CustomerSignin(**data)
Esempio n. 18
0
class TypedMoneySchema(helpers.BaseSchema):
    type = marshmallow_enum.EnumField(MoneyType,
                                      by_value=True,
                                      allow_none=True,
                                      missing=None)
    fraction_digits = marshmallow.fields.Integer(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="fractionDigits",
    )
    cent_amount = marshmallow.fields.Integer(allow_none=True,
                                             missing=None,
                                             data_key="centAmount")
    currency_code = marshmallow.fields.String(allow_none=True,
                                              missing=None,
                                              data_key="currencyCode")

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["type"]
        return models.TypedMoney(**data)
Esempio n. 19
0
class MultiBuyLineItemsTargetSchema(CartDiscountTargetSchema):
    predicate = marshmallow.fields.String(allow_none=True, missing=None)
    trigger_quantity = marshmallow.fields.Integer(
        allow_none=True, missing=None, data_key="triggerQuantity"
    )
    discounted_quantity = marshmallow.fields.Integer(
        allow_none=True, missing=None, data_key="discountedQuantity"
    )
    max_occurrence = marshmallow.fields.Integer(
        allow_none=True,
        metadata={"omit_empty": True},
        missing=None,
        data_key="maxOccurrence",
    )
    selection_mode = marshmallow_enum.EnumField(
        SelectionMode,
        by_value=True,
        allow_none=True,
        missing=None,
        data_key="selectionMode",
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["type"]
        return models.MultiBuyLineItemsTarget(**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)
Esempio n. 21
0
class BranchNodeSchema(NodeSchema):
    """Serialization schema for branch nodes."""

    child_branches = fields.Dict(fields.Str(),
                                 fields.Nested(lambda: BranchNodeSchema()))
    child_leaves = fields.Dict(fields.Str(), fields.Nested(LeafNodeSchema()))
    environment_state = marshmallow_enum.EnumField(
        environment.EnvironmentState, by_value=True)
Esempio n. 22
0
class Callback:
    Schema: ClassVar[Type[marshmallow.Schema]] = marshmallow.Schema

    type: CallbackType = field(
        metadata={
            "marshmallow_field":
            marshmallow_enum.EnumField(CallbackType, by_value=True)
        })
    id: int
Esempio n. 23
0
class RuleSchema(ma.Schema):

    trait = ma.fields.String()
    match = ma.fields.String()
    action = ma_enum.EnumField(RuleAction)

    @ma.post_load
    def build_rule(self, data, **_):
        return Rule(**data)
class ExtensionInputSchema(marshmallow.Schema):
    """Marshmallow schema for :class:`commercetools.types.ExtensionInput`."""

    action = marshmallow_enum.EnumField(types.ExtensionAction, by_value=True)
    resource = helpers.Discriminator(
        discriminator_field=("typeId", "type_id"),
        discriminator_schemas={
            "cart-discount":
            "commercetools._schemas._cart_discount.CartDiscountReferenceSchema",
            "cart": "commercetools._schemas._cart.CartReferenceSchema",
            "category":
            "commercetools._schemas._category.CategoryReferenceSchema",
            "channel":
            "commercetools._schemas._channel.ChannelReferenceSchema",
            "key-value-document":
            "commercetools._schemas._custom_object.CustomObjectReferenceSchema",
            "customer-group":
            "commercetools._schemas._customer_group.CustomerGroupReferenceSchema",
            "customer":
            "commercetools._schemas._customer.CustomerReferenceSchema",
            "discount-code":
            "commercetools._schemas._discount_code.DiscountCodeReferenceSchema",
            "inventory-entry":
            "commercetools._schemas._inventory.InventoryEntryReferenceSchema",
            "order-edit":
            "commercetools._schemas._order_edit.OrderEditReferenceSchema",
            "order": "commercetools._schemas._order.OrderReferenceSchema",
            "payment":
            "commercetools._schemas._payment.PaymentReferenceSchema",
            "product-discount":
            "commercetools._schemas._product_discount.ProductDiscountReferenceSchema",
            "product-type":
            "commercetools._schemas._product_type.ProductTypeReferenceSchema",
            "product":
            "commercetools._schemas._product.ProductReferenceSchema",
            "review": "commercetools._schemas._review.ReviewReferenceSchema",
            "shipping-method":
            "commercetools._schemas._shipping_method.ShippingMethodReferenceSchema",
            "shopping-list":
            "commercetools._schemas._shopping_list.ShoppingListReferenceSchema",
            "state": "commercetools._schemas._state.StateReferenceSchema",
            "store": "commercetools._schemas._store.StoreReferenceSchema",
            "tax-category":
            "commercetools._schemas._tax_category.TaxCategoryReferenceSchema",
            "type": "commercetools._schemas._type.TypeReferenceSchema",
            "zone": "commercetools._schemas._zone.ZoneReferenceSchema",
        },
        unknown=marshmallow.EXCLUDE,
        allow_none=True,
    )

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        return types.ExtensionInput(**data)
Esempio n. 25
0
class PaypalAppContext:
    """Класс данных для хранения информации о настройках для работы с покупателем.

    Содержит настройки получения предпочтительного адреса доставки и особенностей оплаты."""

    Schema: ClassVar[Type[marshmallow.Schema]] = marshmallow.Schema

    shipping_preference: PaypalShippingPreference = field(
        default=PaypalShippingPreference.GET_FROM_FILE,
        metadata={
            "marshmallow_field": marshmallow_enum.EnumField(PaypalShippingPreference, by_value=True)
        }
    )
    user_action: PaypalUserAction = field(
        default=PaypalUserAction.PAY_NOW,
        metadata={
            "marshmallow_field": marshmallow_enum.EnumField(PaypalUserAction, by_value=True)
        }
    )
class StateChangeTypeActionSchema(StateUpdateActionSchema):
    "Marshmallow schema for :class:`commercetools.types.StateChangeTypeAction`."
    type = marshmallow_enum.EnumField(types.StateTypeEnum, by_value=True)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["action"]
        return types.StateChangeTypeAction(**data)
Esempio n. 27
0
class PaypalAmount:
    """Класс данных для хранения информации о суммах денег в разных валютах."""

    Schema: ClassVar[Type[marshmallow.Schema]] = marshmallow.Schema

    currency_code: Currency = field(
        metadata={
            "marshmallow_field": marshmallow_enum.EnumField(Currency, by_value=True)
        }
    )
    value: str
Esempio n. 28
0
class AbstractCommand(ABC):
    Schema: ClassVar[Type[marshmallow.Schema]] = marshmallow.Schema

    bot_id: int
    chat_id_in_messenger: str
    content_type: MessageContentType = field(
        metadata={
            "marshmallow_field":
            marshmallow_enum.EnumField(MessageContentType, by_value=True)
        })
    payload: Payload
Esempio n. 29
0
class TypedMoneyDraftSchema(MoneySchema):
    "Marshmallow schema for :class:`commercetools.types.TypedMoneyDraft`."
    type = marshmallow_enum.EnumField(types.MoneyType, by_value=True)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data, **kwargs):
        del data["type"]
        return types.TypedMoneyDraft(**data)
Esempio n. 30
0
class ShippingRatePriceTierSchema(marshmallow.Schema):
    "Marshmallow schema for :class:`commercetools.types.ShippingRatePriceTier`."
    type = marshmallow_enum.EnumField(types.ShippingRateTierType, by_value=True)

    class Meta:
        unknown = marshmallow.EXCLUDE

    @marshmallow.post_load
    def post_load(self, data):
        del data["type"]
        return types.ShippingRatePriceTier(**data)