use crate::FluentRequest;
use serde::{Serialize, Deserialize};
use httpclient::InMemoryResponseExt;
use crate::model::{
IdentityVerificationRetryRequestStepsObject, Strategy,
IdentityVerificationRequestUser,
};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IdentityVerificationRetryRequest {
pub client_user_id: String,
pub is_shareable: Option<bool>,
pub steps: Option<IdentityVerificationRetryRequestStepsObject>,
pub strategy: Strategy,
pub template_id: String,
pub user: Option<IdentityVerificationRequestUser>,
}
impl FluentRequest<'_, IdentityVerificationRetryRequest> {
pub fn is_shareable(mut self, is_shareable: bool) -> Self {
self.params.is_shareable = Some(is_shareable);
self
}
pub fn steps(mut self, steps: IdentityVerificationRetryRequestStepsObject) -> Self {
self.params.steps = Some(steps);
self
}
pub fn user(mut self, user: IdentityVerificationRequestUser) -> Self {
self.params.user = Some(user);
self
}
}
impl<'a> ::std::future::IntoFuture
for FluentRequest<'a, IdentityVerificationRetryRequest> {
type Output = httpclient::InMemoryResult<
crate::model::IdentityVerificationRetryResponse,
>;
type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let url = "/identity_verification/retry";
let mut r = self.client.client.post(url);
r = r
.json(
serde_json::json!({ "client_user_id" : self.params.client_user_id }),
);
if let Some(ref unwrapped) = self.params.is_shareable {
r = r.json(serde_json::json!({ "is_shareable" : unwrapped }));
}
if let Some(ref unwrapped) = self.params.steps {
r = r.json(serde_json::json!({ "steps" : unwrapped }));
}
r = r.json(serde_json::json!({ "strategy" : self.params.strategy }));
r = r.json(serde_json::json!({ "template_id" : self.params.template_id }));
if let Some(ref unwrapped) = self.params.user {
r = r.json(serde_json::json!({ "user" : unwrapped }));
}
r = self.client.authenticate(r);
let res = r.await?;
res.json().map_err(Into::into)
})
}
}
impl crate::PlaidClient {
pub fn identity_verification_retry(
&self,
client_user_id: &str,
strategy: Strategy,
template_id: &str,
) -> FluentRequest<'_, IdentityVerificationRetryRequest> {
FluentRequest {
client: self,
params: IdentityVerificationRetryRequest {
client_user_id: client_user_id.to_owned(),
is_shareable: None,
steps: None,
strategy,
template_id: template_id.to_owned(),
user: None,
},
}
}
}