harvest_api/request/
retrieve_time_entry.rs1use serde_json::json;
2use crate::model::*;
3use crate::HarvestClient;
4pub struct RetrieveTimeEntryRequest<'a> {
8 pub(crate) client: &'a HarvestClient,
9 pub time_entry_id: String,
10}
11impl<'a> RetrieveTimeEntryRequest<'a> {
12 pub async fn send(self) -> anyhow::Result<TimeEntry> {
13 let mut r = self
14 .client
15 .client
16 .get(
17 &format!(
18 "/time_entries/{time_entry_id}", time_entry_id = self.time_entry_id
19 ),
20 );
21 r = self.client.authenticate(r);
22 let res = r.send().await.unwrap().error_for_status();
23 match res {
24 Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
25 Err(res) => {
26 let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
27 Err(anyhow::anyhow!("{:?}", text))
28 }
29 }
30 }
31}