plaid/request/
statements_download.rs1use crate::FluentRequest;
2use serde::{Serialize, Deserialize};
3use httpclient::InMemoryResponseExt;
4#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct StatementsDownloadRequest {
9 pub access_token: String,
10 pub statement_id: String,
11}
12impl FluentRequest<'_, StatementsDownloadRequest> {}
13impl<'a> ::std::future::IntoFuture for FluentRequest<'a, StatementsDownloadRequest> {
14 type Output = httpclient::InMemoryResult<String>;
15 type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
16 fn into_future(self) -> Self::IntoFuture {
17 Box::pin(async move {
18 let url = "/statements/download";
19 let mut r = self.client.client.post(url);
20 r = r.json(serde_json::json!({ "access_token" : self.params.access_token }));
21 r = r.json(serde_json::json!({ "statement_id" : self.params.statement_id }));
22 r = self.client.authenticate(r);
23 let res = r.await?;
24 res.json().map_err(Into::into)
25 })
26 }
27}
28impl crate::PlaidClient {
29 pub fn statements_download(
35 &self,
36 access_token: &str,
37 statement_id: &str,
38 ) -> FluentRequest<'_, StatementsDownloadRequest> {
39 FluentRequest {
40 client: self,
41 params: StatementsDownloadRequest {
42 access_token: access_token.to_owned(),
43 statement_id: statement_id.to_owned(),
44 },
45 }
46 }
47}