use crate::FluentRequest;
use serde::{Serialize, Deserialize};
use httpclient::InMemoryResponseExt;
use crate::model::IdentityVerificationCreateRequestUser;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IdentityVerificationCreateRequest {
pub client_user_id: Option<String>,
pub gave_consent: bool,
pub is_idempotent: Option<bool>,
pub is_shareable: bool,
pub template_id: String,
pub user: Option<IdentityVerificationCreateRequestUser>,
}
impl FluentRequest<'_, IdentityVerificationCreateRequest> {
pub fn client_user_id(mut self, client_user_id: &str) -> Self {
self.params.client_user_id = Some(client_user_id.to_owned());
self
}
pub fn is_idempotent(mut self, is_idempotent: bool) -> Self {
self.params.is_idempotent = Some(is_idempotent);
self
}
pub fn user(mut self, user: IdentityVerificationCreateRequestUser) -> Self {
self.params.user = Some(user);
self
}
}
impl<'a> ::std::future::IntoFuture
for FluentRequest<'a, IdentityVerificationCreateRequest> {
type Output = httpclient::InMemoryResult<
crate::model::IdentityVerificationCreateResponse,
>;
type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let url = "/identity_verification/create";
let mut r = self.client.client.post(url);
if let Some(ref unwrapped) = self.params.client_user_id {
r = r.json(serde_json::json!({ "client_user_id" : unwrapped }));
}
r = r.json(serde_json::json!({ "gave_consent" : self.params.gave_consent }));
if let Some(ref unwrapped) = self.params.is_idempotent {
r = r.json(serde_json::json!({ "is_idempotent" : unwrapped }));
}
r = r.json(serde_json::json!({ "is_shareable" : self.params.is_shareable }));
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_create(
&self,
gave_consent: bool,
is_shareable: bool,
template_id: &str,
) -> FluentRequest<'_, IdentityVerificationCreateRequest> {
FluentRequest {
client: self,
params: IdentityVerificationCreateRequest {
client_user_id: None,
gave_consent,
is_idempotent: None,
is_shareable,
template_id: template_id.to_owned(),
user: None,
},
}
}
}