babelforce_manager_sdk/resources/
me.rs1use std::sync::Arc;
2
3use crate::error::{map_user_err, ManagerError};
4use crate::gen::user::apis::configuration::Configuration;
5use crate::gen::user::apis::user_api as api;
6use crate::gen::user::models;
7use crate::retry::{with_retry, RetryPolicy};
8
9pub struct MeResource {
12 pub(crate) cfg: Arc<Configuration>,
13 pub(crate) retry: RetryPolicy,
14}
15
16impl MeResource {
17 pub async fn get(&self) -> Result<models::UserItemResponse, ManagerError> {
19 with_retry(&self.retry, true, || api::get_user(self.cfg.as_ref()))
20 .await
21 .map_err(map_user_err)
22 }
23
24 pub async fn customer(&self) -> Result<models::UserCustomerItemResponse, ManagerError> {
26 with_retry(&self.retry, true, || {
27 api::get_user_customer(self.cfg.as_ref())
28 })
29 .await
30 .map_err(map_user_err)
31 }
32
33 pub async fn accounts(&self) -> Result<Vec<models::Account>, ManagerError> {
35 let resp = with_retry(&self.retry, true, || api::list_accounts(self.cfg.as_ref()))
36 .await
37 .map_err(map_user_err)?;
38 Ok(resp.items)
39 }
40
41 pub async fn reset_password(&self) -> Result<(), ManagerError> {
43 with_retry(&self.retry, false, || {
44 api::reset_password(self.cfg.as_ref())
45 })
46 .await
47 .map_err(map_user_err)?;
48 Ok(())
49 }
50}