square_api_client/models/
list_invoices_parameters.rs

1//! Query parameters for the List Invoices API
2
3/// This is a model struct for ListInvoicesParameters (query parameters)
4#[derive(Clone, Debug, Default)]
5pub struct ListInvoicesParameters {
6    /// The ID of the location for which to list invoices.
7    pub location_id: String,
8    /// A pagination cursor returned by a previous call to this endpoint. Provide this cursor to
9    /// retrieve the next set of results for your original query.
10    ///
11    /// For more information, see
12    /// [Pagination](https://developer.squareup.com/docs/basics/api101/pagination).
13    pub cursor: Option<String>,
14    /// The maximum number of invoices to return (200 is the maximum `limit`). If not provided, the
15    /// server uses a default limit of 100 invoices.
16    pub limit: Option<i32>,
17}
18
19impl ListInvoicesParameters {
20    pub fn to_query_string(&self) -> String {
21        self.to_string()
22    }
23}
24
25impl From<ListInvoicesParameters> for String {
26    fn from(list_invoices_parameters: ListInvoicesParameters) -> Self {
27        list_invoices_parameters.to_string()
28    }
29}
30
31impl ToString for ListInvoicesParameters {
32    fn to_string(&self) -> String {
33        let mut params = Vec::new();
34
35        if !self.location_id.is_empty() {
36            params.push(format!("location_id={}", &self.location_id));
37        }
38
39        if let Some(cursor) = &self.cursor {
40            params.push(format!("cursor={}", cursor));
41        }
42
43        if let Some(limit) = self.limit {
44            params.push(format!("limit={}", limit));
45        }
46
47        if params.is_empty() {
48            String::new()
49        } else {
50            format!("?{}", params.join("&"))
51        }
52    }
53}