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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
use crate::model::frequency::Frequency;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize, Clone)]
pub struct Payments {
pub page: Option<i64>,
pub name: Option<String>,
pub cost: Option<String>,
pub frequency: Option<Frequency>,
pub highlight: Option<i64>,
pub user: Option<i64>,
pub category: Option<i64>,
pub start_date: Option<String>,
pub end_date: Option<String>,
}
pub fn payments_url(q: Payments) -> String {
let mut params = Vec::new();
match q.page {
None | Some(1) => (),
Some(p) => params.push(format!("page={}", p)),
};
if let Some(Frequency::Monthly) = q.frequency {
params.push("frequency=Monthly".to_string())
};
if let Some(id) = q.highlight {
params.push(format!("highlight={}", id))
};
if let Some(str) = q.name {
if !str.is_empty() {
params.push(format!("name={}", str))
}
};
if let Some(str) = q.cost {
if !str.is_empty() {
params.push(format!("cost={}", str))
}
};
if let Some(id) = q.user {
params.push(format!("user={}", id))
};
if let Some(id) = q.category {
params.push(format!("category={}", id))
};
if let Some(str) = q.start_date {
if !str.is_empty() {
params.push(format!("start_date={}", str))
}
};
if let Some(str) = q.end_date {
if !str.is_empty() {
params.push(format!("end_date={}", str))
}
};
if params.is_empty() {
"".to_string()
} else {
format!("?{}", params.join("&"))
}
}
#[derive(Deserialize, Serialize, Clone)]
pub struct Incomes {
pub page: Option<i64>,
pub highlight: Option<i64>,
}
#[derive(Deserialize, Serialize, Clone)]
pub struct Categories {
pub highlight: Option<i64>,
}
#[derive(Deserialize, Serialize)]
pub struct PaymentCategory {
pub payment_name: String,
}
|