plaid/request/
deposit_switch_alt_create.rs

1use crate::FluentRequest;
2use serde::{Serialize, Deserialize};
3use httpclient::InMemoryResponseExt;
4use crate::model::{
5    DepositSwitchCreateRequestOptions, DepositSwitchTargetAccount,
6    DepositSwitchTargetUser,
7};
8/**You should use this struct via [`PlaidClient::deposit_switch_alt_create`].
9
10On request success, this will return a [`DepositSwitchAltCreateResponse`].*/
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct DepositSwitchAltCreateRequest {
13    pub country_code: Option<String>,
14    pub options: Option<DepositSwitchCreateRequestOptions>,
15    pub target_account: DepositSwitchTargetAccount,
16    pub target_user: DepositSwitchTargetUser,
17}
18impl FluentRequest<'_, DepositSwitchAltCreateRequest> {
19    ///Set the value of the country_code field.
20    pub fn country_code(mut self, country_code: &str) -> Self {
21        self.params.country_code = Some(country_code.to_owned());
22        self
23    }
24    ///Set the value of the options field.
25    pub fn options(mut self, options: DepositSwitchCreateRequestOptions) -> Self {
26        self.params.options = Some(options);
27        self
28    }
29}
30impl<'a> ::std::future::IntoFuture for FluentRequest<'a, DepositSwitchAltCreateRequest> {
31    type Output = httpclient::InMemoryResult<
32        crate::model::DepositSwitchAltCreateResponse,
33    >;
34    type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
35    fn into_future(self) -> Self::IntoFuture {
36        Box::pin(async move {
37            let url = "/deposit_switch/alt/create";
38            let mut r = self.client.client.post(url);
39            if let Some(ref unwrapped) = self.params.country_code {
40                r = r.json(serde_json::json!({ "country_code" : unwrapped }));
41            }
42            if let Some(ref unwrapped) = self.params.options {
43                r = r.json(serde_json::json!({ "options" : unwrapped }));
44            }
45            r = r
46                .json(
47                    serde_json::json!({ "target_account" : self.params.target_account }),
48                );
49            r = r.json(serde_json::json!({ "target_user" : self.params.target_user }));
50            r = self.client.authenticate(r);
51            let res = r.await?;
52            res.json().map_err(Into::into)
53        })
54    }
55}
56impl crate::PlaidClient {
57    /**(Deprecated) Create a deposit switch without using Plaid Exchange
58
59This endpoint provides an alternative to `/deposit_switch/create` for customers who have not yet fully integrated with Plaid Exchange. Like `/deposit_switch/create`, it creates a deposit switch entity that will be persisted throughout the lifecycle of the switch.
60
61See endpoint docs at <https://plaid.com/docs/deposit-switch/reference#deposit_switchaltcreate>.*/
62    pub fn deposit_switch_alt_create(
63        &self,
64        target_account: DepositSwitchTargetAccount,
65        target_user: DepositSwitchTargetUser,
66    ) -> FluentRequest<'_, DepositSwitchAltCreateRequest> {
67        FluentRequest {
68            client: self,
69            params: DepositSwitchAltCreateRequest {
70                country_code: None,
71                options: None,
72                target_account,
73                target_user,
74            },
75        }
76    }
77}