1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#[derive(Clone, Debug, Default)]
pub struct ListInvoicesParameters {
pub location_id: String,
pub cursor: Option<String>,
pub limit: Option<i32>,
}
impl ListInvoicesParameters {
pub fn to_query_string(&self) -> String {
self.to_string()
}
}
impl From<ListInvoicesParameters> for String {
fn from(list_invoices_parameters: ListInvoicesParameters) -> Self {
list_invoices_parameters.to_string()
}
}
impl ToString for ListInvoicesParameters {
fn to_string(&self) -> String {
let mut params = Vec::new();
if !self.location_id.is_empty() {
params.push(format!("location_id={}", &self.location_id));
}
if let Some(cursor) = &self.cursor {
params.push(format!("cursor={}", cursor));
}
if let Some(limit) = self.limit {
params.push(format!("limit={}", limit));
}
if params.is_empty() {
String::new()
} else {
format!("?{}", params.join("&"))
}
}
}