class _ProductProjectionsBaseSchema(Schema, abstract.RemoveEmptyValuesMixin):
    sort = helpers.OptionalList(fields.String())
    limit = fields.Int()
    offset = fields.Int()

    staged = fields.Bool(data_key="staged", required=False, missing=False)
    price_currency = fields.String(data_key="priceCurrency")
    price_country = fields.String(data_key="priceCountry")
    price_customer_group = fields.UUID(data_key="priceCustomerGroup")
    price_channel = fields.UUID(data_key="priceChannel")
class ProductProjectionsSearchSchema(ProductProjectionsBaseSchema):
    text = fields.Method("text_serialize")
    fuzzy = fields.Bool()
    fuzzy_level = fields.Integer(data_key="fuzzy.level")
    filter = helpers.OptionalList(fields.String())
    filter_query = helpers.OptionalList(fields.String(),
                                        data_key="filter.query")
    filter_facets = helpers.OptionalList(fields.String(),
                                         data_key="filter.facets")
    facet = helpers.OptionalList(fields.String())
    mark_matching_variants = fields.Bool(data_key="markMatchingVariants")

    def text_serialize(self, value):
        result = {}
        data = value.get("text") or {}
        for k, v in data.items():
            result[f"text.{k}"] = v
        return result

    @post_dump
    def merge_text(self, data, **kwargs):
        value = data.pop("text")
        data.update(value)
        return data
Exemplo n.º 3
0
class Dummy(Schema):
    items = helpers.OptionalList(fields.String())
class ProductProjectionsQuerySchema(_ProductProjectionsBaseSchema):
    where = helpers.OptionalList(fields.String())
    expand = helpers.OptionalList(fields.String())