use crate::FluentRequest;
use serde::{Serialize, Deserialize};
use httpclient::InMemoryResponseExt;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserThirdPartyTokenCreateRequest {
pub expiration_time: Option<chrono::DateTime<chrono::Utc>>,
pub third_party_client_id: String,
pub user_token: String,
}
impl FluentRequest<'_, UserThirdPartyTokenCreateRequest> {
pub fn expiration_time(
mut self,
expiration_time: chrono::DateTime<chrono::Utc>,
) -> Self {
self.params.expiration_time = Some(expiration_time);
self
}
}
impl<'a> ::std::future::IntoFuture
for FluentRequest<'a, UserThirdPartyTokenCreateRequest> {
type Output = httpclient::InMemoryResult<
crate::model::UserThirdPartyTokenCreateResponse,
>;
type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let url = "/user/third_party_token/create";
let mut r = self.client.client.post(url);
if let Some(ref unwrapped) = self.params.expiration_time {
r = r.json(serde_json::json!({ "expiration_time" : unwrapped }));
}
r = r
.json(
serde_json::json!(
{ "third_party_client_id" : self.params.third_party_client_id }
),
);
r = r.json(serde_json::json!({ "user_token" : self.params.user_token }));
r = self.client.authenticate(r);
let res = r.await?;
res.json().map_err(Into::into)
})
}
}
impl crate::PlaidClient {
pub fn user_third_party_token_create(
&self,
third_party_client_id: &str,
user_token: &str,
) -> FluentRequest<'_, UserThirdPartyTokenCreateRequest> {
FluentRequest {
client: self,
params: UserThirdPartyTokenCreateRequest {
expiration_time: None,
third_party_client_id: third_party_client_id.to_owned(),
user_token: user_token.to_owned(),
},
}
}
}