harvest_api/request/
retrieve_billable_rate.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 RetrieveBillableRateRequest<'a> {
8    pub(crate) client: &'a HarvestClient,
9    pub user_id: String,
10    pub billable_rate_id: String,
11}
12impl<'a> RetrieveBillableRateRequest<'a> {
13    pub async fn send(self) -> anyhow::Result<BillableRate> {
14        let mut r = self
15            .client
16            .client
17            .get(
18                &format!(
19                    "/users/{user_id}/billable_rates/{billable_rate_id}", user_id = self
20                    .user_id, billable_rate_id = self.billable_rate_id
21                ),
22            );
23        r = self.client.authenticate(r);
24        let res = r.send().await.unwrap().error_for_status();
25        match res {
26            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
27            Err(res) => {
28                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
29                Err(anyhow::anyhow!("{:?}", text))
30            }
31        }
32    }
33}