squareup/models/
list_subscription_events_parameters.rs

1//! Model struct for ListSubscriptionEventsParameters (query parameters)
2
3use std::fmt::Display;
4
5/// This is a model struct for ListSubscriptionEventsParameters (query parameters)
6#[derive(Clone, Debug, Default)]
7pub struct ListSubscriptionEventsParameters {
8    /// When the total number of resulting subscription events exceeds the limit of a paged
9    /// response, specify the cursor returned from a preceding response here to fetch the next set
10    /// of results. If the cursor is unset, the response contains the last page of the results.
11    ///
12    /// For more information, see
13    /// [Pagination](https://developer.squareup.com/docs/basics/api101/pagination).
14    pub cursor: Option<String>,
15    /// The upper limit on the number of subscription events to return in a paged response.
16    pub limit: Option<i32>,
17}
18
19impl ListSubscriptionEventsParameters {
20    pub fn to_query_string(&self) -> String {
21        self.to_string()
22    }
23}
24
25impl From<ListSubscriptionEventsParameters> for String {
26    fn from(list_subscription_events_parameters: ListSubscriptionEventsParameters) -> Self {
27        list_subscription_events_parameters.to_string()
28    }
29}
30
31impl Display for ListSubscriptionEventsParameters {
32    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33        let mut params = Vec::new();
34
35        if let Some(cursor) = &self.cursor {
36            params.push(format!("cursor={}", cursor));
37        }
38
39        if let Some(limit) = &self.limit {
40            params.push(format!("limit={}", limit));
41        }
42
43        let str = if params.is_empty() {
44            String::new()
45        } else {
46            format!("?{}", params.join("&"))
47        };
48        write!(f, "{}", str)
49    }
50}