use crate::FluentRequest;
use serde::{Serialize, Deserialize};
use httpclient::InMemoryResponseExt;
use crate::model::{CountryCode, InstitutionsGetRequestOptions};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InstitutionsGetRequest {
pub count: i64,
pub country_codes: Vec<CountryCode>,
pub offset: i64,
pub options: Option<InstitutionsGetRequestOptions>,
}
impl FluentRequest<'_, InstitutionsGetRequest> {
pub fn options(mut self, options: InstitutionsGetRequestOptions) -> Self {
self.params.options = Some(options);
self
}
}
impl<'a> ::std::future::IntoFuture for FluentRequest<'a, InstitutionsGetRequest> {
type Output = httpclient::InMemoryResult<crate::model::InstitutionsGetResponse>;
type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let url = "/institutions/get";
let mut r = self.client.client.post(url);
r = r.json(serde_json::json!({ "count" : self.params.count }));
r = r
.json(
serde_json::json!({ "country_codes" : self.params.country_codes }),
);
r = r.json(serde_json::json!({ "offset" : self.params.offset }));
if let Some(ref unwrapped) = self.params.options {
r = r.json(serde_json::json!({ "options" : unwrapped }));
}
r = self.client.authenticate(r);
let res = r.await?;
res.json().map_err(Into::into)
})
}
}
impl crate::PlaidClient {
pub fn institutions_get(
&self,
count: i64,
country_codes: Vec<CountryCode>,
offset: i64,
) -> FluentRequest<'_, InstitutionsGetRequest> {
FluentRequest {
client: self,
params: InstitutionsGetRequest {
count,
country_codes,
offset,
options: None,
},
}
}
}