use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
/// struct for typed errors of method [`cancel_pending2_fa`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CancelPending2FaError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`check_user_exists`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CheckUserExistsError {
Status400(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`confirm_email`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConfirmEmailError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_global_avatar_moderation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateGlobalAvatarModerationError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_global_avatar_moderation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteGlobalAvatarModerationError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_moderation_report`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteModerationReportError {
Status401(models::Error),
Status403(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_user`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteUserError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`disable2_fa`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Disable2FaError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`enable2_fa`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Enable2FaError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_current_user`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCurrentUserError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_global_avatar_moderations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetGlobalAvatarModerationsError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_moderation_reports`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetModerationReportsError {
Status401(models::Error),
Status403(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_recovery_codes`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetRecoveryCodesError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`logout`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LogoutError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`register_user_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RegisterUserAccountError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`resend_email_confirmation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ResendEmailConfirmationError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`submit_moderation_report`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubmitModerationReportError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`verify2_fa`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Verify2FaError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`verify2_fa_email_code`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Verify2FaEmailCodeError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`verify_auth_token`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum VerifyAuthTokenError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`verify_login_place`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum VerifyLoginPlaceError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`verify_pending2_fa`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum VerifyPending2FaError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`verify_recovery_code`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum VerifyRecoveryCodeError {
Status401(models::Error),
UnknownValue(serde_json::Value),
}
/// Cancels the sequence for enabling time-based 2FA.
pub async fn cancel_pending2_fa(
configuration: &configuration::Configuration,
) -> Result<models::Disable2FaResult, Error<CancelPending2FaError>> {
let uri_str = format!(
"{}/auth/twofactorauth/totp/pending",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Disable2FaResult`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Disable2FaResult`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CancelPending2FaError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Checks if a user by a given `username`, `displayName` or `email` exist. This is used during registration to check if a username has already been taken, during change of displayName to check if a displayName is available, and during change of email to check if the email is already used. In the later two cases the `excludeUserId` is used to exclude oneself, otherwise the result would always be true. It is **REQUIRED** to include **AT LEAST** `username`, `displayName` **or** `email` query parameter. Although they can be combined - in addition with `excludeUserId` (generally to exclude yourself) - to further fine-tune the search.
pub async fn check_user_exists(
configuration: &configuration::Configuration,
email: Option<&str>,
display_name: Option<&str>,
username: Option<&str>,
exclude_user_id: Option<&str>,
) -> Result<models::UserExists, Error<CheckUserExistsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_email = email;
let p_query_display_name = display_name;
let p_query_username = username;
let p_query_exclude_user_id = exclude_user_id;
let uri_str = format!("{}/auth/exists", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_email {
req_builder = req_builder.query(&[("email", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_display_name {
req_builder = req_builder.query(&[("displayName", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_username {
req_builder = req_builder.query(&[("username", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_exclude_user_id {
req_builder = req_builder.query(&[("excludeUserId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UserExists`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserExists`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CheckUserExistsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Confirms the email address for a user
pub async fn confirm_email(
configuration: &configuration::Configuration,
id: &str,
verify_email: &str,
) -> Result<(), Error<ConfirmEmailError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let p_query_verify_email = verify_email;
let uri_str = format!("{}/auth/confirmEmail", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
req_builder = req_builder.query(&[("verify_email", &p_query_verify_email.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<ConfirmEmailError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Globally moderates an avatar.
pub async fn create_global_avatar_moderation(
configuration: &configuration::Configuration,
create_avatar_moderation_request: models::CreateAvatarModerationRequest,
) -> Result<models::AvatarModerationCreated, Error<CreateGlobalAvatarModerationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_avatar_moderation_request = create_avatar_moderation_request;
let uri_str = format!("{}/auth/user/avatarmoderations", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_create_avatar_moderation_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AvatarModerationCreated`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AvatarModerationCreated`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateGlobalAvatarModerationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Globally unmoderates an avatar.
pub async fn delete_global_avatar_moderation(
configuration: &configuration::Configuration,
target_avatar_id: &str,
avatar_moderation_type: models::AvatarModerationType,
) -> Result<models::OkStatus2, Error<DeleteGlobalAvatarModerationError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_target_avatar_id = target_avatar_id;
let p_query_avatar_moderation_type = avatar_moderation_type;
let uri_str = format!("{}/auth/user/avatarmoderations", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("targetAvatarId", &p_query_target_avatar_id.to_string())]);
req_builder = req_builder.query(&[(
"avatarModerationType",
&p_query_avatar_moderation_type.to_string(),
)]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OkStatus2`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OkStatus2`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteGlobalAvatarModerationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Delete a moderation report
pub async fn delete_moderation_report(
configuration: &configuration::Configuration,
moderation_report_id: &str,
) -> Result<models::SuccessFlag, Error<DeleteModerationReportError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_moderation_report_id = moderation_report_id;
let uri_str = format!(
"{}/moderationReports/{moderationReportId}",
configuration.base_path,
moderationReportId = crate::apis::urlencode(p_path_moderation_report_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessFlag`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessFlag`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteModerationReportError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes the account with given ID. Normal users only have permission to delete their own account. Account deletion is 14 days from this request, and will be cancelled if you do an authenticated request with the account afterwards. **VRC+ NOTE:** Despite the 14-days cooldown, any VRC+ subscription will be cancelled **immediately**. **METHOD NOTE:** Despite this being a Delete action, the method type required is PUT.
pub async fn delete_user(
configuration: &configuration::Configuration,
user_id: &str,
) -> Result<models::CurrentUser, Error<DeleteUserError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_user_id = user_id;
let uri_str = format!(
"{}/users/{userId}/delete",
configuration.base_path,
userId = crate::apis::urlencode(p_path_user_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CurrentUser`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CurrentUser`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteUserError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Disables 2FA for the currently logged in account
pub async fn disable2_fa(
configuration: &configuration::Configuration,
) -> Result<models::Disable2FaResult, Error<Disable2FaError>> {
let uri_str = format!("{}/auth/twofactorauth", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Disable2FaResult`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Disable2FaResult`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<Disable2FaError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Begins the sequence for enabling time-based 2FA.
pub async fn enable2_fa(
configuration: &configuration::Configuration,
) -> Result<models::Pending2FaResult, Error<Enable2FaError>> {
let uri_str = format!(
"{}/auth/twofactorauth/totp/pending",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pending2FaResult`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Pending2FaResult`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<Enable2FaError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// This endpoint does the following two operations: 1) Checks if you are already logged in by looking for a valid `auth` cookie. If you are have a valid auth cookie then no additional auth-related actions are taken. If you are **not** logged in then it will log you in with the `Authorization` header and set the `auth` cookie. The `auth` cookie will only be sent once. 2) If logged in, this function will also return the CurrentUser object containing detailed information about the currently logged in user. The auth string after `Authorization: Basic {string}` is a base64-encoded string of the username and password, both individually url-encoded, and then joined with a colon. > base64(urlencode(username):urlencode(password)) **WARNING: Session Limit:** Each authentication with login credentials counts as a separate session, out of which you have a limited amount. Make sure to save and reuse the `auth` cookie if you are often restarting the program. The provided API libraries automatically save cookies during runtime, but does not persist during restart. While it can be fine to use username/password during development, expect in production to very fast run into the rate-limit and be temporarily blocked from making new sessions until older ones expire. The exact number of simultaneous sessions is unknown/undisclosed.
pub async fn get_current_user(
configuration: &configuration::Configuration,
) -> Result<models::RegisterUserAccount200Response, Error<GetCurrentUserError>> {
let uri_str = format!("{}/auth/user", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegisterUserAccount200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegisterUserAccount200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCurrentUserError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns list of globally moderated avatars.
pub async fn get_global_avatar_moderations(
configuration: &configuration::Configuration,
) -> Result<Vec<models::AvatarModeration>, Error<GetGlobalAvatarModerationsError>> {
let uri_str = format!("{}/auth/user/avatarmoderations", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::AvatarModeration>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::AvatarModeration>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetGlobalAvatarModerationsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get submitted moderation reports
pub async fn get_moderation_reports(
configuration: &configuration::Configuration,
offset: Option<i32>,
n: Option<i32>,
reporting_user_id: Option<&str>,
status: Option<&str>,
r#type: Option<&str>,
) -> Result<models::PaginatedModerationReportList, Error<GetModerationReportsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_offset = offset;
let p_query_n = n;
let p_query_reporting_user_id = reporting_user_id;
let p_query_status = status;
let p_query_type = r#type;
let uri_str = format!("{}/moderationReports", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_n {
req_builder = req_builder.query(&[("n", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_reporting_user_id {
req_builder = req_builder.query(&[("reportingUserId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_status {
req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_type {
req_builder = req_builder.query(&[("type", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedModerationReportList`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaginatedModerationReportList`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetModerationReportsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Gets the OTP (One Time Password) recovery codes for accounts with 2FA-protection enabled.
pub async fn get_recovery_codes(
configuration: &configuration::Configuration,
) -> Result<models::TwoFactorRecoveryCodes, Error<GetRecoveryCodesError>> {
let uri_str = format!("{}/auth/user/twofactorauth/otp", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwoFactorRecoveryCodes`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwoFactorRecoveryCodes`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetRecoveryCodesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Invalidates the login session.
pub async fn logout(
configuration: &configuration::Configuration,
) -> Result<models::Success, Error<LogoutError>> {
let uri_str = format!("{}/logout", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Success`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LogoutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// ~~Register a new user account.~~ **DEPRECATED:** Automated creation of accounts has no legitimate public third-party use case, and would be in violation of ToS ยง13.2: *By using the Platform, you agree not to: i. [...] use the Platform in a manner inconsistent with individual human usage* This endpoint is documented in the interest of completeness
#[deprecated]
pub async fn register_user_account(
configuration: &configuration::Configuration,
register_user_account_request: models::RegisterUserAccountRequest,
) -> Result<models::RegisterUserAccount200Response, Error<RegisterUserAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_register_user_account_request = register_user_account_request;
let uri_str = format!("{}/auth/register", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_register_user_account_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegisterUserAccount200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegisterUserAccount200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RegisterUserAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Requests a resend of pending email address confirmation email
pub async fn resend_email_confirmation(
configuration: &configuration::Configuration,
) -> Result<models::Success, Error<ResendEmailConfirmationError>> {
let uri_str = format!("{}/auth/user/resendEmail", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Success`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Success`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ResendEmailConfirmationError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Submit a moderation report
pub async fn submit_moderation_report(
configuration: &configuration::Configuration,
submit_moderation_report_request: models::SubmitModerationReportRequest,
) -> Result<models::ModerationReport, Error<SubmitModerationReportError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_submit_moderation_report_request = submit_moderation_report_request;
let uri_str = format!("{}/moderationReports", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_submit_moderation_report_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ModerationReport`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ModerationReport`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubmitModerationReportError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Finishes the login sequence with a normal 2FA-generated code for accounts with 2FA-protection enabled.
pub async fn verify2_fa(
configuration: &configuration::Configuration,
two_factor_auth_code: models::TwoFactorAuthCode,
) -> Result<models::Verify2FaResult, Error<Verify2FaError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_two_factor_auth_code = two_factor_auth_code;
let uri_str = format!("{}/auth/twofactorauth/totp/verify", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_two_factor_auth_code);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Verify2FaResult`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Verify2FaResult`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<Verify2FaError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Finishes the login sequence with an 2FA email code.
pub async fn verify2_fa_email_code(
configuration: &configuration::Configuration,
two_factor_email_code: models::TwoFactorEmailCode,
) -> Result<models::Verify2FaEmailCodeResult, Error<Verify2FaEmailCodeError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_two_factor_email_code = two_factor_email_code;
let uri_str = format!(
"{}/auth/twofactorauth/emailotp/verify",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_two_factor_email_code);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Verify2FaEmailCodeResult`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Verify2FaEmailCodeResult`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<Verify2FaEmailCodeError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Verify whether the currently provided Auth Token is valid.
pub async fn verify_auth_token(
configuration: &configuration::Configuration,
) -> Result<models::VerifyAuthTokenResult, Error<VerifyAuthTokenError>> {
let uri_str = format!("{}/auth", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerifyAuthTokenResult`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerifyAuthTokenResult`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<VerifyAuthTokenError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Verifies a login attempt for a user
pub async fn verify_login_place(
configuration: &configuration::Configuration,
token: &str,
user_id: Option<&str>,
) -> Result<(), Error<VerifyLoginPlaceError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_token = token;
let p_query_user_id = user_id;
let uri_str = format!("{}/auth/verifyLoginPlace", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_user_id {
req_builder = req_builder.query(&[("userId", ¶m_value.to_string())]);
}
req_builder = req_builder.query(&[("token", &p_query_token.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<VerifyLoginPlaceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Finishes sequence for enabling time-based 2FA.
pub async fn verify_pending2_fa(
configuration: &configuration::Configuration,
two_factor_auth_code: models::TwoFactorAuthCode,
) -> Result<models::Verify2FaResult, Error<VerifyPending2FaError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_two_factor_auth_code = two_factor_auth_code;
let uri_str = format!(
"{}/auth/twofactorauth/totp/pending/verify",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_two_factor_auth_code);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Verify2FaResult`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Verify2FaResult`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<VerifyPending2FaError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Finishes the login sequence with an OTP (One Time Password) recovery code for accounts with 2FA-protection enabled.
pub async fn verify_recovery_code(
configuration: &configuration::Configuration,
two_factor_auth_code: models::TwoFactorAuthCode,
) -> Result<models::Verify2FaResult, Error<VerifyRecoveryCodeError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_two_factor_auth_code = two_factor_auth_code;
let uri_str = format!("{}/auth/twofactorauth/otp/verify", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_two_factor_auth_code);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Verify2FaResult`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Verify2FaResult`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<VerifyRecoveryCodeError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}