use crate::FluentRequest;
use serde::{Serialize, Deserialize};
use httpclient::InMemoryResponseExt;
/**You should use this struct via [`PlaidClient::bank_transfer_migrate_account`].
On request success, this will return a [`BankTransferMigrateAccountResponse`].*/
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BankTransferMigrateAccountRequest {
pub account_number: String,
pub account_type: String,
pub routing_number: String,
pub wire_routing_number: Option<String>,
}
impl FluentRequest<'_, BankTransferMigrateAccountRequest> {
///Set the value of the wire_routing_number field.
pub fn wire_routing_number(mut self, wire_routing_number: &str) -> Self {
self.params.wire_routing_number = Some(wire_routing_number.to_owned());
self
}
}
impl<'a> ::std::future::IntoFuture
for FluentRequest<'a, BankTransferMigrateAccountRequest> {
type Output = httpclient::InMemoryResult<
crate::model::BankTransferMigrateAccountResponse,
>;
type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let url = "/bank_transfer/migrate_account";
let mut r = self.client.client.post(url);
r = r
.json(
serde_json::json!({ "account_number" : self.params.account_number }),
);
r = r.json(serde_json::json!({ "account_type" : self.params.account_type }));
r = r
.json(
serde_json::json!({ "routing_number" : self.params.routing_number }),
);
if let Some(ref unwrapped) = self.params.wire_routing_number {
r = r.json(serde_json::json!({ "wire_routing_number" : unwrapped }));
}
r = self.client.authenticate(r);
let res = r.await?;
res.json().map_err(Into::into)
})
}
}
impl crate::PlaidClient {
/**Migrate account into Bank Transfers
As an alternative to adding Items via Link, you can also use the `/bank_transfer/migrate_account` endpoint to migrate known account and routing numbers to Plaid Items. Note that Items created in this way are not compatible with endpoints for other products, such as `/accounts/balance/get`, and can only be used with Bank Transfer endpoints. If you require access to other endpoints, create the Item through Link instead. Access to `/bank_transfer/migrate_account` is not enabled by default; to obtain access, contact your Plaid Account Manager.
See endpoint docs at <https://plaid.com/docs/bank-transfers/reference#bank_transfermigrate_account>.*/
pub fn bank_transfer_migrate_account(
&self,
account_number: &str,
account_type: &str,
routing_number: &str,
) -> FluentRequest<'_, BankTransferMigrateAccountRequest> {
FluentRequest {
client: self,
params: BankTransferMigrateAccountRequest {
account_number: account_number.to_owned(),
account_type: account_type.to_owned(),
routing_number: routing_number.to_owned(),
wire_routing_number: None,
},
}
}
}