/* * VRChat API Documentation * * * The version of the OpenAPI document: 1.4.1 * 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 `add_favorite` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum AddFavoriteError { Status400(crate::models::Error), Status403(crate::models::Error), UnknownValue(serde_json::Value), } /// struct for typed errors of method `clear_favorite_group` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum ClearFavoriteGroupError { UnknownValue(serde_json::Value), } /// struct for typed errors of method `get_favorite` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetFavoriteError { Status401(crate::models::Error), Status404(crate::models::Error), UnknownValue(serde_json::Value), } /// struct for typed errors of method `get_favorite_group` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetFavoriteGroupError { UnknownValue(serde_json::Value), } /// struct for typed errors of method `get_favorite_groups` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetFavoriteGroupsError { Status401(crate::models::Error), UnknownValue(serde_json::Value), } /// struct for typed errors of method `get_favorites` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum GetFavoritesError { Status401(crate::models::Error), UnknownValue(serde_json::Value), } /// struct for typed errors of method `remove_favorite` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RemoveFavoriteError { Status401(crate::models::Error), Status404(crate::models::Error), UnknownValue(serde_json::Value), } /// struct for typed errors of method `update_favorite_group` #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum UpdateFavoriteGroupError { UnknownValue(serde_json::Value), } /// Add a new favorite. Friend groups are named `group_0` through `group_3`. Avatar and World groups are named `avatars1` to `avatar4` and `worlds1` to `worlds4`. You cannot add people whom you are not friends with to your friends list. Destroying a friendship removes the person as favorite on both sides. pub fn add_favorite(configuration: &configuration::Configuration, inline_object8: Option) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/favorites", configuration.base_path); let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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()); } local_var_req_builder = local_var_req_builder.json(&inline_object8); 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)) } } /// Clear ALL contents of a specific favorite group. pub fn clear_favorite_group(configuration: &configuration::Configuration, favorite_group_type: &str, favorite_group_name: &str, user_id: &str) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/favorite/group/{favoriteGroupType}/{favoriteGroupName}/{userId}", configuration.base_path, favoriteGroupType=crate::apis::urlencode(favorite_group_type), favoriteGroupName=crate::apis::urlencode(favorite_group_name), userId=crate::apis::urlencode(user_id)); let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, 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)) } } /// Return information about a specific Favorite. pub fn get_favorite(configuration: &configuration::Configuration, favorite_id: &str) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/favorites/{favoriteId}", configuration.base_path, favoriteId=crate::apis::urlencode(favorite_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)) } } /// Fetch information about a specific favorite group. pub fn get_favorite_group(configuration: &configuration::Configuration, favorite_group_type: &str, favorite_group_name: &str, user_id: &str) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/favorite/group/{favoriteGroupType}/{favoriteGroupName}/{userId}", configuration.base_path, favoriteGroupType=crate::apis::urlencode(favorite_group_type), favoriteGroupName=crate::apis::urlencode(favorite_group_name), userId=crate::apis::urlencode(user_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)) } } /// Return a list of favorite groups owned by a user. Returns the same information as `getFavoriteGroups`. pub fn get_favorite_groups(configuration: &configuration::Configuration, n: Option, offset: Option, owner_id: Option<&str>) -> Result, Error> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/favorite/groups", 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_str) = n { local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); } if let Some(ref local_var_str) = offset { local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); } if let Some(ref local_var_str) = owner_id { local_var_req_builder = local_var_req_builder.query(&[("ownerId", &local_var_str.to_string())]); } 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 list of favorites. pub fn get_favorites(configuration: &configuration::Configuration, n: Option, offset: Option, _type: Option<&str>, tag: Option<&str>) -> Result, Error> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/favorites", 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_str) = n { local_var_req_builder = local_var_req_builder.query(&[("n", &local_var_str.to_string())]); } if let Some(ref local_var_str) = offset { local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); } if let Some(ref local_var_str) = _type { local_var_req_builder = local_var_req_builder.query(&[("type", &local_var_str.to_string())]); } if let Some(ref local_var_str) = tag { local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]); } 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)) } } /// Remove a favorite from your favorites list. pub fn remove_favorite(configuration: &configuration::Configuration, favorite_id: &str) -> Result> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/favorites/{favoriteId}", configuration.base_path, favoriteId=crate::apis::urlencode(favorite_id)); let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, 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)) } } /// Update information about a specific favorite group. pub fn update_favorite_group(configuration: &configuration::Configuration, favorite_group_type: &str, favorite_group_name: &str, user_id: &str, inline_object9: Option) -> Result<(), Error> { let local_var_client = &configuration.client; let local_var_uri_str = format!("{}/favorite/group/{favoriteGroupType}/{favoriteGroupName}/{userId}", configuration.base_path, favoriteGroupType=crate::apis::urlencode(favorite_group_type), favoriteGroupName=crate::apis::urlencode(favorite_group_name), userId=crate::apis::urlencode(user_id)); let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, 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()); } local_var_req_builder = local_var_req_builder.json(&inline_object9); 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() { Ok(()) } 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)) } }