Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add formatting #20

Merged
merged 2 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions examples/online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@ async fn main() {
let mut config = apis::configuration::Configuration::default();
config.basic_auth = Some((String::from("username"), Some(String::from("password"))));

match apis::authentication_api::get_current_user(&config).await.unwrap() {
vrchatapi::models::EitherUserOrTwoFactor::CurrentUser(me) => println!("Username: {}", me.username.unwrap()),
vrchatapi::models::EitherUserOrTwoFactor::RequiresTwoFactorAuth(requires_auth) => println!("The Username requires Auth: {:?}", requires_auth.requires_two_factor_auth)
match apis::authentication_api::get_current_user(&config)
.await
.unwrap()
{
vrchatapi::models::EitherUserOrTwoFactor::CurrentUser(me) => {
println!("Username: {}", me.username.unwrap())
}
vrchatapi::models::EitherUserOrTwoFactor::RequiresTwoFactorAuth(requires_auth) => println!(
"The Username requires Auth: {:?}",
requires_auth.requires_two_factor_auth
),
}

let online = apis::system_api::get_current_online_users(&config).await.unwrap();
let online = apis::system_api::get_current_online_users(&config)
.await
.unwrap();
println!("Current Online Users: {}", online);
}
}
1 change: 1 addition & 0 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ cat patches/2FA_Current_User.rs >> src/models/current_user.rs
sed -i 's/pub use self::current_user::CurrentUser;/pub use self::current_user::{EitherUserOrTwoFactor, CurrentUser};/g' src/models/mod.rs
sed -i 's/Result<models::CurrentUser, Error<GetCurrentUserError>>/Result<models::EitherUserOrTwoFactor, Error<GetCurrentUserError>>/g' src/apis/authentication_api.rs

cargo fmt
cargo build
cargo test
203 changes: 149 additions & 54 deletions src/apis/authentication_api.rs

Large diffs are not rendered by default.

315 changes: 236 additions & 79 deletions src/apis/avatars_api.rs

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions src/apis/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* Generated by: https://openapi-generator.tech
*/



#[derive(Debug, Clone)]
pub struct Configuration {
pub base_path: String,
Expand All @@ -28,7 +26,6 @@ pub struct ApiKey {
pub key: String,
}


impl Configuration {
pub fn new() -> Configuration {
Configuration::default()
Expand All @@ -40,12 +37,14 @@ impl Default for Configuration {
Configuration {
base_path: "https://vrchat.com/api/1".to_owned(),
user_agent: Some("vrchatapi-rust".to_owned()),
client: reqwest::Client::builder().cookie_store(true).build().unwrap(),
client: reqwest::Client::builder()
.cookie_store(true)
.build()
.unwrap(),
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,

}
}
}
122 changes: 88 additions & 34 deletions src/apis/economy_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
* Generated by: https://openapi-generator.tech
*/


use super::{configuration, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{Deserialize, Serialize};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};


/// struct for typed errors of method [`get_current_subscriptions`]
#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -53,18 +51,24 @@ pub enum GetSubscriptionsError {
UnknownValue(serde_json::Value),
}


/// Get a list of all current user subscriptions.
pub async fn get_current_subscriptions(configuration: &configuration::Configuration, ) -> Result<Vec<models::UserSubscription>, Error<GetCurrentSubscriptionsError>> {
pub async fn get_current_subscriptions(
configuration: &configuration::Configuration,
) -> Result<Vec<models::UserSubscription>, Error<GetCurrentSubscriptionsError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!("{}/auth/user/subscription", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
let local_var_uri_str = format!(
"{}/auth/user/subscription",
local_var_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) = local_var_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.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}

let local_var_req = local_var_req_builder.build()?;
Expand All @@ -76,23 +80,37 @@ pub async fn get_current_subscriptions(configuration: &configuration::Configurat
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<GetCurrentSubscriptionsError> = 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 };
let local_var_entity: Option<GetCurrentSubscriptionsError> =
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))
}
}

/// Get a single License Group by given ID.
pub async fn get_license_group(configuration: &configuration::Configuration, license_group_id: &str) -> Result<models::LicenseGroup, Error<GetLicenseGroupError>> {
pub async fn get_license_group(
configuration: &configuration::Configuration,
license_group_id: &str,
) -> Result<models::LicenseGroup, Error<GetLicenseGroupError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!("{}/licenseGroups/{licenseGroupId}", local_var_configuration.base_path, licenseGroupId=crate::apis::urlencode(license_group_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
let local_var_uri_str = format!(
"{}/licenseGroups/{licenseGroupId}",
local_var_configuration.base_path,
licenseGroupId = crate::apis::urlencode(license_group_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) = local_var_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.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}

let local_var_req = local_var_req_builder.build()?;
Expand All @@ -104,23 +122,37 @@ pub async fn get_license_group(configuration: &configuration::Configuration, lic
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<GetLicenseGroupError> = 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 };
let local_var_entity: Option<GetLicenseGroupError> =
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))
}
}

/// Get a single Steam transactions by ID. This returns the exact same information as `getSteamTransactions`, so no point in using this endpoint.
pub async fn get_steam_transaction(configuration: &configuration::Configuration, transaction_id: &str) -> Result<models::Transaction, Error<GetSteamTransactionError>> {
pub async fn get_steam_transaction(
configuration: &configuration::Configuration,
transaction_id: &str,
) -> Result<models::Transaction, Error<GetSteamTransactionError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!("{}/Steam/transactions/{transactionId}", local_var_configuration.base_path, transactionId=crate::apis::urlencode(transaction_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
let local_var_uri_str = format!(
"{}/Steam/transactions/{transactionId}",
local_var_configuration.base_path,
transactionId = crate::apis::urlencode(transaction_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) = local_var_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.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}

let local_var_req = local_var_req_builder.build()?;
Expand All @@ -132,23 +164,32 @@ pub async fn get_steam_transaction(configuration: &configuration::Configuration,
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<GetSteamTransactionError> = 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 };
let local_var_entity: Option<GetSteamTransactionError> =
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))
}
}

/// Get all own Steam transactions.
pub async fn get_steam_transactions(configuration: &configuration::Configuration, ) -> Result<Vec<models::Transaction>, Error<GetSteamTransactionsError>> {
pub async fn get_steam_transactions(
configuration: &configuration::Configuration,
) -> Result<Vec<models::Transaction>, Error<GetSteamTransactionsError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!("{}/Steam/transactions", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
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) = local_var_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.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}

let local_var_req = local_var_req_builder.build()?;
Expand All @@ -160,23 +201,32 @@ pub async fn get_steam_transactions(configuration: &configuration::Configuration
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<GetSteamTransactionsError> = 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 };
let local_var_entity: Option<GetSteamTransactionsError> =
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))
}
}

/// List all existing Subscriptions. For example, \"vrchatplus-monthly\" and \"vrchatplus-yearly\".
pub async fn get_subscriptions(configuration: &configuration::Configuration, ) -> Result<Vec<models::Subscription>, Error<GetSubscriptionsError>> {
pub async fn get_subscriptions(
configuration: &configuration::Configuration,
) -> Result<Vec<models::Subscription>, Error<GetSubscriptionsError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!("{}/subscriptions", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
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) = local_var_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.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}

let local_var_req = local_var_req_builder.build()?;
Expand All @@ -188,9 +238,13 @@ pub async fn get_subscriptions(configuration: &configuration::Configuration, ) -
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<GetSubscriptionsError> = 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 };
let local_var_entity: Option<GetSubscriptionsError> =
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))
}
}

Loading