use crate::FluentRequest;
use serde::{Serialize, Deserialize};
use httpclient::InMemoryResponseExt;
use crate::model::{TransferLedgerSweepSimulateEventType, TransferFailure};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SandboxTransferLedgerDepositSimulateRequest {
pub event_type: TransferLedgerSweepSimulateEventType,
pub failure_reason: Option<TransferFailure>,
pub sweep_id: String,
}
impl FluentRequest<'_, SandboxTransferLedgerDepositSimulateRequest> {
pub fn failure_reason(mut self, failure_reason: TransferFailure) -> Self {
self.params.failure_reason = Some(failure_reason);
self
}
}
impl<'a> ::std::future::IntoFuture
for FluentRequest<'a, SandboxTransferLedgerDepositSimulateRequest> {
type Output = httpclient::InMemoryResult<
crate::model::SandboxTransferLedgerDepositSimulateResponse,
>;
type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let url = "/sandbox/transfer/ledger/deposit/simulate";
let mut r = self.client.client.post(url);
r = r.json(serde_json::json!({ "event_type" : self.params.event_type }));
if let Some(ref unwrapped) = self.params.failure_reason {
r = r.json(serde_json::json!({ "failure_reason" : unwrapped }));
}
r = r.json(serde_json::json!({ "sweep_id" : self.params.sweep_id }));
r = self.client.authenticate(r);
let res = r.await?;
res.json().map_err(Into::into)
})
}
}
impl crate::PlaidClient {
pub fn sandbox_transfer_ledger_deposit_simulate(
&self,
event_type: TransferLedgerSweepSimulateEventType,
sweep_id: &str,
) -> FluentRequest<'_, SandboxTransferLedgerDepositSimulateRequest> {
FluentRequest {
client: self,
params: SandboxTransferLedgerDepositSimulateRequest {
event_type,
failure_reason: None,
sweep_id: sweep_id.to_owned(),
},
}
}
}