plaid/request/
statements_download.rs

1use crate::FluentRequest;
2use serde::{Serialize, Deserialize};
3use httpclient::InMemoryResponseExt;
4/**You should use this struct via [`PlaidClient::statements_download`].
5
6On request success, this will return a [`String`].*/
7#[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    /**Retrieve a single statement.
30
31The `/statements/download` endpoint retrieves a single statement PDF in binary format.  The response will contain a `Plaid-Content-Hash` header containing a SHA 256 checksum of the statement. This can be used to verify that the file being sent by Plaid is the same file that was downloaded to your system.
32
33See endpoint docs at <https://plaid.com/docs/api/products/statements#statementsdownload>.*/
34    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}