use crate::client::Client;
use reqwest::Method;
use serde_json::json;
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct Users {
client: Client,
}
impl Users {
pub fn new(client: &Client) -> Self {
Self { client: client.clone() }
}
pub fn client(&self) -> &Client {
&self.client
}
pub async fn list(
&self,
queries: Option<Vec<String>>,
search: Option<&str>,
total: Option<bool>,
) -> crate::error::Result<crate::models::UserList> {
let mut params = HashMap::new();
if let Some(value) = queries {
params.insert("queries".to_string(), json!(value.into_iter().map(|s| s.into()).collect::<Vec<String>>()));
}
if let Some(value) = search {
params.insert("search".to_string(), json!(value));
}
if let Some(value) = total {
params.insert("total".to_string(), json!(value));
}
let path = "/users".to_string();
self.client.call(Method::GET, &path, None, Some(params)).await
}
pub async fn create(
&self,
user_id: impl Into<String>,
email: Option<&str>,
phone: Option<&str>,
password: Option<&str>,
name: Option<&str>,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("userId".to_string(), json!(user_id.into()));
if let Some(value) = email {
params.insert("email".to_string(), json!(value));
}
if let Some(value) = phone {
params.insert("phone".to_string(), json!(value));
}
if let Some(value) = password {
params.insert("password".to_string(), json!(value));
}
if let Some(value) = name {
params.insert("name".to_string(), json!(value));
}
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users".to_string();
self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await
}
pub async fn create_argon2_user(
&self,
user_id: impl Into<String>,
email: impl Into<String>,
password: impl Into<String>,
name: Option<&str>,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("userId".to_string(), json!(user_id.into()));
params.insert("email".to_string(), json!(email.into()));
params.insert("password".to_string(), json!(password.into()));
if let Some(value) = name {
params.insert("name".to_string(), json!(value));
}
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/argon2".to_string();
self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await
}
pub async fn create_bcrypt_user(
&self,
user_id: impl Into<String>,
email: impl Into<String>,
password: impl Into<String>,
name: Option<&str>,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("userId".to_string(), json!(user_id.into()));
params.insert("email".to_string(), json!(email.into()));
params.insert("password".to_string(), json!(password.into()));
if let Some(value) = name {
params.insert("name".to_string(), json!(value));
}
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/bcrypt".to_string();
self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await
}
pub async fn list_identities(
&self,
queries: Option<Vec<String>>,
search: Option<&str>,
total: Option<bool>,
) -> crate::error::Result<crate::models::IdentityList> {
let mut params = HashMap::new();
if let Some(value) = queries {
params.insert("queries".to_string(), json!(value.into_iter().map(|s| s.into()).collect::<Vec<String>>()));
}
if let Some(value) = search {
params.insert("search".to_string(), json!(value));
}
if let Some(value) = total {
params.insert("total".to_string(), json!(value));
}
let path = "/users/identities".to_string();
self.client.call(Method::GET, &path, None, Some(params)).await
}
pub async fn delete_identity(
&self,
identity_id: impl Into<String>,
) -> crate::error::Result<()> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/identities/{identityId}".to_string().replace("{identityId}", &identity_id.into().to_string());
self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await
}
pub async fn create_md5_user(
&self,
user_id: impl Into<String>,
email: impl Into<String>,
password: impl Into<String>,
name: Option<&str>,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("userId".to_string(), json!(user_id.into()));
params.insert("email".to_string(), json!(email.into()));
params.insert("password".to_string(), json!(password.into()));
if let Some(value) = name {
params.insert("name".to_string(), json!(value));
}
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/md5".to_string();
self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await
}
pub async fn create_ph_pass_user(
&self,
user_id: impl Into<String>,
email: impl Into<String>,
password: impl Into<String>,
name: Option<&str>,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("userId".to_string(), json!(user_id.into()));
params.insert("email".to_string(), json!(email.into()));
params.insert("password".to_string(), json!(password.into()));
if let Some(value) = name {
params.insert("name".to_string(), json!(value));
}
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/phpass".to_string();
self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await
}
#[allow(clippy::too_many_arguments)]
pub async fn create_scrypt_user(
&self,
user_id: impl Into<String>,
email: impl Into<String>,
password: impl Into<String>,
password_salt: impl Into<String>,
password_cpu: i64,
password_memory: i64,
password_parallel: i64,
password_length: i64,
name: Option<&str>,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("userId".to_string(), json!(user_id.into()));
params.insert("email".to_string(), json!(email.into()));
params.insert("password".to_string(), json!(password.into()));
params.insert("passwordSalt".to_string(), json!(password_salt.into()));
params.insert("passwordCpu".to_string(), json!(password_cpu));
params.insert("passwordMemory".to_string(), json!(password_memory));
params.insert("passwordParallel".to_string(), json!(password_parallel));
params.insert("passwordLength".to_string(), json!(password_length));
if let Some(value) = name {
params.insert("name".to_string(), json!(value));
}
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/scrypt".to_string();
self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await
}
#[allow(clippy::too_many_arguments)]
pub async fn create_scrypt_modified_user(
&self,
user_id: impl Into<String>,
email: impl Into<String>,
password: impl Into<String>,
password_salt: impl Into<String>,
password_salt_separator: impl Into<String>,
password_signer_key: impl Into<String>,
name: Option<&str>,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("userId".to_string(), json!(user_id.into()));
params.insert("email".to_string(), json!(email.into()));
params.insert("password".to_string(), json!(password.into()));
params.insert("passwordSalt".to_string(), json!(password_salt.into()));
params.insert("passwordSaltSeparator".to_string(), json!(password_salt_separator.into()));
params.insert("passwordSignerKey".to_string(), json!(password_signer_key.into()));
if let Some(value) = name {
params.insert("name".to_string(), json!(value));
}
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/scrypt-modified".to_string();
self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await
}
pub async fn create_sha_user(
&self,
user_id: impl Into<String>,
email: impl Into<String>,
password: impl Into<String>,
password_version: Option<crate::enums::PasswordHash>,
name: Option<&str>,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("userId".to_string(), json!(user_id.into()));
params.insert("email".to_string(), json!(email.into()));
params.insert("password".to_string(), json!(password.into()));
if let Some(value) = password_version {
params.insert("passwordVersion".to_string(), json!(value));
}
if let Some(value) = name {
params.insert("name".to_string(), json!(value));
}
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/sha".to_string();
self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await
}
pub async fn get(
&self,
user_id: impl Into<String>,
) -> crate::error::Result<crate::models::User> {
let params = HashMap::new();
let path = "/users/{userId}".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::GET, &path, None, Some(params)).await
}
pub async fn delete(
&self,
user_id: impl Into<String>,
) -> crate::error::Result<()> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await
}
pub async fn update_email(
&self,
user_id: impl Into<String>,
email: impl Into<String>,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("email".to_string(), json!(email.into()));
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/email".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await
}
pub async fn update_impersonator(
&self,
user_id: impl Into<String>,
impersonator: bool,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("impersonator".to_string(), json!(impersonator));
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/impersonator".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await
}
pub async fn create_jwt(
&self,
user_id: impl Into<String>,
session_id: Option<&str>,
duration: Option<i64>,
) -> crate::error::Result<crate::models::Jwt> {
let mut params = HashMap::new();
if let Some(value) = session_id {
params.insert("sessionId".to_string(), json!(value));
}
if let Some(value) = duration {
params.insert("duration".to_string(), json!(value));
}
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/jwts".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await
}
pub async fn update_labels(
&self,
user_id: impl Into<String>,
labels: impl IntoIterator<Item = impl Into<String>>,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("labels".to_string(), json!(labels.into_iter().map(|s| s.into()).collect::<Vec<String>>()));
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/labels".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await
}
pub async fn list_logs(
&self,
user_id: impl Into<String>,
queries: Option<Vec<String>>,
total: Option<bool>,
) -> crate::error::Result<crate::models::LogList> {
let mut params = HashMap::new();
if let Some(value) = queries {
params.insert("queries".to_string(), json!(value.into_iter().map(|s| s.into()).collect::<Vec<String>>()));
}
if let Some(value) = total {
params.insert("total".to_string(), json!(value));
}
let path = "/users/{userId}/logs".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::GET, &path, None, Some(params)).await
}
pub async fn list_memberships(
&self,
user_id: impl Into<String>,
queries: Option<Vec<String>>,
search: Option<&str>,
total: Option<bool>,
) -> crate::error::Result<crate::models::MembershipList> {
let mut params = HashMap::new();
if let Some(value) = queries {
params.insert("queries".to_string(), json!(value.into_iter().map(|s| s.into()).collect::<Vec<String>>()));
}
if let Some(value) = search {
params.insert("search".to_string(), json!(value));
}
if let Some(value) = total {
params.insert("total".to_string(), json!(value));
}
let path = "/users/{userId}/memberships".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::GET, &path, None, Some(params)).await
}
pub async fn update_mfa(
&self,
user_id: impl Into<String>,
mfa: bool,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("mfa".to_string(), json!(mfa));
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/mfa".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await
}
pub async fn delete_mfa_authenticator(
&self,
user_id: impl Into<String>,
r#type: crate::enums::AuthenticatorType,
) -> crate::error::Result<()> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/mfa/authenticators/{type}".to_string().replace("{userId}", &user_id.into().to_string()).replace("{type}", &r#type.to_string());
self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await
}
pub async fn list_mfa_factors(
&self,
user_id: impl Into<String>,
) -> crate::error::Result<crate::models::MfaFactors> {
let params = HashMap::new();
let path = "/users/{userId}/mfa/factors".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::GET, &path, None, Some(params)).await
}
pub async fn get_mfa_recovery_codes(
&self,
user_id: impl Into<String>,
) -> crate::error::Result<crate::models::MfaRecoveryCodes> {
let params = HashMap::new();
let path = "/users/{userId}/mfa/recovery-codes".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::GET, &path, None, Some(params)).await
}
pub async fn update_mfa_recovery_codes(
&self,
user_id: impl Into<String>,
) -> crate::error::Result<crate::models::MfaRecoveryCodes> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/mfa/recovery-codes".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::PUT, &path, Some(api_headers), Some(params)).await
}
pub async fn create_mfa_recovery_codes(
&self,
user_id: impl Into<String>,
) -> crate::error::Result<crate::models::MfaRecoveryCodes> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/mfa/recovery-codes".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await
}
pub async fn update_name(
&self,
user_id: impl Into<String>,
name: impl Into<String>,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("name".to_string(), json!(name.into()));
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/name".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await
}
pub async fn update_password(
&self,
user_id: impl Into<String>,
password: impl Into<String>,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("password".to_string(), json!(password.into()));
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/password".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await
}
pub async fn update_phone(
&self,
user_id: impl Into<String>,
number: impl Into<String>,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("number".to_string(), json!(number.into()));
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/phone".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await
}
pub async fn get_prefs(
&self,
user_id: impl Into<String>,
) -> crate::error::Result<crate::models::Preferences> {
let params = HashMap::new();
let path = "/users/{userId}/prefs".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::GET, &path, None, Some(params)).await
}
pub async fn update_prefs(
&self,
user_id: impl Into<String>,
prefs: serde_json::Value,
) -> crate::error::Result<crate::models::Preferences> {
let mut params = HashMap::new();
params.insert("prefs".to_string(), json!(prefs));
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/prefs".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await
}
pub async fn list_sessions(
&self,
user_id: impl Into<String>,
total: Option<bool>,
) -> crate::error::Result<crate::models::SessionList> {
let mut params = HashMap::new();
if let Some(value) = total {
params.insert("total".to_string(), json!(value));
}
let path = "/users/{userId}/sessions".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::GET, &path, None, Some(params)).await
}
pub async fn create_session(
&self,
user_id: impl Into<String>,
) -> crate::error::Result<crate::models::Session> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/sessions".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await
}
pub async fn delete_sessions(
&self,
user_id: impl Into<String>,
) -> crate::error::Result<()> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/sessions".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await
}
pub async fn delete_session(
&self,
user_id: impl Into<String>,
session_id: impl Into<String>,
) -> crate::error::Result<()> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/sessions/{sessionId}".to_string().replace("{userId}", &user_id.into().to_string()).replace("{sessionId}", &session_id.into().to_string());
self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await
}
pub async fn update_status(
&self,
user_id: impl Into<String>,
status: bool,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("status".to_string(), json!(status));
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/status".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await
}
pub async fn list_targets(
&self,
user_id: impl Into<String>,
queries: Option<Vec<String>>,
total: Option<bool>,
) -> crate::error::Result<crate::models::TargetList> {
let mut params = HashMap::new();
if let Some(value) = queries {
params.insert("queries".to_string(), json!(value.into_iter().map(|s| s.into()).collect::<Vec<String>>()));
}
if let Some(value) = total {
params.insert("total".to_string(), json!(value));
}
let path = "/users/{userId}/targets".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::GET, &path, None, Some(params)).await
}
pub async fn create_target(
&self,
user_id: impl Into<String>,
target_id: impl Into<String>,
provider_type: crate::enums::MessagingProviderType,
identifier: impl Into<String>,
provider_id: Option<&str>,
name: Option<&str>,
) -> crate::error::Result<crate::models::Target> {
let mut params = HashMap::new();
params.insert("targetId".to_string(), json!(target_id.into()));
params.insert("providerType".to_string(), json!(provider_type));
params.insert("identifier".to_string(), json!(identifier.into()));
if let Some(value) = provider_id {
params.insert("providerId".to_string(), json!(value));
}
if let Some(value) = name {
params.insert("name".to_string(), json!(value));
}
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/targets".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await
}
pub async fn get_target(
&self,
user_id: impl Into<String>,
target_id: impl Into<String>,
) -> crate::error::Result<crate::models::Target> {
let params = HashMap::new();
let path = "/users/{userId}/targets/{targetId}".to_string().replace("{userId}", &user_id.into().to_string()).replace("{targetId}", &target_id.into().to_string());
self.client.call(Method::GET, &path, None, Some(params)).await
}
pub async fn update_target(
&self,
user_id: impl Into<String>,
target_id: impl Into<String>,
identifier: Option<&str>,
provider_id: Option<&str>,
name: Option<&str>,
) -> crate::error::Result<crate::models::Target> {
let mut params = HashMap::new();
if let Some(value) = identifier {
params.insert("identifier".to_string(), json!(value));
}
if let Some(value) = provider_id {
params.insert("providerId".to_string(), json!(value));
}
if let Some(value) = name {
params.insert("name".to_string(), json!(value));
}
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/targets/{targetId}".to_string().replace("{userId}", &user_id.into().to_string()).replace("{targetId}", &target_id.into().to_string());
self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await
}
pub async fn delete_target(
&self,
user_id: impl Into<String>,
target_id: impl Into<String>,
) -> crate::error::Result<()> {
let params = HashMap::new();
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/targets/{targetId}".to_string().replace("{userId}", &user_id.into().to_string()).replace("{targetId}", &target_id.into().to_string());
self.client.call(Method::DELETE, &path, Some(api_headers), Some(params)).await
}
pub async fn create_token(
&self,
user_id: impl Into<String>,
length: Option<i64>,
expire: Option<i64>,
) -> crate::error::Result<crate::models::Token> {
let mut params = HashMap::new();
if let Some(value) = length {
params.insert("length".to_string(), json!(value));
}
if let Some(value) = expire {
params.insert("expire".to_string(), json!(value));
}
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/tokens".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::POST, &path, Some(api_headers), Some(params)).await
}
pub async fn update_email_verification(
&self,
user_id: impl Into<String>,
email_verification: bool,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("emailVerification".to_string(), json!(email_verification));
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/verification".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await
}
pub async fn update_phone_verification(
&self,
user_id: impl Into<String>,
phone_verification: bool,
) -> crate::error::Result<crate::models::User> {
let mut params = HashMap::new();
params.insert("phoneVerification".to_string(), json!(phone_verification));
let mut api_headers = HashMap::new();
api_headers.insert("content-type".to_string(), "application/json".to_string());
let path = "/users/{userId}/verification/phone".to_string().replace("{userId}", &user_id.into().to_string());
self.client.call(Method::PATCH, &path, Some(api_headers), Some(params)).await
}
}
impl crate::services::Service for Users {
fn client(&self) -> &Client {
&self.client
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_users_creation() {
let client = Client::new();
let service = Users::new(&client);
assert!(service.client().endpoint().contains("cloud.appwrite.io/v1"));
}
}