stripe/resources/generated/
terminal_location.rs

1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use crate::client::{Client, Response};
6use crate::ids::TerminalLocationId;
7use crate::params::{Expand, List, Metadata, Object, Paginable};
8use crate::resources::Address;
9use serde::{Deserialize, Serialize};
10
11/// The resource representing a Stripe "TerminalLocationLocation".
12///
13/// For more details see <https://stripe.com/docs/api/terminal/locations/object>
14#[derive(Clone, Debug, Default, Deserialize, Serialize)]
15pub struct TerminalLocation {
16    /// Unique identifier for the object.
17    pub id: TerminalLocationId,
18
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub address: Option<Address>,
21
22    /// The ID of a configuration that will be used to customize all readers in this location.
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub configuration_overrides: Option<String>,
25
26    // Always true for a deleted object
27    #[serde(default)]
28    pub deleted: bool,
29
30    /// The display name of the location.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub display_name: Option<String>,
33
34    /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub livemode: Option<bool>,
37
38    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
39    ///
40    /// This can be useful for storing additional information about the object in a structured format.
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub metadata: Option<Metadata>,
43}
44
45impl TerminalLocation {
46    /// Returns a list of `Location` objects.
47    pub fn list(
48        client: &Client,
49        params: &ListTerminalLocations<'_>,
50    ) -> Response<List<TerminalLocation>> {
51        client.get_query("/terminal/locations", params)
52    }
53
54    /// Creates a new `Location` object.
55    /// For further details, including which address fields are required in each country, see the [Manage locations](https://stripe.com/docs/terminal/fleet/locations) guide.
56    pub fn create(
57        client: &Client,
58        params: CreateTerminalLocation<'_>,
59    ) -> Response<TerminalLocation> {
60        #[allow(clippy::needless_borrows_for_generic_args)]
61        client.post_form("/terminal/locations", &params)
62    }
63}
64
65impl Object for TerminalLocation {
66    type Id = TerminalLocationId;
67    fn id(&self) -> Self::Id {
68        self.id.clone()
69    }
70    fn object(&self) -> &'static str {
71        "terminal.location"
72    }
73}
74
75/// The parameters for `TerminalLocation::create`.
76#[derive(Clone, Debug, Serialize)]
77pub struct CreateTerminalLocation<'a> {
78    /// The full address of the location.
79    pub address: CreateTerminalLocationAddress,
80
81    /// The ID of a configuration that will be used to customize all readers in this location.
82    #[serde(skip_serializing_if = "Option::is_none")]
83    pub configuration_overrides: Option<&'a str>,
84
85    /// A name for the location.
86    pub display_name: &'a str,
87
88    /// Specifies which fields in the response should be expanded.
89    #[serde(skip_serializing_if = "Expand::is_empty")]
90    pub expand: &'a [&'a str],
91
92    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
93    ///
94    /// This can be useful for storing additional information about the object in a structured format.
95    /// Individual keys can be unset by posting an empty value to them.
96    /// All keys can be unset by posting an empty value to `metadata`.
97    #[serde(skip_serializing_if = "Option::is_none")]
98    pub metadata: Option<Metadata>,
99}
100
101impl<'a> CreateTerminalLocation<'a> {
102    pub fn new(address: CreateTerminalLocationAddress, display_name: &'a str) -> Self {
103        CreateTerminalLocation {
104            address,
105            configuration_overrides: Default::default(),
106            display_name,
107            expand: Default::default(),
108            metadata: Default::default(),
109        }
110    }
111}
112
113/// The parameters for `TerminalLocation::list`.
114#[derive(Clone, Debug, Serialize, Default)]
115pub struct ListTerminalLocations<'a> {
116    /// A cursor for use in pagination.
117    ///
118    /// `ending_before` is an object ID that defines your place in the list.
119    /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
120    #[serde(skip_serializing_if = "Option::is_none")]
121    pub ending_before: Option<TerminalLocationId>,
122
123    /// Specifies which fields in the response should be expanded.
124    #[serde(skip_serializing_if = "Expand::is_empty")]
125    pub expand: &'a [&'a str],
126
127    /// A limit on the number of objects to be returned.
128    ///
129    /// Limit can range between 1 and 100, and the default is 10.
130    #[serde(skip_serializing_if = "Option::is_none")]
131    pub limit: Option<u64>,
132
133    /// A cursor for use in pagination.
134    ///
135    /// `starting_after` is an object ID that defines your place in the list.
136    /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
137    #[serde(skip_serializing_if = "Option::is_none")]
138    pub starting_after: Option<TerminalLocationId>,
139}
140
141impl<'a> ListTerminalLocations<'a> {
142    pub fn new() -> Self {
143        ListTerminalLocations {
144            ending_before: Default::default(),
145            expand: Default::default(),
146            limit: Default::default(),
147            starting_after: Default::default(),
148        }
149    }
150}
151impl Paginable for ListTerminalLocations<'_> {
152    type O = TerminalLocation;
153    fn set_last(&mut self, item: Self::O) {
154        self.starting_after = Some(item.id());
155    }
156}
157#[derive(Clone, Debug, Default, Deserialize, Serialize)]
158pub struct CreateTerminalLocationAddress {
159    /// City, district, suburb, town, or village.
160    #[serde(skip_serializing_if = "Option::is_none")]
161    pub city: Option<String>,
162
163    /// Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
164    pub country: String,
165
166    /// Address line 1 (e.g., street, PO Box, or company name).
167    #[serde(skip_serializing_if = "Option::is_none")]
168    pub line1: Option<String>,
169
170    /// Address line 2 (e.g., apartment, suite, unit, or building).
171    #[serde(skip_serializing_if = "Option::is_none")]
172    pub line2: Option<String>,
173
174    /// ZIP or postal code.
175    #[serde(skip_serializing_if = "Option::is_none")]
176    pub postal_code: Option<String>,
177
178    /// State, county, province, or region.
179    #[serde(skip_serializing_if = "Option::is_none")]
180    pub state: Option<String>,
181}