printnanny_api_client/apis/
accounts_api.rs

1/*
2 * printnanny-api-client
3 *
4 * Official API client library for printnanny.ai
5 *
6 * The version of the OpenAPI document: 0.135.1
7 * Contact: leigh@printnanny.ai
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use bytes::Bytes;
15use crate::apis::ResponseContent;
16use super::{Error, configuration};
17
18
19/// struct for typed errors of method [`accounts2fa_auth_email_create`]
20#[derive(Debug, Clone, Serialize, Deserialize)]
21#[serde(untagged)]
22pub enum Accounts2faAuthEmailCreateError {
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`accounts2fa_auth_session_create`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum Accounts2faAuthSessionCreateError {
30    UnknownValue(serde_json::Value),
31}
32
33/// struct for typed errors of method [`accounts2fa_auth_token_create`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum Accounts2faAuthTokenCreateError {
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`accounts_email_waitlist_create`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum AccountsEmailWaitlistCreateError {
44    UnknownValue(serde_json::Value),
45}
46
47/// struct for typed errors of method [`accounts_login_create`]
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum AccountsLoginCreateError {
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`accounts_logout_create`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum AccountsLogoutCreateError {
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`accounts_password_change_create`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum AccountsPasswordChangeCreateError {
65    UnknownValue(serde_json::Value),
66}
67
68/// struct for typed errors of method [`accounts_password_reset_confirm_create`]
69#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum AccountsPasswordResetConfirmCreateError {
72    UnknownValue(serde_json::Value),
73}
74
75/// struct for typed errors of method [`accounts_password_reset_create`]
76#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum AccountsPasswordResetCreateError {
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`accounts_registration_create`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum AccountsRegistrationCreateError {
86    UnknownValue(serde_json::Value),
87}
88
89/// struct for typed errors of method [`accounts_registration_resend_email_create`]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum AccountsRegistrationResendEmailCreateError {
93    UnknownValue(serde_json::Value),
94}
95
96/// struct for typed errors of method [`accounts_registration_verify_email_create`]
97#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum AccountsRegistrationVerifyEmailCreateError {
100    UnknownValue(serde_json::Value),
101}
102
103/// struct for typed errors of method [`accounts_user_nkey_retrieve`]
104#[derive(Debug, Clone, Serialize, Deserialize)]
105#[serde(untagged)]
106pub enum AccountsUserNkeyRetrieveError {
107    UnknownValue(serde_json::Value),
108}
109
110/// struct for typed errors of method [`accounts_user_partial_update`]
111#[derive(Debug, Clone, Serialize, Deserialize)]
112#[serde(untagged)]
113pub enum AccountsUserPartialUpdateError {
114    UnknownValue(serde_json::Value),
115}
116
117/// struct for typed errors of method [`accounts_user_retrieve`]
118#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum AccountsUserRetrieveError {
121    UnknownValue(serde_json::Value),
122}
123
124/// struct for typed errors of method [`accounts_user_update`]
125#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum AccountsUserUpdateError {
128    UnknownValue(serde_json::Value),
129}
130
131
132/// This returns a 6-digit callback token we can trade for a user's Auth Token.
133pub async fn accounts2fa_auth_email_create(configuration: &configuration::Configuration, email_auth_request: crate::models::EmailAuthRequest) -> Result<crate::models::EmailAuth, Error<Accounts2faAuthEmailCreateError>> {
134    let local_var_configuration = configuration;
135
136    let local_var_client = &local_var_configuration.client;
137
138    let local_var_uri_str = format!("{}/accounts/2fa-auth/email/", local_var_configuration.base_path);
139    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
140
141    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
142        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
143    }
144    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
145        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
146    };
147    local_var_req_builder = local_var_req_builder.json(&email_auth_request);
148
149    let local_var_req = local_var_req_builder.build()?;
150    let local_var_resp = local_var_client.execute(local_var_req).await?;
151
152    let local_var_status = local_var_resp.status();
153    let local_var_content = local_var_resp.text().await?;
154
155    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
156        serde_json::from_str(&local_var_content).map_err(Error::from)
157    } else {
158        let local_var_entity: Option<Accounts2faAuthEmailCreateError> = serde_json::from_str(&local_var_content).ok();
159        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
160        Err(Error::ResponseError(local_var_error))
161    }
162}
163
164/// Persist a user id and a backend in the request. This way a user doesn't have to reauthenticate on every request. Note that data set during the anonymous session is retained when the user logs in.
165pub async fn accounts2fa_auth_session_create(configuration: &configuration::Configuration, callback_token_auth_request: crate::models::CallbackTokenAuthRequest) -> Result<crate::models::CallbackTokenAuth, Error<Accounts2faAuthSessionCreateError>> {
166    let local_var_configuration = configuration;
167
168    let local_var_client = &local_var_configuration.client;
169
170    let local_var_uri_str = format!("{}/accounts/2fa-auth/session/", local_var_configuration.base_path);
171    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
172
173    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
174        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
175    }
176    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
177        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
178    };
179    local_var_req_builder = local_var_req_builder.json(&callback_token_auth_request);
180
181    let local_var_req = local_var_req_builder.build()?;
182    let local_var_resp = local_var_client.execute(local_var_req).await?;
183
184    let local_var_status = local_var_resp.status();
185    let local_var_content = local_var_resp.text().await?;
186
187    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
188        serde_json::from_str(&local_var_content).map_err(Error::from)
189    } else {
190        let local_var_entity: Option<Accounts2faAuthSessionCreateError> = serde_json::from_str(&local_var_content).ok();
191        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
192        Err(Error::ResponseError(local_var_error))
193    }
194}
195
196/// This is a duplicate of rest_framework's own ObtainAuthToken method. Instead, this returns an Auth Token based on our callback token and source.
197pub async fn accounts2fa_auth_token_create(configuration: &configuration::Configuration, callback_token_auth_request: crate::models::CallbackTokenAuthRequest) -> Result<crate::models::CallbackTokenAuth, Error<Accounts2faAuthTokenCreateError>> {
198    let local_var_configuration = configuration;
199
200    let local_var_client = &local_var_configuration.client;
201
202    let local_var_uri_str = format!("{}/accounts/2fa-auth/token/", local_var_configuration.base_path);
203    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
204
205    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
206        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
207    }
208    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
209        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
210    };
211    local_var_req_builder = local_var_req_builder.json(&callback_token_auth_request);
212
213    let local_var_req = local_var_req_builder.build()?;
214    let local_var_resp = local_var_client.execute(local_var_req).await?;
215
216    let local_var_status = local_var_resp.status();
217    let local_var_content = local_var_resp.text().await?;
218
219    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
220        serde_json::from_str(&local_var_content).map_err(Error::from)
221    } else {
222        let local_var_entity: Option<Accounts2faAuthTokenCreateError> = serde_json::from_str(&local_var_content).ok();
223        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
224        Err(Error::ResponseError(local_var_error))
225    }
226}
227
228/// A device (Raspberry Pi) running Print Nanny OS
229pub async fn accounts_email_waitlist_create(configuration: &configuration::Configuration, email_waitlist_request: crate::models::EmailWaitlistRequest) -> Result<crate::models::EmailWaitlist, Error<AccountsEmailWaitlistCreateError>> {
230    let local_var_configuration = configuration;
231
232    let local_var_client = &local_var_configuration.client;
233
234    let local_var_uri_str = format!("{}/api/accounts/email-waitlist/", local_var_configuration.base_path);
235    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
236
237    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
238        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
239    }
240    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
241        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
242    };
243    local_var_req_builder = local_var_req_builder.json(&email_waitlist_request);
244
245    let local_var_req = local_var_req_builder.build()?;
246    let local_var_resp = local_var_client.execute(local_var_req).await?;
247
248    let local_var_status = local_var_resp.status();
249    let local_var_content = local_var_resp.text().await?;
250
251    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
252        serde_json::from_str(&local_var_content).map_err(Error::from)
253    } else {
254        let local_var_entity: Option<AccountsEmailWaitlistCreateError> = serde_json::from_str(&local_var_content).ok();
255        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
256        Err(Error::ResponseError(local_var_error))
257    }
258}
259
260/// Check the credentials and return the REST Token if the credentials are valid and authenticated. Calls Django Auth login method to register User ID in Django session framework  Accept the following POST parameters: username, password Return the REST Framework Token Object's key.
261pub async fn accounts_login_create(configuration: &configuration::Configuration, login_request: crate::models::LoginRequest) -> Result<crate::models::Token, Error<AccountsLoginCreateError>> {
262    let local_var_configuration = configuration;
263
264    let local_var_client = &local_var_configuration.client;
265
266    let local_var_uri_str = format!("{}/api/accounts/login/", local_var_configuration.base_path);
267    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
268
269    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
270        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
271    }
272    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
273        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
274    };
275    local_var_req_builder = local_var_req_builder.json(&login_request);
276
277    let local_var_req = local_var_req_builder.build()?;
278    let local_var_resp = local_var_client.execute(local_var_req).await?;
279
280    let local_var_status = local_var_resp.status();
281    let local_var_content = local_var_resp.text().await?;
282
283    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
284        serde_json::from_str(&local_var_content).map_err(Error::from)
285    } else {
286        let local_var_entity: Option<AccountsLoginCreateError> = serde_json::from_str(&local_var_content).ok();
287        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
288        Err(Error::ResponseError(local_var_error))
289    }
290}
291
292/// Calls Django logout method and delete the Token object assigned to the current User object.  Accepts/Returns nothing.
293pub async fn accounts_logout_create(configuration: &configuration::Configuration, ) -> Result<crate::models::RestAuthDetail, Error<AccountsLogoutCreateError>> {
294    let local_var_configuration = configuration;
295
296    let local_var_client = &local_var_configuration.client;
297
298    let local_var_uri_str = format!("{}/api/accounts/logout/", local_var_configuration.base_path);
299    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
300
301    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
302        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
303    }
304    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
305        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
306    };
307
308    let local_var_req = local_var_req_builder.build()?;
309    let local_var_resp = local_var_client.execute(local_var_req).await?;
310
311    let local_var_status = local_var_resp.status();
312    let local_var_content = local_var_resp.text().await?;
313
314    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
315        serde_json::from_str(&local_var_content).map_err(Error::from)
316    } else {
317        let local_var_entity: Option<AccountsLogoutCreateError> = serde_json::from_str(&local_var_content).ok();
318        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
319        Err(Error::ResponseError(local_var_error))
320    }
321}
322
323/// Calls Django Auth SetPasswordForm save method.  Accepts the following POST parameters: new_password1, new_password2 Returns the success/fail message.
324pub async fn accounts_password_change_create(configuration: &configuration::Configuration, password_change_request: crate::models::PasswordChangeRequest) -> Result<crate::models::RestAuthDetail, Error<AccountsPasswordChangeCreateError>> {
325    let local_var_configuration = configuration;
326
327    let local_var_client = &local_var_configuration.client;
328
329    let local_var_uri_str = format!("{}/api/accounts/password/change/", local_var_configuration.base_path);
330    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
331
332    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
333        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
334    }
335    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
336        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
337    };
338    local_var_req_builder = local_var_req_builder.json(&password_change_request);
339
340    let local_var_req = local_var_req_builder.build()?;
341    let local_var_resp = local_var_client.execute(local_var_req).await?;
342
343    let local_var_status = local_var_resp.status();
344    let local_var_content = local_var_resp.text().await?;
345
346    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
347        serde_json::from_str(&local_var_content).map_err(Error::from)
348    } else {
349        let local_var_entity: Option<AccountsPasswordChangeCreateError> = serde_json::from_str(&local_var_content).ok();
350        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
351        Err(Error::ResponseError(local_var_error))
352    }
353}
354
355/// Password reset e-mail link is confirmed, therefore this resets the user's password.  Accepts the following POST parameters: token, uid,     new_password1, new_password2 Returns the success/fail message.
356pub async fn accounts_password_reset_confirm_create(configuration: &configuration::Configuration, password_reset_confirm_request: crate::models::PasswordResetConfirmRequest) -> Result<crate::models::RestAuthDetail, Error<AccountsPasswordResetConfirmCreateError>> {
357    let local_var_configuration = configuration;
358
359    let local_var_client = &local_var_configuration.client;
360
361    let local_var_uri_str = format!("{}/api/accounts/password/reset/confirm/", local_var_configuration.base_path);
362    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
363
364    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
365        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
366    }
367    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
368        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
369    };
370    local_var_req_builder = local_var_req_builder.json(&password_reset_confirm_request);
371
372    let local_var_req = local_var_req_builder.build()?;
373    let local_var_resp = local_var_client.execute(local_var_req).await?;
374
375    let local_var_status = local_var_resp.status();
376    let local_var_content = local_var_resp.text().await?;
377
378    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
379        serde_json::from_str(&local_var_content).map_err(Error::from)
380    } else {
381        let local_var_entity: Option<AccountsPasswordResetConfirmCreateError> = serde_json::from_str(&local_var_content).ok();
382        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
383        Err(Error::ResponseError(local_var_error))
384    }
385}
386
387/// Calls Django Auth PasswordResetForm save method.  Accepts the following POST parameters: email Returns the success/fail message.
388pub async fn accounts_password_reset_create(configuration: &configuration::Configuration, password_reset_request: crate::models::PasswordResetRequest) -> Result<crate::models::RestAuthDetail, Error<AccountsPasswordResetCreateError>> {
389    let local_var_configuration = configuration;
390
391    let local_var_client = &local_var_configuration.client;
392
393    let local_var_uri_str = format!("{}/api/accounts/password/reset/", local_var_configuration.base_path);
394    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
395
396    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
397        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
398    }
399    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
400        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
401    };
402    local_var_req_builder = local_var_req_builder.json(&password_reset_request);
403
404    let local_var_req = local_var_req_builder.build()?;
405    let local_var_resp = local_var_client.execute(local_var_req).await?;
406
407    let local_var_status = local_var_resp.status();
408    let local_var_content = local_var_resp.text().await?;
409
410    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
411        serde_json::from_str(&local_var_content).map_err(Error::from)
412    } else {
413        let local_var_entity: Option<AccountsPasswordResetCreateError> = serde_json::from_str(&local_var_content).ok();
414        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
415        Err(Error::ResponseError(local_var_error))
416    }
417}
418
419pub async fn accounts_registration_create(configuration: &configuration::Configuration, register_request: crate::models::RegisterRequest) -> Result<crate::models::Token, Error<AccountsRegistrationCreateError>> {
420    let local_var_configuration = configuration;
421
422    let local_var_client = &local_var_configuration.client;
423
424    let local_var_uri_str = format!("{}/api/accounts/registration/", local_var_configuration.base_path);
425    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
426
427    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
428        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
429    }
430    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
431        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
432    };
433    local_var_req_builder = local_var_req_builder.json(&register_request);
434
435    let local_var_req = local_var_req_builder.build()?;
436    let local_var_resp = local_var_client.execute(local_var_req).await?;
437
438    let local_var_status = local_var_resp.status();
439    let local_var_content = local_var_resp.text().await?;
440
441    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
442        serde_json::from_str(&local_var_content).map_err(Error::from)
443    } else {
444        let local_var_entity: Option<AccountsRegistrationCreateError> = serde_json::from_str(&local_var_content).ok();
445        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
446        Err(Error::ResponseError(local_var_error))
447    }
448}
449
450pub async fn accounts_registration_resend_email_create(configuration: &configuration::Configuration, resend_email_verification_request: crate::models::ResendEmailVerificationRequest) -> Result<crate::models::RestAuthDetail, Error<AccountsRegistrationResendEmailCreateError>> {
451    let local_var_configuration = configuration;
452
453    let local_var_client = &local_var_configuration.client;
454
455    let local_var_uri_str = format!("{}/api/accounts/registration/resend-email/", local_var_configuration.base_path);
456    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
457
458    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
459        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
460    }
461    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
462        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
463    };
464    local_var_req_builder = local_var_req_builder.json(&resend_email_verification_request);
465
466    let local_var_req = local_var_req_builder.build()?;
467    let local_var_resp = local_var_client.execute(local_var_req).await?;
468
469    let local_var_status = local_var_resp.status();
470    let local_var_content = local_var_resp.text().await?;
471
472    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
473        serde_json::from_str(&local_var_content).map_err(Error::from)
474    } else {
475        let local_var_entity: Option<AccountsRegistrationResendEmailCreateError> = serde_json::from_str(&local_var_content).ok();
476        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
477        Err(Error::ResponseError(local_var_error))
478    }
479}
480
481pub async fn accounts_registration_verify_email_create(configuration: &configuration::Configuration, verify_email_request: crate::models::VerifyEmailRequest) -> Result<crate::models::RestAuthDetail, Error<AccountsRegistrationVerifyEmailCreateError>> {
482    let local_var_configuration = configuration;
483
484    let local_var_client = &local_var_configuration.client;
485
486    let local_var_uri_str = format!("{}/api/accounts/registration/verify-email/", local_var_configuration.base_path);
487    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
488
489    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
490        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
491    }
492    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
493        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
494    };
495    local_var_req_builder = local_var_req_builder.json(&verify_email_request);
496
497    let local_var_req = local_var_req_builder.build()?;
498    let local_var_resp = local_var_client.execute(local_var_req).await?;
499
500    let local_var_status = local_var_resp.status();
501    let local_var_content = local_var_resp.text().await?;
502
503    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
504        serde_json::from_str(&local_var_content).map_err(Error::from)
505    } else {
506        let local_var_entity: Option<AccountsRegistrationVerifyEmailCreateError> = serde_json::from_str(&local_var_content).ok();
507        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
508        Err(Error::ResponseError(local_var_error))
509    }
510}
511
512/// Providers user nkey credentials
513pub async fn accounts_user_nkey_retrieve(configuration: &configuration::Configuration, ) -> Result<crate::models::NatsOrganizationUser, Error<AccountsUserNkeyRetrieveError>> {
514    let local_var_configuration = configuration;
515
516    let local_var_client = &local_var_configuration.client;
517
518    let local_var_uri_str = format!("{}/api/accounts/user/nkey", local_var_configuration.base_path);
519    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
520
521    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
522        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
523    }
524    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
525        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
526    };
527
528    let local_var_req = local_var_req_builder.build()?;
529    let local_var_resp = local_var_client.execute(local_var_req).await?;
530
531    let local_var_status = local_var_resp.status();
532    let local_var_content = local_var_resp.text().await?;
533
534    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
535        serde_json::from_str(&local_var_content).map_err(Error::from)
536    } else {
537        let local_var_entity: Option<AccountsUserNkeyRetrieveError> = serde_json::from_str(&local_var_content).ok();
538        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
539        Err(Error::ResponseError(local_var_error))
540    }
541}
542
543/// Reads and updates UserModel fields Accepts GET, PUT, PATCH methods.  Default accepted fields: username, first_name, last_name Default display fields: pk, username, email, first_name, last_name Read-only fields: pk, email  Returns UserModel fields.
544pub async fn accounts_user_partial_update(configuration: &configuration::Configuration, patched_user_request: Option<crate::models::PatchedUserRequest>) -> Result<crate::models::User, Error<AccountsUserPartialUpdateError>> {
545    let local_var_configuration = configuration;
546
547    let local_var_client = &local_var_configuration.client;
548
549    let local_var_uri_str = format!("{}/api/accounts/user/", local_var_configuration.base_path);
550    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
551
552    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
553        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
554    }
555    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
556        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
557    };
558    local_var_req_builder = local_var_req_builder.json(&patched_user_request);
559
560    let local_var_req = local_var_req_builder.build()?;
561    let local_var_resp = local_var_client.execute(local_var_req).await?;
562
563    let local_var_status = local_var_resp.status();
564    let local_var_content = local_var_resp.text().await?;
565
566    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
567        serde_json::from_str(&local_var_content).map_err(Error::from)
568    } else {
569        let local_var_entity: Option<AccountsUserPartialUpdateError> = serde_json::from_str(&local_var_content).ok();
570        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
571        Err(Error::ResponseError(local_var_error))
572    }
573}
574
575/// Reads and updates UserModel fields Accepts GET, PUT, PATCH methods.  Default accepted fields: username, first_name, last_name Default display fields: pk, username, email, first_name, last_name Read-only fields: pk, email  Returns UserModel fields.
576pub async fn accounts_user_retrieve(configuration: &configuration::Configuration, ) -> Result<crate::models::User, Error<AccountsUserRetrieveError>> {
577    let local_var_configuration = configuration;
578
579    let local_var_client = &local_var_configuration.client;
580
581    let local_var_uri_str = format!("{}/api/accounts/user/", local_var_configuration.base_path);
582    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
583
584    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
585        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
586    }
587    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
588        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
589    };
590
591    let local_var_req = local_var_req_builder.build()?;
592    let local_var_resp = local_var_client.execute(local_var_req).await?;
593
594    let local_var_status = local_var_resp.status();
595    let local_var_content = local_var_resp.text().await?;
596
597    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
598        serde_json::from_str(&local_var_content).map_err(Error::from)
599    } else {
600        let local_var_entity: Option<AccountsUserRetrieveError> = serde_json::from_str(&local_var_content).ok();
601        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
602        Err(Error::ResponseError(local_var_error))
603    }
604}
605
606/// Reads and updates UserModel fields Accepts GET, PUT, PATCH methods.  Default accepted fields: username, first_name, last_name Default display fields: pk, username, email, first_name, last_name Read-only fields: pk, email  Returns UserModel fields.
607pub async fn accounts_user_update(configuration: &configuration::Configuration, user_request: crate::models::UserRequest) -> Result<crate::models::User, Error<AccountsUserUpdateError>> {
608    let local_var_configuration = configuration;
609
610    let local_var_client = &local_var_configuration.client;
611
612    let local_var_uri_str = format!("{}/api/accounts/user/", local_var_configuration.base_path);
613    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
614
615    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
616        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
617    }
618    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
619        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
620    };
621    local_var_req_builder = local_var_req_builder.json(&user_request);
622
623    let local_var_req = local_var_req_builder.build()?;
624    let local_var_resp = local_var_client.execute(local_var_req).await?;
625
626    let local_var_status = local_var_resp.status();
627    let local_var_content = local_var_resp.text().await?;
628
629    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
630        serde_json::from_str(&local_var_content).map_err(Error::from)
631    } else {
632        let local_var_entity: Option<AccountsUserUpdateError> = serde_json::from_str(&local_var_content).ok();
633        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
634        Err(Error::ResponseError(local_var_error))
635    }
636}
637