harvest_api/request/
delete_invoice_message.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 DeleteInvoiceMessageRequest<'a> {
8    pub(crate) client: &'a HarvestClient,
9    pub invoice_id: String,
10    pub message_id: String,
11}
12impl<'a> DeleteInvoiceMessageRequest<'a> {
13    pub async fn send(self) -> anyhow::Result<()> {
14        let mut r = self
15            .client
16            .client
17            .delete(
18                &format!(
19                    "/invoices/{invoice_id}/messages/{message_id}", invoice_id = self
20                    .invoice_id, message_id = self.message_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) => Ok(()),
27            Err(res) => {
28                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
29                Err(anyhow::anyhow!("{:?}", text))
30            }
31        }
32    }
33}