plaid/request/
deposit_switch_alt_create.rs1use crate::FluentRequest;
2use serde::{Serialize, Deserialize};
3use httpclient::InMemoryResponseExt;
4use crate::model::{
5 DepositSwitchCreateRequestOptions, DepositSwitchTargetAccount,
6 DepositSwitchTargetUser,
7};
8#[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 pub fn country_code(mut self, country_code: &str) -> Self {
21 self.params.country_code = Some(country_code.to_owned());
22 self
23 }
24 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 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}