square_api_client/models/retrieve_catalog_object_parameters.rs
1//! Query parameters for the Retrieve Catalog Object API
2
3/// This is a model struct for RetrieveCatalogObjectParameters (query parameters)
4#[derive(Clone, Debug, Default)]
5pub struct RetrieveCatalogObjectParameters {
6 /// If `true`, the response will include additional objects that are related to the requested
7 /// objects. Related objects are defined as any objects referenced by ID by the results in the
8 /// `objects` field of the response. These objects are put in the `related_objects` field.
9 /// Setting this to `true` is helpful when the objects are needed for immediate display to a
10 /// user. This process only goes one level deep. Objects referenced by the related objects will
11 /// not be included. For example,
12 ///
13 /// if the `objects` field of the response contains a CatalogItem, its associated
14 /// CatalogCategory objects, CatalogTax objects, CatalogImage objects and CatalogModifierLists
15 /// will be returned in the `related_objects` field of the response. If the `objects` field of
16 /// the response contains a CatalogItemVariation, its parent CatalogItem will be returned in the
17 /// `related_objects` field of the response.
18 ///
19 /// Default value: `false`
20 pub include_related_objects: Option<bool>,
21 /// Requests objects as of a specific version of the catalog. This allows you to retrieve
22 /// historical versions of objects. The value to retrieve a specific version of an object can be
23 /// found in the version field of [CatalogObject]s. If not included, results will be from the
24 /// current version of the catalog.
25 pub catalog_version: Option<i64>,
26}
27
28impl RetrieveCatalogObjectParameters {
29 pub fn to_query_string(&self) -> String {
30 self.to_string()
31 }
32}
33
34impl From<RetrieveCatalogObjectParameters> for String {
35 fn from(retrieve_catalog_object_parameters: RetrieveCatalogObjectParameters) -> Self {
36 retrieve_catalog_object_parameters.to_string()
37 }
38}
39
40impl ToString for RetrieveCatalogObjectParameters {
41 fn to_string(&self) -> String {
42 let mut params = Vec::new();
43
44 if let Some(include_related_objects) = &self.include_related_objects {
45 params.push(format!("include_related_objects={}", include_related_objects));
46 }
47
48 if let Some(catalog_version) = &self.catalog_version {
49 params.push(format!("catalog_version={}", catalog_version));
50 }
51
52 if params.is_empty() {
53 String::new()
54 } else {
55 format!("?{}", params.join("&"))
56 }
57 }
58}