harvest_api/request/
retrieve_company.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 RetrieveCompanyRequest<'a> {
8    pub(crate) client: &'a HarvestClient,
9}
10impl<'a> RetrieveCompanyRequest<'a> {
11    pub async fn send(self) -> anyhow::Result<Company> {
12        let mut r = self.client.client.get("/company");
13        r = self.client.authenticate(r);
14        let res = r.send().await.unwrap().error_for_status();
15        match res {
16            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
17            Err(res) => {
18                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
19                Err(anyhow::anyhow!("{:?}", text))
20            }
21        }
22    }
23}