use serde_json::json;
use crate::model::*;
use crate::HarvestClient;
pub struct DeleteInvoicePaymentRequest<'a> {
pub(crate) client: &'a HarvestClient,
pub invoice_id: String,
pub payment_id: String,
}
impl<'a> DeleteInvoicePaymentRequest<'a> {
pub async fn send(self) -> anyhow::Result<()> {
let mut r = self
.client
.client
.delete(
&format!(
"/invoices/{invoice_id}/payments/{payment_id}", invoice_id = self
.invoice_id, payment_id = self.payment_id
),
);
r = self.client.authenticate(r);
let res = r.send().await.unwrap().error_for_status();
match res {
Ok(res) => Ok(()),
Err(res) => {
let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
Err(anyhow::anyhow!("{:?}", text))
}
}
}
}