1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
/*
 * Box Platform API
 *
 * [Box Platform](https://box.dev) provides functionality to provide access to content stored within [Box](https://box.com). It provides endpoints for basic manipulation of files and folders, management of users within an enterprise, as well as more complex topics such as legal holds and retention policies.
 *
 * The version of the OpenAPI document: 2.0.0
 * Contact: devrel@box.com
 * Generated by: https://openapi-generator.tech
 */
//

use std::collections::HashMap;

use serde_json::json;

use super::models::post_users_request::PostUsersRequest;
use super::models::put_users_id_request::PutUsersIdRequest;
use super::models::user_full::UserFull;
use super::models::users::Users;

use crate::auth::AuthError;

use crate::box_client::BoxClient;
use crate::http_client::BaseHttpClient;

/// struct for passing parameters to the method [`list`]
#[derive(Clone, Debug, Default)]
pub struct ListUsersParams {
    /// Limits the results to only users who's `name` or `login` start with the search term.  
    /// For externally managed users, the search term needs to completely match the in order to find the user, and it will only return one user at a time.
    pub filter_term: Option<String>,
    /// Limits the results to the kind of user specified.  * `all` returns every kind of user for whom the   `login` or `name` partially matches the   `filter_term`. It will only return an external user   if the login matches the `filter_term` completely,   and in that case it will only return that user. * `managed` returns all managed and app users for whom   the `login` or `name` partially matches the   `filter_term`. * `external` returns all external users for whom the   `login` matches the `filter_term` exactly.
    pub user_type: Option<String>,
    /// Limits the results to app users with the given `external_app_user_id` value.  When creating an app user, an `external_app_user_id` value can be set. This value can then be used in this endpoint to find any users that match that `external_app_user_id` value.
    pub external_app_user_id: Option<String>,
    /// A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.  Be aware that specifying this parameter will have the effect that none of the standard fields are returned in the response unless explicitly specified, instead only fields for the mini representation are returned, additional to the fields requested.
    pub fields: Option<Vec<String>>,
    /// The offset of the item at which to begin the response.  Queries with offset parameter value exceeding 10000 will be rejected with a 400 response.
    pub offset: Option<i64>,
    /// The maximum number of items to return per page.
    pub limit: Option<i64>,
    /// Specifies whether to use marker-based pagination instead of offset-based pagination. Only one pagination method can be used at a time.  By setting this value to true, the API will return a `marker` field that can be passed as a parameter to this endpoint to get the next page of the response.
    pub usemarker: Option<bool>,
    /// Defines the position marker at which to begin returning results. This is used when paginating using marker-based pagination.  This requires `usemarker` to be set to `true`.
    pub marker: Option<String>,
}

/// Deletes a user.
/// By default this will fail if the user still owns any content.
/// Move their owned content first before proceeding, or use the `force` field to delete the user and their files.
///
/// Sample usage:
/// ```no_run
/// use rusty_box::{
///     auth::{
///         auth_developer::DevAuth,
///         AuthError,
///     },
///     box_client::BoxClient,
///     config::Config,
///     rest_api::users::users_api,
/// };
/// use dotenv;
/// use std::env;
/// #[tokio::main]
/// async fn main() -> Result<(), AuthError> {
///
///     dotenv::from_filename(".dev.env").ok();
///     let access_token = env::var("DEVELOPER_TOKEN").expect("DEVELOPER_TOKEN must be set");
///
///     let config = Config::new();
///     let auth = DevAuth::new(
///         config,
///         access_token,
///     );
///     let mut client = BoxClient::new(Box::new(auth));
///
///     let user_id = "12345";
///     users_api::delete(&mut client, &user_id, None, None).await?;
///
///     Ok(())
/// }
/// ```
pub async fn delete(
    client: &mut BoxClient<'_>,
    user_id: &str,
    notify: Option<bool>,
    force: Option<bool>,
) -> Result<(), AuthError> {
    let uri = client.auth.base_api_url() + "/users" + format!("/{}", user_id).as_str();
    let headers = client.headers().await?;

    //TODO: these need to go in the query string
    let value = serde_json::json!({
        "notify": notify,
        "force": force,
    });

    let resp = client.http.delete(&uri, Some(&headers), &value).await;
    match resp {
        Ok(_) => Ok(()),
        Err(e) => Err(AuthError::RequestError(e)),
    }
}

/// Returns a list of all users for the Enterprise along with their `user_id`, `public_name`, and `login`.  
/// The application and the authenticated user need to have the permission to look up users in the entire enterprise.
///
/// Sample usage:
/// ```no_run
/// use rusty_box::{
///     auth::{
///         auth_developer::DevAuth,
///         AuthError,
///     },
///     box_client::BoxClient,
///     config::Config,
///     rest_api::users::users_api,
/// };
/// use dotenv;
/// use std::env;
/// #[tokio::main]
/// async fn main() -> Result<(), AuthError> {
///
///     dotenv::from_filename(".dev.env").ok();
///     let access_token = env::var("DEVELOPER_TOKEN").expect("DEVELOPER_TOKEN must be set");
///
///     let config = Config::new();
///     let auth = DevAuth::new(
///         config,
///         access_token,
///     );
///     let mut client = BoxClient::new(Box::new(auth));
///
///     let result = users_api::list(&mut client, None).await?;
///     println!("Users:");
///
///     if let Some(users) = result.entries {
///         for user in users {
///             println!(
///                 "{}\t{}\t{}\t{}",
///                 user.id.unwrap(),
///                 user.r#type.to_string(),
///                 user.name.unwrap(),
///                 user.login.unwrap(),
///             );
///         }
///     }
///
///     Ok(())
/// }
/// ```
pub async fn list(
    client: &mut BoxClient<'_>,
    params: Option<ListUsersParams>,
) -> Result<Users, AuthError> {
    let uri = client.auth.base_api_url() + "/users";
    let headers = client.headers().await?;

    let params = params.unwrap_or_default();

    let filter_term = params.filter_term.unwrap_or_default();
    let user_type = params.user_type.unwrap_or_default();
    let external_app_user_id = params.external_app_user_id.unwrap_or_default();

    let fields = params
        .fields
        .unwrap_or(vec![])
        .into_iter()
        .collect::<Vec<String>>()
        .join(",")
        .to_string();

    let offset = params.offset.unwrap_or_default().to_string();
    let limit = params.limit.unwrap_or_default().to_string();
    let usemarker = params.usemarker.unwrap_or_default().to_string();
    let marker = params.marker.unwrap_or_default().to_string();

    let mut payload = HashMap::new();

    if filter_term != String::default() {
        payload.insert("filter_term", filter_term.as_str());
    }
    if user_type != String::default() {
        payload.insert("user_type", user_type.as_str());
    }
    if external_app_user_id != String::default() {
        payload.insert("external_app_user_id", external_app_user_id.as_str());
    }
    if fields != String::default() {
        payload.insert("fields", fields.as_str());
    }
    if offset != "0" {
        payload.insert("offset", offset.as_str());
    }
    if limit != "0" {
        payload.insert("limit", limit.as_str());
    }
    if usemarker != String::default() {
        payload.insert("usemarker", usemarker.as_str());
    }
    if marker != String::default() {
        payload.insert("marker", marker.as_str());
    }

    let resp = client.http.get(&uri, Some(&headers), &payload).await;

    match resp {
        Ok(res) => {
            let users = serde_json::from_str::<Users>(&res)?;
            Ok(users)
        }
        Err(e) => Err(AuthError::RequestError(e)),
    }
}

/// Retrieves information about a user in the enterprise.  
/// The application and the authenticated user need to have the permission to look up users in the entire enterprise.  
/// This endpoint also returns a limited set of information for external users who are collaborated on content owned by the enterprise for authenticated users with the right scopes.
/// In this case, disallowed fields will return null instead.
///
/// Sample usage:
/// ```no_run
/// use rusty_box::{
///     auth::{
///         auth_developer::DevAuth,
///         AuthError,
///     },
///     box_client::BoxClient,
///     config::Config,
///     rest_api::users::users_api,
/// };
/// use dotenv;
/// use std::env;
/// #[tokio::main]
/// async fn main() -> Result<(), AuthError> {
///
///     dotenv::from_filename(".dev.env").ok();
///     let access_token = env::var("DEVELOPER_TOKEN").expect("DEVELOPER_TOKEN must be set");
///
///     let config = Config::new();
///     let auth = DevAuth::new(
///         config,
///         access_token,
///     );
///     let mut client = BoxClient::new(Box::new(auth));
///
///     let user_id = "123";
///     
///     let user = users_api::id(&mut client, &user_id, None).await?;
///     println!("User:{:#?}", user);
///
///     Ok(())
/// }
/// ```
pub async fn id(
    client: &mut BoxClient<'_>,
    user_id: &str,
    fields: Option<Vec<String>>,
) -> Result<UserFull, AuthError> {
    let uri = client.auth.base_api_url() + "/users" + format!("/{}", user_id).as_str();
    let headers = client.headers().await?;

    let fields = fields
        .unwrap_or(vec![])
        .into_iter()
        .collect::<Vec<String>>()
        .join(",")
        .to_string();

    let mut payload = HashMap::new();
    payload.insert("fields", fields.as_str());

    let resp = client.http.get(&uri, Some(&headers), &payload).await;
    match resp {
        Ok(res) => {
            let user = serde_json::from_str::<UserFull>(&res)?;
            Ok(user)
        }
        Err(e) => Err(AuthError::RequestError(e)),
    }
}

/// Retrieves information about the user who is currently authenticated.  
/// In the case of a client-side authenticated OAuth 2.0 application this will be the user who authorized the app.  
/// In the case of a JWT, server-side authenticated application this will be the service account that belongs to the application by default.  
/// Use the `As-User` header to change who this API call is made on behalf of.
///
/// Sample usage:
/// ```no_run
/// use rusty_box::{
///     auth::{
///         auth_developer::DevAuth,
///         AuthError,
///     },
///     box_client::BoxClient,
///     config::Config,
///     rest_api::users::users_api,
/// };
/// use dotenv;
/// use std::env;
/// #[tokio::main]
/// async fn main() -> Result<(), AuthError> {
///
///     dotenv::from_filename(".dev.env").ok();
///     let access_token = env::var("DEVELOPER_TOKEN").expect("DEVELOPER_TOKEN must be set");
///
///     let config = Config::new();
///     let auth = DevAuth::new(
///         config,
///         access_token,
///     );
///     let mut client = BoxClient::new(Box::new(auth));
///     
///     let me = users_api::me(&mut client, None).await?;
///     println!("Me:{:#?}", me);
///
///     Ok(())
/// }
/// ```
pub async fn me(
    client: &mut BoxClient<'_>,
    fields: Option<Vec<String>>,
) -> Result<UserFull, AuthError> {
    let uri = client.auth.base_api_url() + "/users/me";
    let headers = client.headers().await?;

    let fields = fields
        .unwrap_or(vec![])
        .into_iter()
        .collect::<Vec<String>>()
        .join(",")
        .to_string();

    let mut payload = HashMap::new();
    payload.insert("fields", fields.as_str());

    let resp = client.http.get(&uri, Some(&headers), &payload).await;
    match resp {
        Ok(res) => {
            let user = serde_json::from_str::<UserFull>(&res)?;
            Ok(user)
        }
        Err(e) => Err(AuthError::RequestError(e)),
    }
}

/// Creates a new managed user in an enterprise.
/// This endpoint is only available to users and applications with the right admin permissions.
///
/// Sample usage:
/// ```no_run
/// use rusty_box::{
///     auth::{
///         auth_developer::DevAuth,
///         AuthError,
///     },
///     box_client::BoxClient,
///     config::Config,
///     rest_api::users::users_api,
///     rest_api::users::models::post_users_request
/// };
/// use dotenv;
/// use std::env;
/// #[tokio::main]
/// async fn main() -> Result<(), AuthError> {
///
///     dotenv::from_filename(".dev.env").ok();
///     let access_token = env::var("DEVELOPER_TOKEN").expect("DEVELOPER_TOKEN must be set");
///
///     let config = Config::new();
///     let auth = DevAuth::new(
///         config,
///         access_token,
///     );
///     let mut client = BoxClient::new(Box::new(auth));
///     
///     let new_user_request = post_users_request::PostUsersRequest {
///         name: "Test User".to_string(),
///         login: Some("test.user@gmail.local".to_string()),
///         is_platform_access_only: Some(false),
///         role: Some(post_users_request::Role::Coadmin),
///         language: Some("en".to_string()),
///         is_sync_enabled: Some(true),
///         job_title: Some("Test Job Title".to_string()),
///         phone: Some("555-555-5555".to_string()),
///         address: Some("123 Test St".to_string()),
///         space_amount: Some(1073741824),
///         // tracking_codes: Some(vec!["test-tracking-code".to_string()]),
///         can_see_managed_users: Some(true),
///         timezone: Some("America/Los_Angeles".to_string()),
///         is_external_collab_restricted: Some(false),
///         is_exempt_from_device_limits: Some(false),
///         is_exempt_from_login_verification: Some(false),
///         status: Some(post_users_request::Status::Active),
///         external_app_user_id: Some("test-external-app-user-id".to_string()),
///         ..Default::default()
///     };
///
///     let new_user = users_api::create(&mut client, None, new_user_request).await?;
///     println!("New User:{:#?}", new_user);
///
///     Ok(())
/// }
/// ```
pub async fn create(
    client: &mut BoxClient<'_>,
    fields: Option<Vec<String>>,
    user: PostUsersRequest,
) -> Result<UserFull, AuthError> {
    let uri = client.auth.base_api_url() + "/users";
    let headers = client.headers().await?;

    let fields = fields
        .unwrap_or(vec![])
        .into_iter()
        .collect::<Vec<String>>()
        .join(",")
        .to_string();

    let mut query = HashMap::new();
    if !fields.is_empty() {
        query.insert("fields", fields.as_str());
    }

    // convert the postusersrequest to json
    let value_json = serde_json::to_string(&user)?;
    let value = serde_json::from_str(&value_json)?;

    let resp = client
        .http
        .post(&uri, Some(&headers), Some(&query), &value)
        .await;
    match resp {
        Ok(res) => {
            let user = serde_json::from_str::<UserFull>(&res)?;
            Ok(user)
        }
        Err(e) => Err(AuthError::RequestError(e)),
    }
}

/// Validates the roles and permissions of the user,
/// and creates asynchronous jobs to terminate the user's sessions.
/// Returns the status for the POST request.
///
/// Sample usage:
/// ```no_run
/// use rusty_box::{
///     auth::{
///         auth_developer::DevAuth,
///         AuthError,
///     },
///     box_client::BoxClient,
///     config::Config,
///     rest_api::users::users_api,
/// };
/// use dotenv;
/// use std::env;
/// #[tokio::main]
/// async fn main() -> Result<(), AuthError> {
///
///     dotenv::from_filename(".dev.env").ok();
///     let access_token = env::var("DEVELOPER_TOKEN").expect("DEVELOPER_TOKEN must be set");
///
///     let config = Config::new();
///     let auth = DevAuth::new(
///         config,
///         access_token,
///     );
///     let mut client = BoxClient::new(Box::new(auth));
///     
///     let by_user_ids = users_api::terminate_sessions_by_user_ids(
///         &mut client,
///         vec!["123".to_string(), "456".to_string()],
///     )
///     .await?;
///     assert!(by_user_ids.is_some());
///
///     Ok(())
/// }
/// ```
pub async fn terminate_sessions_by_user_ids(
    client: &mut BoxClient<'_>,
    user_ids: Vec<String>,
) -> Result<Option<String>, AuthError> {
    let uri = client.auth.base_api_url() + "/users/terminate_sessions";
    let headers = client.headers().await?;

    let mut value = HashMap::new();
    value.insert("user_ids", user_ids);
    let value = json!(value);

    let resp = client.http.post(&uri, Some(&headers), None, &value).await;
    match resp {
        Ok(res) => Ok(Some(res)),
        Err(e) => Err(AuthError::RequestError(e)),
    }
}

/// Validates the roles and permissions of the user,
/// and creates asynchronous jobs to terminate the user's sessions.
/// Returns the status for the POST request.
///
/// Sample usage:
/// ```no_run
/// use rusty_box::{
///     auth::{
///         auth_developer::DevAuth,
///         AuthError,
///     },
///     box_client::BoxClient,
///     config::Config,
///     rest_api::users::users_api,
/// };
/// use dotenv;
/// use std::env;
/// #[tokio::main]
/// async fn main() -> Result<(), AuthError> {
///
///     dotenv::from_filename(".dev.env").ok();
///     let access_token = env::var("DEVELOPER_TOKEN").expect("DEVELOPER_TOKEN must be set");
///
///     let config = Config::new();
///     let auth = DevAuth::new(
///         config,
///         access_token,
///     );
///     let mut client = BoxClient::new(Box::new(auth));
///     
///
///     let by_user_logins = users_api::terminate_sessions_by_user_logins(
///         &mut client,
///         vec!["abc@gmail.local".to_string(), "def@gmail.local".to_string()],
///     )
///     .await?;
///     assert!(by_user_logins.is_some());
///
///     Ok(())
/// }
/// ```
pub async fn terminate_sessions_by_user_logins(
    client: &mut BoxClient<'_>,
    user_logins: Vec<String>,
) -> Result<Option<String>, AuthError> {
    let uri = client.auth.base_api_url() + "/users/terminate_sessions";
    let headers = client.headers().await?;

    let mut value = HashMap::new();
    value.insert("user_logins", user_logins);
    let value = json!(value);

    let resp = client.http.post(&uri, Some(&headers), None, &value).await;
    match resp {
        Ok(res) => Ok(Some(res)),
        Err(e) => Err(AuthError::RequestError(e)),
    }
}

/// Validates the roles and permissions of the user,
/// and creates asynchronous jobs to terminate the user's sessions.
/// Returns the status for the POST request.
///
/// Sample usage:
/// ```no_run
/// use rusty_box::{
///     auth::{
///         auth_developer::DevAuth,
///         AuthError,
///     },
///     box_client::BoxClient,
///     config::Config,
///     rest_api::users::users_api,
/// };
/// use dotenv;
/// use std::env;
/// #[tokio::main]
/// async fn main() -> Result<(), AuthError> {
///
///     dotenv::from_filename(".dev.env").ok();
///     let access_token = env::var("DEVELOPER_TOKEN").expect("DEVELOPER_TOKEN must be set");
///
///     let config = Config::new();
///     let auth = DevAuth::new(
///         config,
///         access_token,
///     );
///     let mut client = BoxClient::new(Box::new(auth));
///     
///     let by_group_ids = users_api::terminate_sessions_by_group_ids(
///         &mut client,
///         vec!["123".to_string(), "456".to_string()],
///     )
///     .await?;
///     assert!(by_group_ids.is_some());
///
///     Ok(())
/// }
/// ```
pub async fn terminate_sessions_by_group_ids(
    client: &mut BoxClient<'_>,
    group_ids: Vec<String>,
    // fields: Option<Vec<String>>,
) -> Result<Option<String>, AuthError> {
    let uri = client.auth.base_api_url() + "/users/terminate_sessions";
    let headers = client.headers().await?;

    let mut value = HashMap::new();
    value.insert("user_ids", group_ids);
    let value = json!(value);

    let resp = client.http.post(&uri, Some(&headers), None, &value).await;
    match resp {
        Ok(res) => Ok(Some(res)),
        Err(e) => Err(AuthError::RequestError(e)),
    }
}

/// Updates a managed or app user in an enterprise.
/// This endpoint is only available to users and applications with the right admin permissions.
///
/// Sample usage:
/// ```no_run
/// use rusty_box::{
///     auth::{
///         auth_developer::DevAuth,
///         AuthError,
///     },
///     box_client::BoxClient,
///     config::Config,
///     rest_api::users::users_api,
///     rest_api::users::models::put_users_id_request::PutUsersIdRequest
/// };
/// use dotenv;
/// use std::env;
/// #[tokio::main]
/// async fn main() -> Result<(), AuthError> {
///
///     dotenv::from_filename(".dev.env").ok();
///     let access_token = env::var("DEVELOPER_TOKEN").expect("DEVELOPER_TOKEN must be set");
///
///     let config = Config::new();
///     let auth = DevAuth::new(
///         config,
///         access_token,
///     );
///     let mut client = BoxClient::new(Box::new(auth));
///
///     let user_id = "12345";
///     
///     let user_updates = PutUsersIdRequest {
///         name: Some("Test User Updated".to_string()),
///         address: Some("456 Test St".to_string()),
///         ..Default::default()
///     };
///
///     let updated_user =
///         users_api::update(&mut client, &user_id, None, user_updates).await?;
///     println!("Updated User:{:#?}", updated_user);
///
///     Ok(())
/// }
/// ```
pub async fn update(
    client: &mut BoxClient<'_>,
    user_id: &str,
    fields: Option<Vec<String>>,
    user: PutUsersIdRequest,
) -> Result<UserFull, AuthError> {
    let uri = client.auth.base_api_url() + "/users" + format!("/{}", user_id).as_str();
    let headers = client.headers().await?;

    let fields = fields
        .unwrap_or(vec![])
        .into_iter()
        .collect::<Vec<String>>()
        .join(",")
        .to_string();

    let mut query = HashMap::new();
    if !fields.is_empty() {
        query.insert("fields", fields.as_str());
    }

    // convert the postusersrequest to json
    let value_json = serde_json::to_string(&user)?;
    let value = serde_json::from_str(&value_json)?;

    let resp = client
        .http
        .put(&uri, Some(&headers), Some(&query), &value)
        .await;
    match resp {
        Ok(res) => {
            let user = serde_json::from_str::<UserFull>(&res)?;
            Ok(user)
        }
        Err(e) => Err(AuthError::RequestError(e)),
    }
}