primer_api/request/
delete_payment_method_payment_methods_token_delete.rs

1use serde_json::json;
2use crate::model::*;
3use crate::PrimerClient;
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 DeletePaymentMethodPaymentMethodsTokenDeleteRequest<'a> {
8    pub(crate) client: &'a PrimerClient,
9    pub payment_method_token: String,
10}
11impl<'a> DeletePaymentMethodPaymentMethodsTokenDeleteRequest<'a> {
12    pub async fn send(
13        self,
14    ) -> anyhow::Result<VerifiedMerchantPaymentMethodTokenApiResponse> {
15        let mut r = self
16            .client
17            .client
18            .delete(
19                &format!(
20                    "/payment-instruments/{payment_method_token}", payment_method_token =
21                    self.payment_method_token
22                ),
23            );
24        r = self.client.authenticate(r);
25        let res = r.send().await.unwrap().error_for_status();
26        match res {
27            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
28            Err(res) => {
29                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
30                Err(anyhow::anyhow!("{:?}", text))
31            }
32        }
33    }
34}