From 6e695bf7a0253b4f6d1db78fa4310616d8a1357f Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 10 Oct 2021 19:27:22 +0200 Subject: Search by name, cost and user --- src/queries.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/queries.rs') diff --git a/src/queries.rs b/src/queries.rs index df57bd8..f10c7a1 100644 --- a/src/queries.rs +++ b/src/queries.rs @@ -4,9 +4,11 @@ use serde::{Deserialize, Serialize}; #[derive(Deserialize, Serialize, Clone)] pub struct Payments { pub page: Option, - pub search: Option, + pub name: Option, + pub cost: Option, pub frequency: Option, pub highlight: Option, + pub user: Option, pub category: Option, } @@ -18,15 +20,6 @@ pub fn payments_url(q: Payments) -> String { 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()) @@ -39,6 +32,21 @@ pub fn payments_url(q: Payments) -> String { _ => (), }; + match q.name { + Some(str) => params.push(format!("name={}", str)), + _ => (), + }; + + match q.cost { + Some(n) => params.push(format!("cost={}", n)), + _ => (), + }; + + match q.user { + Some(id) => params.push(format!("user={}", id)), + _ => (), + }; + match q.category { Some(id) => params.push(format!("category={}", id)), _ => (), -- cgit v1.2.3