square_api_client/models/
list_customer_segments_parameters.rs

1//! Query parameters for the List Customer Segments API
2
3/// This is a model struct for ListCustomerSegmentsParameters (query parameters)
4#[derive(Clone, Debug, Default)]
5pub struct ListCustomerSegmentsParameters {
6    /// A pagination cursor returned by previous calls to ListCustomerSegments. This cursor is used
7    /// to retrieve the next set of query results.
8    ///
9    /// For more information, see
10    /// [Pagination](https://developer.squareup.com/docs/basics/api101/pagination).
11    pub cursor: Option<String>,
12    /// The maximum number of results to return in a single page. This limit is advisory. The
13    /// response might contain more or fewer results. If the specified limit is less than 1 or
14    /// greater than 50, Square returns a `400 VALUE_TOO_LOW` or `400 VALUE_TOO_HIGH` error. The
15    /// default value is 50.
16    ///
17    /// For more information, see
18    /// [Pagination](https://developer.squareup.com/docs/basics/api101/pagination).
19    pub limit: Option<i32>,
20}
21
22impl ListCustomerSegmentsParameters {
23    pub fn to_query_string(&self) -> String {
24        self.to_string()
25    }
26}
27
28impl From<ListCustomerSegmentsParameters> for String {
29    fn from(list_customer_segments_parameters: ListCustomerSegmentsParameters) -> Self {
30        list_customer_segments_parameters.to_string()
31    }
32}
33
34impl ToString for ListCustomerSegmentsParameters {
35    fn to_string(&self) -> String {
36        let mut params = Vec::new();
37
38        if let Some(cursor) = &self.cursor {
39            params.push(format!("cursor={}", cursor));
40        }
41
42        if let Some(limit) = self.limit {
43            params.push(format!("limit={}", limit));
44        }
45
46        if params.is_empty() {
47            String::new()
48        } else {
49            format!("?{}", params.join("&"))
50        }
51    }
52}