noah_sdk/api/
onboarding.rs1use crate::client::NoahClient;
4use crate::error::Result;
5use crate::models::common::*;
6use crate::models::onboarding::{
7 HostedOnboardingRequest, HostedSessionResponse, PrefillDocumentUploadURLResponse,
8};
9use serde::Serialize;
10
11#[derive(Debug, Clone, Serialize)]
13#[serde(untagged)]
14pub enum PrefillOnboardingRequest {
15 SumSubToken {
17 #[serde(rename = "Type")]
19 request_type: String,
20 #[serde(rename = "Token")]
22 token: String,
23 },
24 BusinessCustomerPrefill(serde_json::Value),
26 IndividualCustomerPrefill(serde_json::Value),
28}
29
30impl NoahClient {
31 #[cfg(feature = "async")]
33 pub async fn create_onboarding_session(
34 &self,
35 customer_id: &CustomerID,
36 request: &HostedOnboardingRequest,
37 ) -> Result<HostedSessionResponse> {
38 let path = format!("/onboarding/{customer_id}");
39 self.post(&path, request).await
40 }
41
42 #[cfg(feature = "sync")]
44 pub fn create_onboarding_session_blocking(
45 &self,
46 customer_id: &CustomerID,
47 request: &HostedOnboardingRequest,
48 ) -> Result<HostedSessionResponse> {
49 let path = format!("/onboarding/{customer_id}");
50 self.post_blocking(&path, request)
51 }
52
53 #[cfg(feature = "async")]
55 pub async fn prefill_onboarding(
56 &self,
57 customer_id: &CustomerID,
58 request: &PrefillOnboardingRequest,
59 ) -> Result<()> {
60 let path = format!("/onboarding/{customer_id}/prefill");
61 let _response: Option<serde_json::Value> = self.post(&path, request).await?;
62 Ok(())
63 }
64
65 #[cfg(feature = "sync")]
67 pub fn prefill_onboarding_blocking(
68 &self,
69 customer_id: &CustomerID,
70 request: &PrefillOnboardingRequest,
71 ) -> Result<()> {
72 let path = format!("/onboarding/{customer_id}/prefill");
73 let _response: Option<serde_json::Value> = self.post_blocking(&path, request)?;
74 Ok(())
75 }
76
77 #[cfg(feature = "async")]
79 pub async fn get_document_upload_url(
80 &self,
81 customer_id: &CustomerID,
82 document_type: &str,
83 country_code: &CountryCode,
84 side: Option<&str>,
85 associate_id: Option<&str>,
86 ) -> Result<PrefillDocumentUploadURLResponse> {
87 let mut path = format!("/onboarding/{customer_id}/prefill/documents/upload-url");
88 let mut query_params = vec![
89 format!("Type={document_type}"),
90 format!("CountryCode={country_code}"),
91 ];
92
93 if let Some(s) = side {
94 query_params.push(format!("Side={s}"));
95 }
96 if let Some(aid) = associate_id {
97 query_params.push(format!("AssociateID={aid}"));
98 }
99
100 path.push('?');
101 path.push_str(&query_params.join("&"));
102
103 self.get(&path).await
104 }
105
106 #[cfg(feature = "sync")]
108 pub fn get_document_upload_url_blocking(
109 &self,
110 customer_id: &CustomerID,
111 document_type: &str,
112 country_code: &CountryCode,
113 side: Option<&str>,
114 associate_id: Option<&str>,
115 ) -> Result<PrefillDocumentUploadURLResponse> {
116 let mut path = format!("/onboarding/{customer_id}/prefill/documents/upload-url");
117 let mut query_params = vec![
118 format!("Type={document_type}"),
119 format!("CountryCode={country_code}"),
120 ];
121
122 if let Some(s) = side {
123 query_params.push(format!("Side={s}"));
124 }
125 if let Some(aid) = associate_id {
126 query_params.push(format!("AssociateID={aid}"));
127 }
128
129 path.push('?');
130 path.push_str(&query_params.join("&"));
131
132 self.get_blocking(&path)
133 }
134}