plaid/request/
payment_initiation_consent_payment_execute.rs1use crate::FluentRequest;
2use serde::{Serialize, Deserialize};
3use httpclient::InMemoryResponseExt;
4use crate::model::{PaymentAmount, PaymentInitiationConsentProcessingMode};
5#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct PaymentInitiationConsentPaymentExecuteRequest {
10 pub amount: PaymentAmount,
11 pub consent_id: String,
12 pub idempotency_key: String,
13 pub processing_mode: Option<PaymentInitiationConsentProcessingMode>,
14 pub reference: Option<String>,
15 pub scope: Option<serde_json::Value>,
16}
17impl FluentRequest<'_, PaymentInitiationConsentPaymentExecuteRequest> {
18 pub fn processing_mode(
20 mut self,
21 processing_mode: PaymentInitiationConsentProcessingMode,
22 ) -> Self {
23 self.params.processing_mode = Some(processing_mode);
24 self
25 }
26 pub fn reference(mut self, reference: &str) -> Self {
28 self.params.reference = Some(reference.to_owned());
29 self
30 }
31 pub fn scope(mut self, scope: serde_json::Value) -> Self {
33 self.params.scope = Some(scope);
34 self
35 }
36}
37impl<'a> ::std::future::IntoFuture
38for FluentRequest<'a, PaymentInitiationConsentPaymentExecuteRequest> {
39 type Output = httpclient::InMemoryResult<
40 crate::model::PaymentInitiationConsentPaymentExecuteResponse,
41 >;
42 type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
43 fn into_future(self) -> Self::IntoFuture {
44 Box::pin(async move {
45 let url = "/payment_initiation/consent/payment/execute";
46 let mut r = self.client.client.post(url);
47 r = r.json(serde_json::json!({ "amount" : self.params.amount }));
48 r = r.json(serde_json::json!({ "consent_id" : self.params.consent_id }));
49 r = r
50 .json(
51 serde_json::json!(
52 { "idempotency_key" : self.params.idempotency_key }
53 ),
54 );
55 if let Some(ref unwrapped) = self.params.processing_mode {
56 r = r.json(serde_json::json!({ "processing_mode" : unwrapped }));
57 }
58 if let Some(ref unwrapped) = self.params.reference {
59 r = r.json(serde_json::json!({ "reference" : unwrapped }));
60 }
61 if let Some(ref unwrapped) = self.params.scope {
62 r = r.json(serde_json::json!({ "scope" : unwrapped }));
63 }
64 r = self.client.authenticate(r);
65 let res = r.await?;
66 res.json().map_err(Into::into)
67 })
68 }
69}
70impl crate::PlaidClient {
71 pub fn payment_initiation_consent_payment_execute(
77 &self,
78 amount: PaymentAmount,
79 consent_id: &str,
80 idempotency_key: &str,
81 ) -> FluentRequest<'_, PaymentInitiationConsentPaymentExecuteRequest> {
82 FluentRequest {
83 client: self,
84 params: PaymentInitiationConsentPaymentExecuteRequest {
85 amount,
86 consent_id: consent_id.to_owned(),
87 idempotency_key: idempotency_key.to_owned(),
88 processing_mode: None,
89 reference: None,
90 scope: None,
91 },
92 }
93 }
94}