print_nanny_client/apis/
auth_api.rs1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AuthEmailCreateError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum AuthMobileCreateError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum AuthTokenCreateError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum AuthVerifyCreateError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum AuthVerifyEmailCreateError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum AuthVerifyMobileCreateError {
57 UnknownValue(serde_json::Value),
58}
59
60
61pub async fn auth_email_create(configuration: &configuration::Configuration, email_auth_request: crate::models::EmailAuthRequest) -> Result<crate::models::DetailResponse, Error<AuthEmailCreateError>> {
63 let local_var_configuration = configuration;
64
65 let local_var_client = &local_var_configuration.client;
66
67 let local_var_uri_str = format!("{}/auth/email/", local_var_configuration.base_path);
68 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
69
70 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
71 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
72 }
73 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
74 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
75 };
76 local_var_req_builder = local_var_req_builder.json(&email_auth_request);
77
78 let local_var_req = local_var_req_builder.build()?;
79 let local_var_resp = local_var_client.execute(local_var_req).await?;
80
81 let local_var_status = local_var_resp.status();
82 let local_var_content = local_var_resp.text().await?;
83
84 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
85 serde_json::from_str(&local_var_content).map_err(Error::from)
86 } else {
87 let local_var_entity: Option<AuthEmailCreateError> = serde_json::from_str(&local_var_content).ok();
88 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
89 Err(Error::ResponseError(local_var_error))
90 }
91}
92
93pub async fn auth_mobile_create(configuration: &configuration::Configuration, mobile_auth_request: crate::models::MobileAuthRequest) -> Result<crate::models::DetailResponse, Error<AuthMobileCreateError>> {
95 let local_var_configuration = configuration;
96
97 let local_var_client = &local_var_configuration.client;
98
99 let local_var_uri_str = format!("{}/auth/mobile/", local_var_configuration.base_path);
100 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
101
102 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
103 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
104 }
105 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
106 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
107 };
108 local_var_req_builder = local_var_req_builder.json(&mobile_auth_request);
109
110 let local_var_req = local_var_req_builder.build()?;
111 let local_var_resp = local_var_client.execute(local_var_req).await?;
112
113 let local_var_status = local_var_resp.status();
114 let local_var_content = local_var_resp.text().await?;
115
116 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
117 serde_json::from_str(&local_var_content).map_err(Error::from)
118 } else {
119 let local_var_entity: Option<AuthMobileCreateError> = serde_json::from_str(&local_var_content).ok();
120 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
121 Err(Error::ResponseError(local_var_error))
122 }
123}
124
125pub async fn auth_token_create(configuration: &configuration::Configuration, callback_token_auth_request: crate::models::CallbackTokenAuthRequest) -> Result<crate::models::TokenResponse, Error<AuthTokenCreateError>> {
127 let local_var_configuration = configuration;
128
129 let local_var_client = &local_var_configuration.client;
130
131 let local_var_uri_str = format!("{}/auth/token/", local_var_configuration.base_path);
132 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
133
134 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
135 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
136 }
137 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
138 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
139 };
140 local_var_req_builder = local_var_req_builder.json(&callback_token_auth_request);
141
142 let local_var_req = local_var_req_builder.build()?;
143 let local_var_resp = local_var_client.execute(local_var_req).await?;
144
145 let local_var_status = local_var_resp.status();
146 let local_var_content = local_var_resp.text().await?;
147
148 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
149 serde_json::from_str(&local_var_content).map_err(Error::from)
150 } else {
151 let local_var_entity: Option<AuthTokenCreateError> = serde_json::from_str(&local_var_content).ok();
152 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
153 Err(Error::ResponseError(local_var_error))
154 }
155}
156
157pub async fn auth_verify_create(configuration: &configuration::Configuration, callback_token_verification_request: crate::models::CallbackTokenVerificationRequest) -> Result<crate::models::CallbackTokenVerification, Error<AuthVerifyCreateError>> {
159 let local_var_configuration = configuration;
160
161 let local_var_client = &local_var_configuration.client;
162
163 let local_var_uri_str = format!("{}/auth/verify/", local_var_configuration.base_path);
164 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
165
166 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
167 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
168 }
169 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
170 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
171 };
172 local_var_req_builder = local_var_req_builder.json(&callback_token_verification_request);
173
174 let local_var_req = local_var_req_builder.build()?;
175 let local_var_resp = local_var_client.execute(local_var_req).await?;
176
177 let local_var_status = local_var_resp.status();
178 let local_var_content = local_var_resp.text().await?;
179
180 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
181 serde_json::from_str(&local_var_content).map_err(Error::from)
182 } else {
183 let local_var_entity: Option<AuthVerifyCreateError> = serde_json::from_str(&local_var_content).ok();
184 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
185 Err(Error::ResponseError(local_var_error))
186 }
187}
188
189pub async fn auth_verify_email_create(configuration: &configuration::Configuration, ) -> Result<crate::models::DetailResponse, Error<AuthVerifyEmailCreateError>> {
191 let local_var_configuration = configuration;
192
193 let local_var_client = &local_var_configuration.client;
194
195 let local_var_uri_str = format!("{}/auth/verify/email/", local_var_configuration.base_path);
196 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
197
198 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
199 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
200 }
201 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
202 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
203 };
204
205 let local_var_req = local_var_req_builder.build()?;
206 let local_var_resp = local_var_client.execute(local_var_req).await?;
207
208 let local_var_status = local_var_resp.status();
209 let local_var_content = local_var_resp.text().await?;
210
211 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
212 serde_json::from_str(&local_var_content).map_err(Error::from)
213 } else {
214 let local_var_entity: Option<AuthVerifyEmailCreateError> = serde_json::from_str(&local_var_content).ok();
215 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
216 Err(Error::ResponseError(local_var_error))
217 }
218}
219
220pub async fn auth_verify_mobile_create(configuration: &configuration::Configuration, ) -> Result<crate::models::DetailResponse, Error<AuthVerifyMobileCreateError>> {
222 let local_var_configuration = configuration;
223
224 let local_var_client = &local_var_configuration.client;
225
226 let local_var_uri_str = format!("{}/auth/verify/mobile/", local_var_configuration.base_path);
227 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
228
229 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
230 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
231 }
232 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
233 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
234 };
235
236 let local_var_req = local_var_req_builder.build()?;
237 let local_var_resp = local_var_client.execute(local_var_req).await?;
238
239 let local_var_status = local_var_resp.status();
240 let local_var_content = local_var_resp.text().await?;
241
242 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
243 serde_json::from_str(&local_var_content).map_err(Error::from)
244 } else {
245 let local_var_entity: Option<AuthVerifyMobileCreateError> = serde_json::from_str(&local_var_content).ok();
246 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
247 Err(Error::ResponseError(local_var_error))
248 }
249}
250