use crate::model::frequency::Frequency; use serde::{Deserialize, Serialize}; #[derive(Deserialize, Serialize, Clone)] pub struct Payments { pub page: Option, pub search: Option, pub frequency: Option, pub highlight: Option, } 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)), }; match q.search { Some(s) => { if !s.is_empty() { params.push(format!("search={}", s)); } } _ => (), }; match q.frequency { Some(Frequency::Monthly) => { params.push("frequency=Monthly".to_string()) } _ => (), }; match q.highlight { Some(id) => params.push(format!("highlight={}", id)), _ => (), }; if params.is_empty() { "".to_string() } else { format!("?{}", params.join("&")) } } #[derive(Deserialize, Serialize, Clone)] pub struct Incomes { pub page: Option, pub highlight: Option, } #[derive(Deserialize, Serialize, Clone)] pub struct Categories { pub highlight: Option, } #[derive(Deserialize, Serialize)] pub struct PaymentCategory { pub payment_name: String, }