/* * VRChat API Documentation * * * The version of the OpenAPI document: 1.3.0 * Contact: me@ruby.js.org * Generated by: https://openapi-generator.tech */ use reqwest; use crate::apis::ResponseContent; use super::{Error, configuration}; /// struct for typed errors of method `get_assigned_permissions` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetAssignedPermissionsError { Status401(crate::models::Error), UnknownValue(serde_json::Value), } /// struct for typed errors of method `get_permission` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetPermissionError { Status401(crate::models::Error), UnknownValue(serde_json::Value), } /// Returns a list of all permissions currently granted by the user. Permissions are assigned e.g. by subscribing to VRC+. pub fn get_assigned_permissions(configuration: &configuration::Configuration, ) -> Result, Error> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/auth/permissions", configuration.base_path); let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = configuration.user_agent { local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } let local_var_req = local_var_req_builder.build()?; let mut local_var_resp = local_var_client.execute(local_var_req)?; let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } } /// Returns a single permission. This endpoint is pretty useless, as it returns the exact same information as `/auth/permissions`. pub fn get_permission(configuration: &configuration::Configuration, permission_id: &str) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/permissions/{permissionId}", configuration.base_path, permissionId=crate::apis::urlencode(permission_id)); let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); if let Some(ref local_var_user_agent) = configuration.user_agent { local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); } let local_var_req = local_var_req_builder.build()?; let mut local_var_resp = local_var_client.execute(local_var_req)?; let local_var_status = local_var_resp.status(); let local_var_content = local_var_resp.text()?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { serde_json::from_str(&local_var_content).map_err(Error::from) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; Err(Error::ResponseError(local_var_error)) } }