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