square_api_client/models/catalog_object.rs
1//! Model struct for CatalogObject type
2
3use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6
7use super::{
8 enums::CatalogObjectType, CatalogCategory, CatalogCustomAttributeDefinition,
9 CatalogCustomAttributeValue, CatalogDiscount, CatalogImage, CatalogItem, CatalogItemOption,
10 CatalogItemOptionValue, CatalogItemVariation, CatalogMeasurementUnit, CatalogModifier,
11 CatalogModifierList, CatalogPricingRule, CatalogProductSet, CatalogQuickAmountsSettings,
12 CatalogSubscriptionPlan, CatalogTax, CatalogTimePeriod, CatalogV1Id, DateTime,
13};
14
15/// The wrapper object for the catalog entries of a given object type.
16///
17/// Depending on the `type` attribute value, a `CatalogObject` instance assumes a type-specific data
18/// to yield the corresponding type of catalog object.
19///
20/// For example, if `type=ITEM`, the `CatalogObject` instance must have the ITEM-specific data set
21/// on the `item_data` attribute. The resulting `CatalogObject` instance is also a `CatalogItem`
22/// instance.
23///
24/// In general, if `type=<OBJECT_TYPE>`, the `CatalogObject` instance must have the
25/// `<OBJECT_TYPE>`-specific data set on the `<object_type>_data` attribute. The resulting
26/// `CatalogObject` instance is also a `Catalog<ObjectType>` instance.
27///
28/// For a more detailed discussion of the Catalog data model, please see the
29/// [Design a Catalog](https://developer.squareup.com/docs/catalog-api/design-a-catalog) guide.
30#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
31pub struct CatalogObject {
32 /// The type of this object. Each object type has expected properties expressed in a structured
33 /// format within its corresponding `*_data` field below.
34 pub r#type: CatalogObjectType,
35 /// An identifier to reference this object in the catalog. When a new `CatalogObject` is
36 /// inserted, the client should set the id to a temporary identifier starting with a "`#`"
37 /// character. Other objects being inserted or updated within the same request may use this
38 /// identifier to refer to the new object.
39 ///
40 /// When the server receives the new object, it will supply a unique identifier that replaces
41 /// the temporary identifier for all future references.
42 pub id: String,
43 /// **Read only** Last modification timestamp.
44 pub updated_at: Option<DateTime>,
45 /// The version of the object. When updating an object, the version supplied must match the
46 /// version in the database, otherwise the write will be rejected as conflicting.
47 pub version: Option<i64>,
48 /// If `true`, the object has been deleted from the database. Must be `false` for new objects
49 /// being inserted. When deleted, the `updated_at` field will equal the deletion time.
50 pub is_deleted: Option<bool>,
51 /// A map (key-value pairs) of application-defined custom attribute values. The value of a
52 /// key-value pair is a [CatalogCustomAttributeValue] object. The key is the `key` attribute
53 /// value defined in the associated [CatalogCustomAttributeDefinition] object defined by the
54 /// application making the request.
55 ///
56 /// If the `CatalogCustomAttributeDefinition` object is defined by another application, the
57 /// `CatalogCustomAttributeDefinition`'s key attribute value is prefixed by the defining
58 /// application ID. For example, if the `CatalogCustomAttributeDefinition` has a `key` attribute
59 /// of `"cocoa_brand"` and the defining application ID is `"abcd1234"`, the key in the map is
60 /// `"abcd1234:cocoa_brand"` if the application making the request is different from the
61 /// application defining the custom attribute definition. Otherwise, the key used in the map is
62 /// simply `"cocoa_brand"`.
63 ///
64 /// Application-defined custom attributes are set at a global (location-independent) level.
65 /// Custom attribute values are intended to store additional information about a catalog object
66 /// or associations with an entity in another system. Do not use custom attributes to store any
67 /// sensitive information (personally identifiable information, card details, etc.).
68 pub custom_attribute_values: Option<HashMap<String, CatalogCustomAttributeValue>>,
69 /// The Connect v1 IDs for this object at each location where it is present, where they differ
70 /// from the object's Connect V2 ID. The field will only be present for objects that have been
71 /// created or modified by legacy APIs.
72 pub catalog_v1_ids: Option<Vec<CatalogV1Id>>,
73 /// If `true`, this object is present at all locations (including future locations), except
74 /// where specified in the `absent_at_location_ids` field. If `false`, this object is not
75 /// present at any locations (including future locations), except where specified in the
76 /// `present_at_location_ids` field. If not specified, defaults to `true`.
77 pub present_at_all_locations: Option<bool>,
78 /// A list of locations where the object is present, even if `present_at_all_locations` is
79 /// `false`. This can include locations that are deactivated.
80 pub present_at_location_ids: Option<Vec<String>>,
81 /// A list of locations where the object is not present, even if `present_at_all_locations` is
82 /// `true`. This can include locations that are deactivated.
83 pub absent_at_location_ids: Option<Vec<String>>,
84 /// Structured data for a `CatalogItem`, set for CatalogObjects of type `ITEM`.
85 pub item_data: Option<CatalogItem>,
86 /// Structured data for a `CatalogCategory`, set for CatalogObjects of type `CATEGORY`.
87 pub category_data: Option<CatalogCategory>,
88 /// Structured data for a `CatalogItemVariation`, set for CatalogObjects of type
89 /// `ITEM_VARIATION`.
90 pub item_variation_data: Option<CatalogItemVariation>,
91 /// Structured data for a `CatalogTax`, set for CatalogObjects of type `TAX`.
92 pub tax_data: Option<CatalogTax>,
93 /// Structured data for a `CatalogDiscount`, set for CatalogObjects of type `DISCOUNT`.
94 pub discount_data: Option<CatalogDiscount>,
95 /// Structured data for a `CatalogModifierList`, set for CatalogObjects of type `MODIFIER_LIST`.
96 pub modifier_list_data: Option<CatalogModifierList>,
97 /// Structured data for a `CatalogModifier`, set for CatalogObjects of type `MODIFIER`.
98 pub modifier_data: Option<CatalogModifier>,
99 /// Structured data for a `CatalogTimePeriod`, set for CatalogObjects of type `TIME_PERIOD`.
100 pub time_period_data: Option<CatalogTimePeriod>,
101 /// Structured data for a `CatalogProductSet`, set for CatalogObjects of type `PRODUCT_SET`.
102 pub product_set_data: Option<CatalogProductSet>,
103 /// Structured data for a `CatalogPricingRule`, set for CatalogObjects of type `PRICING_RULE`. A
104 /// `CatalogPricingRule` object often works with a `CatalogProductSet` object or a
105 /// `CatalogTimePeriod` object.
106 pub pricing_rule_data: Option<CatalogPricingRule>,
107 /// Structured data for a `CatalogImage`, set for CatalogObjects of type `IMAGE`.
108 pub image_data: Option<CatalogImage>,
109 /// Structured data for a `CatalogMeasurementUnit`, set for CatalogObjects of type
110 /// `MEASUREMENT_UNIT`.
111 pub measurement_unit_data: Option<CatalogMeasurementUnit>,
112 /// Structured data for a `CatalogSubscriptionPlan`, set for CatalogObjects of type
113 /// `SUBSCRIPTION_PLAN`.
114 pub subscription_plan_data: Option<CatalogSubscriptionPlan>,
115 /// Structured data for a `CatalogItemOption`, set for CatalogObjects of type `ITEM_OPTION`.
116 pub item_option_data: Option<CatalogItemOption>,
117 /// Structured data for a `CatalogItemOptionValue`, set for CatalogObjects of type
118 /// `ITEM_OPTION_VAL`.
119 pub item_option_value_data: Option<CatalogItemOptionValue>,
120 /// Structured data for a `CatalogCustomAttributeDefinition`, set for CatalogObjects of type
121 /// `CUSTOM_ATTRIBUTE_DEFINITION`.
122 pub custom_attribute_definition_data: Option<CatalogCustomAttributeDefinition>,
123 /// Structured data for a `CatalogQuickAmountsSettings`, set for CatalogObjects of type
124 /// `QUICK_AMOUNTS_SETTINGS`.
125 pub quick_amounts_settings_data: Option<CatalogQuickAmountsSettings>,
126}