squareup/models/
list_invoices_parameters.rs1use std::fmt::Display;
4
5#[derive(Clone, Debug, Default)]
7pub struct ListInvoicesParameters {
8 pub location_id: String,
10 pub cursor: Option<String>,
16 pub limit: Option<i32>,
19}
20
21impl ListInvoicesParameters {
22 pub fn to_query_string(&self) -> String {
23 self.to_string()
24 }
25}
26
27impl From<ListInvoicesParameters> for String {
28 fn from(list_invoices_parameters: ListInvoicesParameters) -> Self {
29 list_invoices_parameters.to_string()
30 }
31}
32
33impl Display for ListInvoicesParameters {
34 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35 let mut params = Vec::new();
36
37 if !self.location_id.is_empty() {
38 params.push(format!("location_id={}", &self.location_id));
39 }
40
41 if let Some(cursor) = &self.cursor {
42 params.push(format!("cursor={}", cursor));
43 }
44
45 if let Some(limit) = self.limit {
46 params.push(format!("limit={}", limit));
47 }
48
49 let str = if params.is_empty() {
50 String::new()
51 } else {
52 format!("?{}", params.join("&"))
53 };
54 write!(f, "{}", str)
55 }
56}