square_api_client/models/
catalog_query.rs

1//! Model struct for CatalogQuery type.
2
3use serde::Serialize;
4
5use super::{
6    CatalogQueryExact, CatalogQueryItemVariationsForItemOptionValues,
7    CatalogQueryItemsForItemOptions, CatalogQueryItemsForModifierList, CatalogQueryItemsForTax,
8    CatalogQueryPrefix, CatalogQueryRange, CatalogQuerySet, CatalogQuerySortedAttribute,
9    CatalogQueryText,
10};
11
12/// A query composed of one or more different types of filters to narrow the scope of targeted
13/// objects when calling the `SearchCatalogObjects` endpoint.
14///
15/// Although a query can have multiple filters, only certain query types can be combined per call to
16/// `SearchCatalogObjects`. Any combination of the following types may be used together:
17///
18/// * [exact_query](CatalogQueryExact)
19/// * [prefix_query](CatalogQueryPrefix)
20/// * [range_query](CatalogQueryRange)
21/// * [sorted_attribute_query](CatalogQuerySortedAttribute)
22/// * [text_query](CatalogQueryText) All other query types cannot be combined with any others.
23///
24/// When a query filter is based on an attribute, the attribute must be searchable. Searchable
25/// attributes are listed as follows, along their parent types that can be searched for with
26/// applicable query filters.
27///
28/// * Searchable attribute and objects queryable by searchable attributes **
29/// * `name`: `CatalogItem`, `CatalogItemVariation`, `CatalogCategory`, `CatalogTax`,
30///   `CatalogDiscount`, `CatalogModifier`, `CatalogModifierList`, `CatalogItemOption`,
31///   `CatalogItemOptionValue`
32/// * `description`: `CatalogItem`, `CatalogItemOptionValue`
33/// * `abbreviation`: `CatalogItem`
34/// * `upc`: `CatalogItemVariation`
35/// * `sku`: `CatalogItemVariation`
36/// * `caption`: `CatalogImage`
37/// * `display_name`: `CatalogItemOption`
38///
39/// For example, to search for [CatalogItem] objects by searchable attributes, you can use the
40/// `"name"`, `"description"`, or `"abbreviation"` attribute in an applicable query filter.
41#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)]
42pub struct CatalogQuery {
43    /// A query expression to sort returned query result by the given attribute.
44    pub sorted_attribute_query: Option<CatalogQuerySortedAttribute>,
45    /// An exact query expression to return objects with attribute name and value matching the
46    /// specified attribute name and value exactly. Value matching is case insensitive.
47    pub exact_query: Option<CatalogQueryExact>,
48    /// A set query expression to return objects with attribute name and value matching the
49    /// specified attribute name and any of the specified attribute values exactly. Value matching
50    /// is case insensitive.
51    pub set_query: Option<CatalogQuerySet>,
52    /// A prefix query expression to return objects with attribute values that have a prefix
53    /// matching the specified string value. Value matching is case insensitive.
54    pub prefix_query: Option<CatalogQueryPrefix>,
55    /// A range query expression to return objects with numeric values that lie in the specified
56    /// range.
57    pub range_query: Option<CatalogQueryRange>,
58    /// A text query expression to return objects whose searchable attributes contain all of the
59    /// given keywords, irrespective of their order. For example, if a `CatalogItem` contains custom
60    /// attribute values of `{"name": "t-shirt"}` and `{"description": "Small, Purple"}`, the query
61    /// filter of `{"keywords": ["shirt", "sma", "purp"]}` returns this item.
62    pub text_query: Option<CatalogQueryText>,
63    /// A query expression to return items that have any of the specified taxes (as identified by
64    /// the corresponding `CatalogTax` object IDs) enabled.
65    pub items_for_tax_query: Option<CatalogQueryItemsForTax>,
66    /// A query expression to return items that have any of the given modifier list (as identified
67    /// by the corresponding `CatalogModifierList`s IDs) enabled.
68    pub items_for_modifier_list_query: Option<CatalogQueryItemsForModifierList>,
69    /// A query expression to return items that contains the specified item options (as identified
70    /// the corresponding `CatalogItemOption` IDs).
71    pub items_for_item_options_query: Option<CatalogQueryItemsForItemOptions>,
72    /// A query expression to return item variations (of the CatalogItemVariation type) that contain
73    /// all of the specified `CatalogItemOption` IDs.
74    pub item_variations_for_item_option_values_query:
75        Option<CatalogQueryItemVariationsForItemOptionValues>,
76}