harvest_api/request/
project_budget_report.rs

1use serde_json::json;
2use crate::model::*;
3use crate::HarvestClient;
4/**Create this with the associated client method.
5
6That method takes required values as arguments. Set optional values using builder methods on this struct.*/
7pub struct ProjectBudgetReportRequest<'a> {
8    pub(crate) client: &'a HarvestClient,
9    pub page: Option<i64>,
10    pub per_page: Option<i64>,
11    pub is_active: Option<bool>,
12}
13impl<'a> ProjectBudgetReportRequest<'a> {
14    pub async fn send(self) -> anyhow::Result<ProjectBudgetReportResults> {
15        let mut r = self.client.client.get("/reports/project_budget");
16        if let Some(ref unwrapped) = self.page {
17            r = r.push_query("page", &unwrapped.to_string());
18        }
19        if let Some(ref unwrapped) = self.per_page {
20            r = r.push_query("per_page", &unwrapped.to_string());
21        }
22        if let Some(ref unwrapped) = self.is_active {
23            r = r.push_query("is_active", &unwrapped.to_string());
24        }
25        r = self.client.authenticate(r);
26        let res = r.send().await.unwrap().error_for_status();
27        match res {
28            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
29            Err(res) => {
30                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
31                Err(anyhow::anyhow!("{:?}", text))
32            }
33        }
34    }
35    pub fn page(mut self, page: i64) -> Self {
36        self.page = Some(page);
37        self
38    }
39    pub fn per_page(mut self, per_page: i64) -> Self {
40        self.per_page = Some(per_page);
41        self
42    }
43    pub fn is_active(mut self, is_active: bool) -> Self {
44        self.is_active = Some(is_active);
45        self
46    }
47}