diff --git a/http/src/client/requester.rs b/http/src/client/requester.rs index db6f57a..d1d7385 100644 --- a/http/src/client/requester.rs +++ b/http/src/client/requester.rs @@ -128,7 +128,7 @@ pub trait Requester: Sized + Sync match either { Some(Either::Left(mut rx)) => return rx.recv().await.map_err(Into::into), Some(Either::Right(tx)) => break tx, - None => { + _none => { if let Some(c) = self.try_get(&id).await { return Ok(c); } @@ -232,7 +232,7 @@ pub trait Requester: Sized + Sync txs.insert(id.clone(), tx); break true; } - None => { + _none => { if let Some(c) = check_cache::(self, &id).await { @@ -539,7 +539,7 @@ async fn get_or_ids< match either { Some(Either::Left(mut rx)) => return rx.recv().await.map_err(Into::into), Some(Either::Right(tx)) => break tx, - None => { + _none => { if let Some(c) = check_cache::(req, "").await { return Ok(c); } diff --git a/http/tests/account_new.rs b/http/tests/account_new.rs new file mode 100644 index 0000000..9f3a02f --- /dev/null +++ b/http/tests/account_new.rs @@ -0,0 +1,167 @@ +#![cfg(feature = "blocking")] + +use gw2lib::{ + model::authenticated::account::{ + achievements::AccountAchievements, + dailycrafting::AccountDailyCrafting, + dungeons::AccountDungeons, + dyes::AccountDyes, + finishers::AccountFinishers, + gliders::AccountGliders, + home::{AccountHomeCats, AccountHomeNodes}, + inventory::AccountInventory, + luck::AccountLuckVec, + mailcarriers::AccountMailCarriers, + mapchests::AccountMapChests, + masteries::{AccountMasteries, AccountMasteryPoints}, + minis::AccountMinis, + mounts::{AccountMountSkins, AccountMountTypes}, + outfits::AccountOutfits, + pvp::AccountPvpHeroes, + recipes::AccountRecipes, + skins::AccountSkins, + titles::AccountTitles, + worldbosses::AccountWorldBosses, + }, + Requester, +}; + +pub mod setup; + +#[test] +fn account_achievements() { + let client = setup::setup(); + let _: AccountAchievements = client.get().unwrap(); +} + +#[test] +fn account_dailycrafting() { + let client = setup::setup(); + let _: AccountDailyCrafting = client.get().unwrap(); +} + +#[test] +fn account_dungeons() { + let client = setup::setup(); + let _: AccountDungeons = client.get().unwrap(); +} + +#[test] +fn account_dyes() { + let client = setup::setup(); + let _: AccountDyes = client.get().unwrap(); +} + +#[test] +fn account_finishers() { + let client = setup::setup(); + let _: AccountFinishers = client.get().unwrap(); +} + +#[test] +fn account_gliders() { + let client = setup::setup(); + let _: AccountGliders = client.get().unwrap(); +} + +#[test] +fn account_home_cats() { + let client = setup::setup(); + let _: AccountHomeCats = client.get().unwrap(); +} + +#[test] +fn account_home_nodes() { + let client = setup::setup(); + let _: AccountHomeNodes = client.get().unwrap(); +} + +#[test] +fn account_inventory() { + let client = setup::setup(); + let _: AccountInventory = client.get().unwrap(); +} + +#[test] +fn account_luck() { + let client = setup::setup(); + let _: AccountLuckVec = client.get().unwrap(); +} + +#[test] +fn account_mailcarriers() { + let client = setup::setup(); + let _: AccountMailCarriers = client.get().unwrap(); +} + +#[test] +fn account_mapchests() { + let client = setup::setup(); + let _: AccountMapChests = client.get().unwrap(); +} + +#[test] +fn account_masteries() { + let client = setup::setup(); + let _: AccountMasteries = client.get().unwrap(); +} + +#[test] +fn account_mastery_points() { + let client = setup::setup(); + let _: AccountMasteryPoints = client.get().unwrap(); +} + +#[test] +fn account_minis() { + let client = setup::setup(); + let _: AccountMinis = client.get().unwrap(); +} + +#[test] +fn account_mount_skins() { + let client = setup::setup(); + let _: AccountMountSkins = client.get().unwrap(); +} + +#[test] +fn account_mount_types() { + let client = setup::setup(); + let _: AccountMountTypes = client.get().unwrap(); +} + +#[test] +fn account_outfits() { + let client = setup::setup(); + let _: AccountOutfits = client.get().unwrap(); +} + +#[test] +fn account_pvp_heroes() { + let client = setup::setup(); + let _: AccountPvpHeroes = client.get().unwrap(); +} + +#[test] +fn account_recipes() { + let client = setup::setup(); + let _: AccountRecipes = client.get().unwrap(); +} + +#[test] +fn account_skins() { + let client = setup::setup(); + let _: AccountSkins = client.get().unwrap(); +} + +#[test] +fn account_titles() { + let client = setup::setup(); + let _: AccountTitles = client.get().unwrap(); +} + +#[test] +fn account_worldbosses() { + let client = setup::setup(); + let _: AccountWorldBosses = client.get().unwrap(); +} diff --git a/http/tests/achievements.rs b/http/tests/achievements.rs index 179e9ac..17ab480 100644 --- a/http/tests/achievements.rs +++ b/http/tests/achievements.rs @@ -1,9 +1,7 @@ #![cfg(feature = "blocking")] use gw2lib::{ - model::achievements::{ - categories::AchievementCategory, groups::AchievementGroup, Achievement, - }, + model::achievements::{categories::AchievementCategory, groups::AchievementGroup, Achievement}, Requester, }; diff --git a/http/tests/authenticated_new.rs b/http/tests/authenticated_new.rs new file mode 100644 index 0000000..c2bbb97 --- /dev/null +++ b/http/tests/authenticated_new.rs @@ -0,0 +1,56 @@ +#![cfg(feature = "blocking")] + +use gw2lib::{ + model::authenticated::{ + characters::Character, + commerce::{CurrentBuyTransactions, HistoryBuyTransactions}, + pvp::{PvpStandings, PvpStats}, + }, + Requester, +}; + +use crate::setup::character_name; + +pub mod setup; + +#[test] +fn heropoints() { + let client = setup::setup(); + use gw2lib::model::authenticated::characters::Heropoints; + let _: Heropoints = client.single(character_name()).unwrap(); +} + +#[test] +fn sab() { + let client = setup::setup(); + use gw2lib::model::authenticated::characters::Sab; + let char_ids: Vec = + client.ids::().unwrap(); + if let Some(name) = char_ids.first() { + let _: Sab = client.single(name.clone()).unwrap(); + } +} + +#[test] +fn pvp_stats() { + let client = setup::setup(); + let _: PvpStats = client.get().unwrap(); +} + +#[test] +fn pvp_standings() { + let client = setup::setup(); + let _: PvpStandings = client.get().unwrap(); +} + +#[test] +fn commerce_current_buys() { + let client = setup::setup(); + let _: CurrentBuyTransactions = client.get().unwrap(); +} + +#[test] +fn commerce_history_buys() { + let client = setup::setup(); + let _: HistoryBuyTransactions = client.get().unwrap(); +} diff --git a/http/tests/daily_rewards.rs b/http/tests/daily_rewards.rs new file mode 100644 index 0000000..b1d9a32 --- /dev/null +++ b/http/tests/daily_rewards.rs @@ -0,0 +1,31 @@ +#![cfg(feature = "blocking")] + +use gw2lib::{ + model::daily_rewards::{ + dailycrafting::DailyCrafting, mapchests::MapChest, worldbosses::WorldBoss, + }, + Requester, +}; + +pub mod setup; + +#[test] +fn dailycrafting() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); +} + +#[test] +fn mapchests() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); +} + +#[test] +fn worldbosses() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); +} diff --git a/http/tests/game_mechanics.rs b/http/tests/game_mechanics.rs new file mode 100644 index 0000000..3dea567 --- /dev/null +++ b/http/tests/game_mechanics.rs @@ -0,0 +1,93 @@ +#![cfg(feature = "blocking")] + +use gw2lib::{ + model::game_mechanics::{ + legends::Legend, + masteries::Mastery, + mounts::{MountSkin, MountType}, + outfits::Outfit, + pets::Pet, + professions::ProfessionInfo, + races::Race, + skills::Skill, + specializations::Specialization, + traits::Trait, + }, + Requester, +}; + +pub mod setup; + +#[test] +fn masteries() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); + let _: Mastery = client.single(ids[0]).unwrap(); +} + +#[test] +fn mount_skins() { + let client = setup::setup(); + let _: MountSkin = client.single(1u32).unwrap(); +} + +#[test] +fn mount_types() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); +} + +#[test] +fn outfits() { + let client = setup::setup(); + let _: Outfit = client.single(1u32).unwrap(); +} + +#[test] +fn pets() { + let client = setup::setup(); + let _: Pet = client.single(1u16).unwrap(); +} + +#[test] +fn professions() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); + let _: ProfessionInfo = client.single(ids[0].clone()).unwrap(); +} + +#[test] +fn races() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); +} + +#[test] +fn skills() { + let client = setup::setup(); + let _: Skill = client.single(1110u32).unwrap(); +} + +#[test] +fn specializations() { + let client = setup::setup(); + let _: Specialization = client.single(1u16).unwrap(); +} + +#[test] +fn traits() { + let client = setup::setup(); + let _: Trait = client.single(214u16).unwrap(); +} + +#[test] +fn legends() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); + let _: Legend = client.single(ids[0].clone()).unwrap(); +} diff --git a/http/tests/guild.rs b/http/tests/guild.rs new file mode 100644 index 0000000..8b9f344 --- /dev/null +++ b/http/tests/guild.rs @@ -0,0 +1,65 @@ +#![cfg(feature = "blocking")] + +use gw2lib::{ + model::guild::{ + authenticated::{GuildLog, GuildMembers, GuildRanks}, + emblem::{EmblemBackground, EmblemForeground}, + guild::{Guild, GuildPermission}, + upgrades::GuildUpgrade, + }, + Requester, +}; + +pub mod setup; + +// Guild ID for "Fay Timewhisper" +const GUILD_ID: &str = "87B97E30-580E-E811-81A1-06AEA39922EA"; + +#[test] +fn guild_info() { + let client = setup::setup(); + let _: Guild = client.single(GUILD_ID.to_string()).unwrap(); +} + +#[test] +fn guild_permissions() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); +} + +#[test] +fn guild_upgrades() { + let client = setup::setup(); + let _: GuildUpgrade = client.single(38u64).unwrap(); +} + +#[test] +fn emblem_backgrounds() { + let client = setup::setup(); + let _: EmblemBackground = client.single(1u32).unwrap(); +} + +#[test] +fn emblem_foregrounds() { + let client = setup::setup(); + let _: EmblemForeground = client.single(1u32).unwrap(); +} + +#[test] +fn guild_log() { + let client = setup::setup(); + let _: GuildLog = client.single(GUILD_ID.to_string()).unwrap(); +} + +#[test] +fn guild_members() { + let client = setup::setup(); + let _: GuildMembers = client.single(GUILD_ID.to_string()).unwrap(); +} + +#[test] +fn guild_ranks() { + let client = setup::setup(); + let _: GuildRanks = client.single(GUILD_ID.to_string()).unwrap(); +} diff --git a/http/tests/misc_new.rs b/http/tests/misc_new.rs new file mode 100644 index 0000000..3e4b0a7 --- /dev/null +++ b/http/tests/misc_new.rs @@ -0,0 +1,54 @@ +#![cfg(feature = "blocking")] + +use gw2lib::{ + model::{ + items::{finishers::Finisher, materials::MaterialCategory}, + misc::{dungeons::Dungeon, files::GameFile, minis::Mini, quaggans::Quaggan, titles::Title}, + }, + Requester, +}; + +pub mod setup; + +#[test] +fn dungeons() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); +} + +#[test] +fn files() { + let client = setup::setup(); + let _: GameFile = client.single("map_complete".to_string()).unwrap(); +} + +#[test] +fn quaggans() { + let client = setup::setup(); + let _: Quaggan = client.single("404".to_string()).unwrap(); +} + +#[test] +fn minis() { + let client = setup::setup(); + let _: Mini = client.single(1u64).unwrap(); +} + +#[test] +fn titles() { + let client = setup::setup(); + let _: Title = client.single(1u16).unwrap(); +} + +#[test] +fn finishers() { + let client = setup::setup(); + let _: Finisher = client.single(1u32).unwrap(); +} + +#[test] +fn materials() { + let client = setup::setup(); + let _: MaterialCategory = client.single(5u32).unwrap(); +} diff --git a/http/tests/pvp_new.rs b/http/tests/pvp_new.rs new file mode 100644 index 0000000..503a7f0 --- /dev/null +++ b/http/tests/pvp_new.rs @@ -0,0 +1,27 @@ +#![cfg(feature = "blocking")] + +use gw2lib::{ + model::pvp::{amulets::Amulet, ranks::PvpRank, seasons::PvpSeason}, + Requester, +}; + +pub mod setup; + +#[test] +fn pvp_amulets() { + let client = setup::setup(); + let _: Amulet = client.single(4u16).unwrap(); +} + +#[test] +fn pvp_ranks() { + let client = setup::setup(); + let _: PvpRank = client.single(1u32).unwrap(); +} + +#[test] +fn pvp_seasons() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); +} diff --git a/http/tests/story.rs b/http/tests/story.rs new file mode 100644 index 0000000..941e445 --- /dev/null +++ b/http/tests/story.rs @@ -0,0 +1,38 @@ +#![cfg(feature = "blocking")] + +use gw2lib::{ + model::story::{ + backstory::{BackstoryAnswer, BackstoryQuestion}, + stories::{Story, StorySeason}, + }, + Requester, +}; + +pub mod setup; + +#[test] +fn backstory_answers() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); +} + +#[test] +fn backstory_questions() { + let client = setup::setup(); + let _: BackstoryQuestion = client.single(7u32).unwrap(); +} + +#[test] +fn stories() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); +} + +#[test] +fn story_seasons() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); +} diff --git a/http/tests/wvw.rs b/http/tests/wvw.rs new file mode 100644 index 0000000..4811f8c --- /dev/null +++ b/http/tests/wvw.rs @@ -0,0 +1,43 @@ +#![cfg(feature = "blocking")] + +use gw2lib::{ + model::wvw::{ + abilities::Ability, matches::WvwMatch, objectives::WvwObjective, ranks::WvwRank, + upgrades::WvwUpgrade, + }, + Requester, +}; + +pub mod setup; + +#[test] +fn abilities() { + let client = setup::setup(); + let _: Ability = client.single(2u32).unwrap(); +} + +#[test] +fn matches() { + let client = setup::setup(); + let ids: Vec = client.ids::().unwrap(); + assert!(!ids.is_empty()); + let _: WvwMatch = client.single(ids[0].clone()).unwrap(); +} + +#[test] +fn objectives() { + let client = setup::setup(); + let _: WvwObjective = client.single("1099-99".to_string()).unwrap(); +} + +#[test] +fn ranks() { + let client = setup::setup(); + let _: WvwRank = client.single(1u32).unwrap(); +} + +#[test] +fn upgrades() { + let client = setup::setup(); + let _: WvwUpgrade = client.single(5u32).unwrap(); +} diff --git a/model/Cargo.toml b/model/Cargo.toml index 2f88513..9946be8 100644 --- a/model/Cargo.toml +++ b/model/Cargo.toml @@ -26,3 +26,6 @@ version = "1.0.160" features = [ "derive" ] + +[dependencies.serde_json] +version = "1.0" diff --git a/model/README.md b/model/README.md index 99fca4d..8b50a34 100644 --- a/model/README.md +++ b/model/README.md @@ -32,92 +32,91 @@ Example commit adding an endpoint: [bcb0bd3](https://github.com/greaka/gw2lib/co - [x] account - [x] achievements - [x] bank - - [ ] dailycrafting - - [ ] dungeons - - [ ] dyes - - [ ] finishers - - [x] inventory - - [ ] gliders + - [x] dailycrafting + - [x] dungeons + - [x] dyes + - [x] finishers + - [x] gliders - home - - [ ] cats - - [ ] nodes - - [ ] inventory - - [ ] luck - - [ ] mailcarries - - [ ] mapchests - - [ ] masteries + - [x] cats + - [x] nodes + - [x] inventory + - [x] luck + - [x] mailcarriers + - [x] mapchests + - [x] masteries - mastery - - [ ] points + - [x] points - [x] materials - - [ ] minis + - [x] minis - mounts - - [ ] skins - - [ ] types - - [ ] outfits + - [x] skins + - [x] types + - [x] outfits - pvp - - [ ] heroes + - [x] heroes - [x] raids - - [ ] recipes - - [ ] skins - - [ ] titles + - [x] recipes + - [x] skins + - [x] titles - [x] wallet - wizardsvault - [x] listings - [x] daily - [x] weekly - [x] special - - [ ] worldbosses + - [x] worldbosses - characters - [x] :id - [x] backstory - [x] core - [x] crafting - [x] equipment - - [ ] heropoints + - [x] heropoints - [x] inventory - [x] recipes - - [ ] sab + - [x] sab - [x] skills - [x] specializations - [x] training - commerce - [x] delivery - - [ ] transactions + - [x] transactions - pvp - - [ ] stats - - [ ] games - - [ ] standings - - [ ] tokeninfo + - [x] stats + - [x] games + - [x] standings + - [x] tokeninfo - daily rewards - - [ ] dailycrafting - - [ ] mapchests - - [ ] worldbosses + - [x] dailycrafting + - [x] mapchests + - [x] worldbosses - game mechanics - - [ ] masteries - - [ ] mounts - - [ ] skins - - [ ] types - - [ ] outfits + - [x] masteries + - [x] mounts + - [x] skins + - [x] types + - [x] outfits - [x] pets - - [ ] professions - - [ ] races - - [ ] specializations - - [ ] skills - - [ ] traits - - [ ] legends + - [x] professions + - [x] races + - [x] specializations + - [x] skills + - [x] traits + - [x] legends - guild - guild - - [ ] :id - - [ ] permissions + - [x] :id + - [x] permissions - [ ] search - - [ ] upgrades - - [ ] emblem + - [x] upgrades + - [x] emblem - guild authenticated - guild - :id - - [ ] log - - [ ] members - - [ ] ranks + - [x] log + - [x] members + - [x] ranks - [ ] stash - [ ] treasury - [ ] teams @@ -127,12 +126,12 @@ Example commit adding an endpoint: [bcb0bd3](https://github.com/greaka/gw2lib/co - [x] cats - [x] nodes - items - - [ ] finishers + - [x] finishers - [x] items - [x] itemstats - - [ ] materials + - [x] materials - pvp - - [ ] amulets + - [x] amulets - [x] recipes - [ ] search - [x] skins @@ -141,25 +140,25 @@ Example commit adding an endpoint: [bcb0bd3](https://github.com/greaka/gw2lib/co - [x] maps - Miscellaneous - [x] build - - [ ] colors - - [ ] currencies - - [ ] dungeons - - [ ] files - - [ ] quaggans - - [ ] minis + - [x] colors + - [x] currencies + - [x] dungeons + - [x] files + - [x] quaggans + - [x] minis - [x] raids - - [ ] titles + - [x] titles - [x] worlds - Story - backstory - - [ ] answers - - [ ] questions - - [ ] stories - - [ ] seasons + - [x] answers + - [x] questions + - [x] stories + - [x] seasons - sPvP - - [ ] pvp - - [ ] ranks - - [ ] seasons + - [x] pvp + - [x] ranks + - [x] seasons - [ ] leaderboards - trading post - commerce @@ -169,9 +168,9 @@ Example commit adding an endpoint: [bcb0bd3](https://github.com/greaka/gw2lib/co - [ ] gems - [ ] prices - world v world - - [ ] wvw - - [ ] abilities - - [ ] matches - - [ ] objectives - - [ ] ranks - - [ ] upgrades + - [x] wvw + - [x] abilities + - [x] matches + - [x] objectives + - [x] ranks + - [x] upgrades diff --git a/model/src/authenticated.rs b/model/src/authenticated.rs index 6f6a089..4d313ae 100644 --- a/model/src/authenticated.rs +++ b/model/src/authenticated.rs @@ -6,6 +6,7 @@ use crate::{Endpoint, FixedEndpoint, TimeStamp}; pub mod account; pub mod characters; pub mod commerce; +pub mod pvp; #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(test, serde(deny_unknown_fields))] diff --git a/model/src/authenticated/account.rs b/model/src/authenticated/account.rs index 8abf792..080b047 100644 --- a/model/src/authenticated/account.rs +++ b/model/src/authenticated/account.rs @@ -1,10 +1,28 @@ pub mod achievements; pub mod bank; +pub mod dailycrafting; +pub mod dungeons; +pub mod dyes; +pub mod finishers; +pub mod gliders; +pub mod home; pub mod inventory; +pub mod luck; +pub mod mailcarriers; +pub mod mapchests; +pub mod masteries; pub mod materials; +pub mod minis; +pub mod mounts; +pub mod outfits; +pub mod pvp; pub mod raids; +pub mod recipes; +pub mod skins; +pub mod titles; pub mod wallet; pub mod wizards_vault; +pub mod worldbosses; use std::collections::BTreeSet; diff --git a/model/src/authenticated/account/dailycrafting.rs b/model/src/authenticated/account/dailycrafting.rs new file mode 100644 index 0000000..0d43849 --- /dev/null +++ b/model/src/authenticated/account/dailycrafting.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountDailyCrafting(pub Vec); + +impl Endpoint for AccountDailyCrafting { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/dailycrafting"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountDailyCrafting {} diff --git a/model/src/authenticated/account/dungeons.rs b/model/src/authenticated/account/dungeons.rs new file mode 100644 index 0000000..12bf1b3 --- /dev/null +++ b/model/src/authenticated/account/dungeons.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountDungeons(pub Vec); + +impl Endpoint for AccountDungeons { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/dungeons"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountDungeons {} diff --git a/model/src/authenticated/account/dyes.rs b/model/src/authenticated/account/dyes.rs new file mode 100644 index 0000000..2d5a6c3 --- /dev/null +++ b/model/src/authenticated/account/dyes.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::{misc::colors::ColorId, Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountDyes(pub Vec); + +impl Endpoint for AccountDyes { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/dyes"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountDyes {} diff --git a/model/src/authenticated/account/finishers.rs b/model/src/authenticated/account/finishers.rs new file mode 100644 index 0000000..6809d79 --- /dev/null +++ b/model/src/authenticated/account/finishers.rs @@ -0,0 +1,21 @@ +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct AccountFinisher { + pub id: u32, + pub permanent: bool, + pub quantity: Option, +} + +pub type AccountFinishers = Vec; + +impl Endpoint for AccountFinishers { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/finishers"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountFinishers {} diff --git a/model/src/authenticated/account/gliders.rs b/model/src/authenticated/account/gliders.rs new file mode 100644 index 0000000..fed8172 --- /dev/null +++ b/model/src/authenticated/account/gliders.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountGliders(pub Vec); + +impl Endpoint for AccountGliders { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/gliders"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountGliders {} diff --git a/model/src/authenticated/account/home.rs b/model/src/authenticated/account/home.rs new file mode 100644 index 0000000..9baf956 --- /dev/null +++ b/model/src/authenticated/account/home.rs @@ -0,0 +1,27 @@ +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountHomeCats(pub Vec); + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountHomeNodes(pub Vec); + +impl Endpoint for AccountHomeCats { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/home/cats"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountHomeCats {} + +impl Endpoint for AccountHomeNodes { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/home/nodes"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountHomeNodes {} diff --git a/model/src/authenticated/account/inventory.rs b/model/src/authenticated/account/inventory.rs index 3fdf5c2..445247d 100644 --- a/model/src/authenticated/account/inventory.rs +++ b/model/src/authenticated/account/inventory.rs @@ -1,25 +1,28 @@ use serde::{Deserialize, Serialize}; use crate::{ - authenticated::characters::Binding, + authenticated::characters::{Binding, Stats}, items::{skins::SkinId, ItemId}, + misc::colors::ColorId, Endpoint, FixedEndpoint, }; -pub type AccountInventory = Vec>; - -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, Eq)] +#[derive(Clone, Debug, Serialize, Deserialize)] #[cfg_attr(test, serde(deny_unknown_fields))] -pub struct AccountInventoryItem { +pub struct SharedInventorySlot { pub id: ItemId, - pub count: u8, - pub charges: Option, - pub upgrades: Option>, + pub count: u32, + pub charges: Option, pub skin: Option, + pub upgrades: Option>, pub infusions: Option>, + pub dyes: Option>>, + pub stats: Option, pub binding: Option, } +pub type AccountInventory = Vec>; + impl Endpoint for AccountInventory { const AUTHENTICATED: bool = true; const LOCALE: bool = false; diff --git a/model/src/authenticated/account/luck.rs b/model/src/authenticated/account/luck.rs new file mode 100644 index 0000000..07674e1 --- /dev/null +++ b/model/src/authenticated/account/luck.rs @@ -0,0 +1,20 @@ +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct AccountLuck { + pub id: String, + pub value: u64, +} + +pub type AccountLuckVec = Vec; + +impl Endpoint for AccountLuckVec { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/luck"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountLuckVec {} diff --git a/model/src/authenticated/account/mailcarriers.rs b/model/src/authenticated/account/mailcarriers.rs new file mode 100644 index 0000000..61e3e36 --- /dev/null +++ b/model/src/authenticated/account/mailcarriers.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountMailCarriers(pub Vec); + +impl Endpoint for AccountMailCarriers { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/mailcarriers"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountMailCarriers {} diff --git a/model/src/authenticated/account/mapchests.rs b/model/src/authenticated/account/mapchests.rs new file mode 100644 index 0000000..ce93e56 --- /dev/null +++ b/model/src/authenticated/account/mapchests.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountMapChests(pub Vec); + +impl Endpoint for AccountMapChests { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/mapchests"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountMapChests {} diff --git a/model/src/authenticated/account/masteries.rs b/model/src/authenticated/account/masteries.rs new file mode 100644 index 0000000..65d6e0c --- /dev/null +++ b/model/src/authenticated/account/masteries.rs @@ -0,0 +1,43 @@ +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct AccountMastery { + pub id: u32, + pub level: u32, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct MasteryRegionTotal { + pub region: String, + pub spent: u32, + pub earned: u32, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct AccountMasteryPoints { + pub totals: Vec, + pub unlocked: Vec, +} + +pub type AccountMasteries = Vec; + +impl Endpoint for AccountMasteries { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/masteries"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountMasteries {} + +impl Endpoint for AccountMasteryPoints { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/mastery/points"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountMasteryPoints {} diff --git a/model/src/authenticated/account/minis.rs b/model/src/authenticated/account/minis.rs new file mode 100644 index 0000000..a6915d9 --- /dev/null +++ b/model/src/authenticated/account/minis.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::{misc::minis::MiniPetId, Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountMinis(pub Vec); + +impl Endpoint for AccountMinis { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/minis"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountMinis {} diff --git a/model/src/authenticated/account/mounts.rs b/model/src/authenticated/account/mounts.rs new file mode 100644 index 0000000..0439a71 --- /dev/null +++ b/model/src/authenticated/account/mounts.rs @@ -0,0 +1,27 @@ +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountMountSkins(pub Vec); + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountMountTypes(pub Vec); + +impl Endpoint for AccountMountSkins { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/mounts/skins"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountMountSkins {} + +impl Endpoint for AccountMountTypes { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/mounts/types"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountMountTypes {} diff --git a/model/src/authenticated/account/outfits.rs b/model/src/authenticated/account/outfits.rs new file mode 100644 index 0000000..121cc93 --- /dev/null +++ b/model/src/authenticated/account/outfits.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountOutfits(pub Vec); + +impl Endpoint for AccountOutfits { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/outfits"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountOutfits {} diff --git a/model/src/authenticated/account/pvp.rs b/model/src/authenticated/account/pvp.rs new file mode 100644 index 0000000..2c8f336 --- /dev/null +++ b/model/src/authenticated/account/pvp.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountPvpHeroes(pub Vec); + +impl Endpoint for AccountPvpHeroes { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/pvp/heroes"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountPvpHeroes {} diff --git a/model/src/authenticated/account/recipes.rs b/model/src/authenticated/account/recipes.rs new file mode 100644 index 0000000..52113b6 --- /dev/null +++ b/model/src/authenticated/account/recipes.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::{items::recipes::RecipeId, Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountRecipes(pub Vec); + +impl Endpoint for AccountRecipes { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/recipes"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountRecipes {} diff --git a/model/src/authenticated/account/skins.rs b/model/src/authenticated/account/skins.rs new file mode 100644 index 0000000..4957993 --- /dev/null +++ b/model/src/authenticated/account/skins.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::{items::skins::SkinId, Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountSkins(pub Vec); + +impl Endpoint for AccountSkins { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/skins"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountSkins {} diff --git a/model/src/authenticated/account/titles.rs b/model/src/authenticated/account/titles.rs new file mode 100644 index 0000000..421b041 --- /dev/null +++ b/model/src/authenticated/account/titles.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::{misc::titles::TitleId, Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountTitles(pub Vec); + +impl Endpoint for AccountTitles { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/titles"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountTitles {} diff --git a/model/src/authenticated/account/worldbosses.rs b/model/src/authenticated/account/worldbosses.rs new file mode 100644 index 0000000..14d42f1 --- /dev/null +++ b/model/src/authenticated/account/worldbosses.rs @@ -0,0 +1,15 @@ +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct AccountWorldBosses(pub Vec); + +impl Endpoint for AccountWorldBosses { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/account/worldbosses"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for AccountWorldBosses {} diff --git a/model/src/authenticated/characters.rs b/model/src/authenticated/characters.rs index 0550c8b..24eebd5 100644 --- a/model/src/authenticated/characters.rs +++ b/model/src/authenticated/characters.rs @@ -499,3 +499,68 @@ impl Endpoint for Training { const URL: &'static str = "v2/characters"; const VERSION: &'static str = "2022-06-14T00:00:00.000Z"; } + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct Heropoints(pub Vec); + +impl EndpointWithId for Heropoints { + type IdType = CharacterId; + + fn format_url(id: &str) -> String { + format!("{}/{}/heropoints", Self::URL, id) + } +} + +impl Endpoint for Heropoints { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/characters"; + const VERSION: &'static str = "2022-06-14T00:00:00.000Z"; +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct SabZone { + pub id: u32, + pub mode: String, + pub d: u32, + pub z: u32, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct SabUnlock { + pub id: u32, + pub name: String, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct SabSong { + pub id: u32, + pub name: String, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Sab { + pub zones: Vec, + pub unlocks: Vec, + pub songs: Vec, +} + +impl EndpointWithId for Sab { + type IdType = CharacterId; + + fn format_url(id: &str) -> String { + format!("{}/{}/sab", Self::URL, id) + } +} + +impl Endpoint for Sab { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/characters"; + const VERSION: &'static str = "2022-06-14T00:00:00.000Z"; +} diff --git a/model/src/authenticated/commerce.rs b/model/src/authenticated/commerce.rs index 4be6e14..492c417 100644 --- a/model/src/authenticated/commerce.rs +++ b/model/src/authenticated/commerce.rs @@ -1 +1,60 @@ +use serde::{Deserialize, Serialize}; + +use crate::{items::ItemId, Endpoint, FixedEndpoint, TimeStamp}; pub mod delivery; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Transaction { + pub id: u64, + pub item_id: ItemId, + pub price: u64, + pub quantity: u32, + pub created: TimeStamp, + pub purchased: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct CurrentBuyTransactions(pub Vec); +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct CurrentSellTransactions(pub Vec); +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct HistoryBuyTransactions(pub Vec); +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct HistorySellTransactions(pub Vec); + +impl Endpoint for CurrentBuyTransactions { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/commerce/transactions/current/buys"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for CurrentBuyTransactions {} + +impl Endpoint for CurrentSellTransactions { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/commerce/transactions/current/sells"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for CurrentSellTransactions {} + +impl Endpoint for HistoryBuyTransactions { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/commerce/transactions/history/buys"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for HistoryBuyTransactions {} + +impl Endpoint for HistorySellTransactions { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/commerce/transactions/history/sells"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for HistorySellTransactions {} diff --git a/model/src/authenticated/pvp.rs b/model/src/authenticated/pvp.rs new file mode 100644 index 0000000..2b76642 --- /dev/null +++ b/model/src/authenticated/pvp.rs @@ -0,0 +1,95 @@ +use std::collections::HashMap; + +use serde::{Deserialize, Serialize}; + +use crate::{Endpoint, FixedEndpoint, PagedEndpoint, TimeStamp}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct PvpResult { + pub wins: u32, + pub losses: u32, + pub desertions: u32, + pub byes: u32, + pub forfeits: u32, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct PvpStats { + pub pvp_rank: u32, + pub pvp_rank_points: u32, + pub pvp_rank_rollovers: u32, + pub aggregate: PvpResult, + pub professions: HashMap, + pub ladders: HashMap, +} + +impl Endpoint for PvpStats { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/pvp/stats"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for PvpStats {} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct PvpGameScores { + pub red: u32, + pub blue: u32, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct PvpGame { + pub id: String, + pub map_id: u32, + pub started: TimeStamp, + pub ended: TimeStamp, + pub result: String, + pub team: String, + pub profession: String, + pub rating_type: String, + pub rating_change: Option, + pub season: Option, + pub scores: PvpGameScores, +} + +impl Endpoint for PvpGame { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/pvp/games"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl PagedEndpoint for PvpGame {} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct PvpStandingResult { + pub total_points: u32, + pub division: u32, + pub tier: u32, + pub points: u32, + pub repeats: u32, + pub rating: Option, + pub decay: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct PvpStanding { + pub current: PvpStandingResult, + pub best: PvpStandingResult, + pub season_id: String, +} + +pub type PvpStandings = Vec; + +impl Endpoint for PvpStandings { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/pvp/standings"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for PvpStandings {} diff --git a/model/src/daily_rewards.rs b/model/src/daily_rewards.rs new file mode 100644 index 0000000..9c2b5c5 --- /dev/null +++ b/model/src/daily_rewards.rs @@ -0,0 +1,3 @@ +pub mod dailycrafting; +pub mod mapchests; +pub mod worldbosses; diff --git a/model/src/daily_rewards/dailycrafting.rs b/model/src/daily_rewards/dailycrafting.rs new file mode 100644 index 0000000..ab90110 --- /dev/null +++ b/model/src/daily_rewards/dailycrafting.rs @@ -0,0 +1,26 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct DailyCrafting { + pub id: String, +} + +impl Endpoint for DailyCrafting { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/dailycrafting"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for DailyCrafting { + type IdType = String; +} +impl BulkEndpoint for DailyCrafting { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/daily_rewards/mapchests.rs b/model/src/daily_rewards/mapchests.rs new file mode 100644 index 0000000..e5055be --- /dev/null +++ b/model/src/daily_rewards/mapchests.rs @@ -0,0 +1,26 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct MapChest { + pub id: String, +} + +impl Endpoint for MapChest { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/mapchests"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for MapChest { + type IdType = String; +} +impl BulkEndpoint for MapChest { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/daily_rewards/worldbosses.rs b/model/src/daily_rewards/worldbosses.rs new file mode 100644 index 0000000..7e1704c --- /dev/null +++ b/model/src/daily_rewards/worldbosses.rs @@ -0,0 +1,26 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct WorldBoss { + pub id: String, +} + +impl Endpoint for WorldBoss { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/worldbosses"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for WorldBoss { + type IdType = String; +} +impl BulkEndpoint for WorldBoss { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/game_mechanics.rs b/model/src/game_mechanics.rs index 56ebe26..d397551 100644 --- a/model/src/game_mechanics.rs +++ b/model/src/game_mechanics.rs @@ -1,4 +1,10 @@ +pub mod legends; +pub mod masteries; +pub mod mounts; +pub mod outfits; pub mod pets; +pub mod professions; +pub mod races; pub mod skills; pub mod specializations; pub mod traits; diff --git a/model/src/game_mechanics/legends.rs b/model/src/game_mechanics/legends.rs new file mode 100644 index 0000000..bd40d2b --- /dev/null +++ b/model/src/game_mechanics/legends.rs @@ -0,0 +1,30 @@ +use serde::{Deserialize, Serialize}; + +use crate::{game_mechanics::skills::SkillId, BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Legend { + pub id: String, + pub swap: SkillId, + pub heal: SkillId, + pub elite: SkillId, + pub utilities: Vec, +} + +impl Endpoint for Legend { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/legends"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Legend { + type IdType = String; +} +impl BulkEndpoint for Legend { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/game_mechanics/masteries.rs b/model/src/game_mechanics/masteries.rs new file mode 100644 index 0000000..dde91e7 --- /dev/null +++ b/model/src/game_mechanics/masteries.rs @@ -0,0 +1,43 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct MasteryLevel { + pub name: String, + pub description: String, + pub instruction: String, + pub icon: String, + pub point_cost: u32, + pub exp_cost: u64, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Mastery { + pub id: u32, + pub name: String, + pub requirement: String, + pub order: u32, + pub background: String, + pub region: String, + pub levels: Vec, +} + +impl Endpoint for Mastery { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/masteries"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Mastery { + type IdType = u32; +} +impl BulkEndpoint for Mastery { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/game_mechanics/mounts.rs b/model/src/game_mechanics/mounts.rs new file mode 100644 index 0000000..fa1cf9c --- /dev/null +++ b/model/src/game_mechanics/mounts.rs @@ -0,0 +1,64 @@ +use serde::{Deserialize, Serialize}; + +use crate::{misc::colors::ColorId, BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct MountDyeSlot { + pub color_id: ColorId, + pub material: String, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct MountSkin { + pub id: u32, + pub name: String, + pub icon: String, + pub dye_slots: Vec, + pub mount: String, +} + +impl Endpoint for MountSkin { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/mounts/skins"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for MountSkin { + type IdType = u32; +} +impl BulkEndpoint for MountSkin { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct MountType { + pub id: String, + pub name: String, + pub default_skin: u32, + pub skins: Vec, + pub skills: Option>, +} + +impl Endpoint for MountType { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/mounts/types"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for MountType { + type IdType = String; +} +impl BulkEndpoint for MountType { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/game_mechanics/outfits.rs b/model/src/game_mechanics/outfits.rs new file mode 100644 index 0000000..45ecc2d --- /dev/null +++ b/model/src/game_mechanics/outfits.rs @@ -0,0 +1,29 @@ +use serde::{Deserialize, Serialize}; + +use crate::{items::ItemId, BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Outfit { + pub id: u32, + pub name: String, + pub icon: String, + pub unlock_items: Vec, +} + +impl Endpoint for Outfit { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/outfits"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Outfit { + type IdType = u32; +} +impl BulkEndpoint for Outfit { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/game_mechanics/pets.rs b/model/src/game_mechanics/pets.rs index e2f16c0..d67c90b 100644 --- a/model/src/game_mechanics/pets.rs +++ b/model/src/game_mechanics/pets.rs @@ -1,7 +1,6 @@ use serde::{Deserialize, Serialize}; -pub use crate::game_mechanics::skills::SkillId; -use crate::*; +use crate::{game_mechanics::skills::SkillId, BulkEndpoint, Endpoint, EndpointWithId}; pub type PetId = u16; diff --git a/model/src/game_mechanics/professions.rs b/model/src/game_mechanics/professions.rs new file mode 100644 index 0000000..b506420 --- /dev/null +++ b/model/src/game_mechanics/professions.rs @@ -0,0 +1,37 @@ +use serde::{Deserialize, Serialize}; + +use crate::{ + game_mechanics::specializations::SpecializationId, BulkEndpoint, Endpoint, EndpointWithId, +}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct ProfessionInfo { + pub id: String, + pub name: String, + pub icon: String, + pub icon_big: String, + pub specializations: Vec, + pub weapons: Option, + pub flags: Option>, + pub skills: Option>, + pub training: Option>, + pub skills_by_palette: Option>, +} + +impl Endpoint for ProfessionInfo { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/professions"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for ProfessionInfo { + type IdType = String; +} +impl BulkEndpoint for ProfessionInfo { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/game_mechanics/races.rs b/model/src/game_mechanics/races.rs new file mode 100644 index 0000000..71d8621 --- /dev/null +++ b/model/src/game_mechanics/races.rs @@ -0,0 +1,28 @@ +use serde::{Deserialize, Serialize}; + +use crate::{game_mechanics::skills::SkillId, BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Race { + pub id: String, + pub name: String, + pub skills: Vec, +} + +impl Endpoint for Race { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/races"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Race { + type IdType = String; +} +impl BulkEndpoint for Race { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/game_mechanics/skills.rs b/model/src/game_mechanics/skills.rs index b6ba572..219bfb4 100644 --- a/model/src/game_mechanics/skills.rs +++ b/model/src/game_mechanics/skills.rs @@ -75,3 +75,56 @@ pub struct TraitedFact { /// array index of Fact pub overrides: Option, } + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Skill { + pub id: SkillId, + pub name: String, + pub description: Option, + pub icon: Option, + pub chat_link: Option, + #[serde(rename = "type")] + pub _type: Option, + pub weapon_type: Option, + pub professions: Option>, + pub slot: Option, + pub facts: Option>, + pub traited_facts: Option>, + pub categories: Option>, + pub attunement: Option, + pub cost: Option, + pub dual_wield: Option, + pub flip_skill: Option, + pub initiative: Option, + pub next_chain: Option, + pub prev_chain: Option, + pub transform_skills: Option>, + pub bundle_skills: Option>, + pub toolbelt_skill: Option, + pub specialization: Option, + pub subtype: Option, + pub flags: Option>, + pub log: Option, + pub ranges: Option>, + pub recharge: Option, +} + +impl Endpoint for Skill { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/skills"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Skill { + type IdType = SkillId; +} +impl BulkEndpoint for Skill { + const ALL: bool = false; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/game_mechanics/specializations.rs b/model/src/game_mechanics/specializations.rs index 8b8e290..8ac01e3 100644 --- a/model/src/game_mechanics/specializations.rs +++ b/model/src/game_mechanics/specializations.rs @@ -1 +1,38 @@ pub type SpecializationId = u16; + +use serde::{Deserialize, Serialize}; + +use crate::{game_mechanics::traits::TraitId, BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Specialization { + pub id: SpecializationId, + pub name: String, + pub profession: String, + pub elite: bool, + pub minor_traits: Vec, + pub major_traits: Vec, + pub icon: String, + pub background: String, + pub weapon_trait: Option, + pub profession_icon: Option, + pub profession_icon_big: Option, +} + +impl Endpoint for Specialization { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/specializations"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Specialization { + type IdType = SpecializationId; +} +impl BulkEndpoint for Specialization { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/game_mechanics/traits.rs b/model/src/game_mechanics/traits.rs index fb6d0f3..cd64254 100644 --- a/model/src/game_mechanics/traits.rs +++ b/model/src/game_mechanics/traits.rs @@ -1 +1,39 @@ pub type TraitId = u16; + +use serde::{Deserialize, Serialize}; + +use crate::{ + game_mechanics::specializations::SpecializationId, BulkEndpoint, Endpoint, EndpointWithId, +}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Trait { + pub id: TraitId, + pub tier: u8, + pub order: u8, + pub name: String, + pub description: Option, + pub slot: String, + pub facts: Option>, + pub traited_facts: Option>, + pub specialization: Option, + pub icon: String, +} + +impl Endpoint for Trait { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/traits"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Trait { + type IdType = TraitId; +} +impl BulkEndpoint for Trait { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/guild.rs b/model/src/guild.rs index 9460bc0..2054065 100644 --- a/model/src/guild.rs +++ b/model/src/guild.rs @@ -1 +1,4 @@ +pub mod authenticated; +pub mod emblem; +pub mod guild; pub mod upgrades; diff --git a/model/src/guild/authenticated.rs b/model/src/guild/authenticated.rs new file mode 100644 index 0000000..0170795 --- /dev/null +++ b/model/src/guild/authenticated.rs @@ -0,0 +1,213 @@ +use std::collections::HashMap; + +use serde::{Deserialize, Serialize}; + +use crate::{ + authenticated::pvp::PvpResult, guild::upgrades::GuildUpgradeId, items::ItemId, Endpoint, + EndpointWithId, TimeStamp, +}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildLogEntry { + pub id: u32, + pub time: TimeStamp, + #[serde(rename = "type")] + pub _type: String, + pub user: Option, + pub action: Option, + pub item_id: Option, + pub count: Option, + pub upgrade_id: Option, + pub currency_id: Option, + pub activity: Option, + pub total_participants: Option, + pub participants: Option>, + pub quantity: Option, + pub item_name: Option, + pub motd: Option, + pub kick_reason: Option, +} + +pub type GuildLog = Vec; + +impl Endpoint for GuildLog { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/guild"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for GuildLog { + type IdType = String; + + fn format_url(id: &str) -> String { + format!("v2/guild/{}/log", id) + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildMember { + pub name: String, + pub rank: String, + pub joined: TimeStamp, + pub wvw_member: bool, +} + +pub type GuildMembers = Vec; + +impl Endpoint for GuildMembers { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/guild"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for GuildMembers { + type IdType = String; + + fn format_url(id: &str) -> String { + format!("v2/guild/{}/members", id) + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildRank { + pub id: String, + pub order: u32, + pub permissions: Vec, + pub icon: String, +} + +pub type GuildRanks = Vec; + +impl Endpoint for GuildRanks { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/guild"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for GuildRanks { + type IdType = String; + + fn format_url(id: &str) -> String { + format!("v2/guild/{}/ranks", id) + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildStashItem { + pub id: ItemId, + pub count: u32, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildStash { + pub upgrade_id: GuildUpgradeId, + pub size: u32, + pub coins: u64, + pub note: String, + pub inventory: Vec>, +} + +pub type GuildStashes = Vec; + +impl Endpoint for GuildStashes { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/guild"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for GuildStashes { + type IdType = String; + + fn format_url(id: &str) -> String { + format!("v2/guild/{}/stash", id) + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildUpgradeNeed { + pub upgrade_id: GuildUpgradeId, + pub count: u32, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildTreasuryItem { + pub item_id: ItemId, + pub count: u32, + pub needed_by: Vec, +} + +pub type GuildTreasury = Vec; + +impl Endpoint for GuildTreasury { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/guild"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for GuildTreasury { + type IdType = String; + + fn format_url(id: &str) -> String { + format!("v2/guild/{}/treasury", id) + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildTeamMember { + pub name: String, + pub role: String, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildTeam { + pub id: u32, + pub members: Vec, + pub name: String, + pub aggregate: PvpResult, + pub ladders: HashMap, + pub games: Vec, + pub seasons: Vec, +} + +pub type GuildTeams = Vec; + +impl Endpoint for GuildTeams { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/guild"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for GuildTeams { + type IdType = String; + + fn format_url(id: &str) -> String { + format!("v2/guild/{}/teams", id) + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct GuildCompletedUpgrades(pub Vec); + +impl Endpoint for GuildCompletedUpgrades { + const AUTHENTICATED: bool = true; + const LOCALE: bool = false; + const URL: &'static str = "v2/guild"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for GuildCompletedUpgrades { + type IdType = String; + + fn format_url(id: &str) -> String { + format!("v2/guild/{}/upgrades", id) + } +} diff --git a/model/src/guild/emblem.rs b/model/src/guild/emblem.rs new file mode 100644 index 0000000..5d4afff --- /dev/null +++ b/model/src/guild/emblem.rs @@ -0,0 +1,51 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct EmblemBackground { + pub id: u32, + pub layers: Vec, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct EmblemForeground { + pub id: u32, + pub layers: Vec, +} + +impl Endpoint for EmblemBackground { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/emblem/backgrounds"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for EmblemBackground { + type IdType = u32; +} +impl BulkEndpoint for EmblemBackground { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} + +impl Endpoint for EmblemForeground { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/emblem/foregrounds"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for EmblemForeground { + type IdType = u32; +} +impl BulkEndpoint for EmblemForeground { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/guild/guild.rs b/model/src/guild/guild.rs new file mode 100644 index 0000000..ae213d3 --- /dev/null +++ b/model/src/guild/guild.rs @@ -0,0 +1,86 @@ +use serde::{Deserialize, Serialize}; + +use crate::{misc::colors::ColorId, BulkEndpoint, Endpoint, EndpointWithId, FixedEndpoint}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildEmblemLayer { + pub id: u32, + pub colors: Vec, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildEmblem { + pub background: GuildEmblemLayer, + pub foreground: GuildEmblemLayer, + pub flags: Vec, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Guild { + pub id: String, + pub name: String, + pub tag: String, + pub level: Option, + pub motd: Option, + pub influence: Option, + pub aetherium: Option, + pub resonance: Option, + pub favor: Option, + pub member_count: Option, + pub member_capacity: Option, + pub emblem: Option, +} + +impl Endpoint for Guild { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/guild"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Guild { + type IdType = String; + + fn format_url(id: &str) -> String { + format!("v2/guild/{}", id) + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildPermission { + pub id: String, + pub name: String, + pub description: String, +} + +impl Endpoint for GuildPermission { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/guild/permissions"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for GuildPermission { + type IdType = String; +} +impl BulkEndpoint for GuildPermission { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(transparent)] +pub struct GuildSearchResult(pub Vec); + +impl Endpoint for GuildSearchResult { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/guild/search"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl FixedEndpoint for GuildSearchResult {} diff --git a/model/src/guild/upgrades.rs b/model/src/guild/upgrades.rs index 862c386..7e14c8c 100644 --- a/model/src/guild/upgrades.rs +++ b/model/src/guild/upgrades.rs @@ -1 +1,50 @@ pub type GuildUpgradeId = u64; + +use serde::{Deserialize, Serialize}; + +use crate::{items::ItemId, BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildUpgradeCost { + #[serde(rename = "type")] + pub _type: String, + pub count: u32, + pub name: String, + pub item_id: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GuildUpgrade { + pub id: GuildUpgradeId, + pub name: String, + pub description: String, + pub build_time: u32, + pub icon: String, + #[serde(rename = "type")] + pub _type: String, + pub required_level: u32, + pub experience: u32, + pub prerequisites: Vec, + pub costs: Vec, + pub bag_max_items: Option, + pub bag_max_coins: Option, +} + +impl Endpoint for GuildUpgrade { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/guild/upgrades"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for GuildUpgrade { + type IdType = GuildUpgradeId; +} +impl BulkEndpoint for GuildUpgrade { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/items.rs b/model/src/items.rs index fc69191..19bf824 100644 --- a/model/src/items.rs +++ b/model/src/items.rs @@ -1,4 +1,6 @@ +pub mod finishers; pub mod itemstats; +pub mod materials; pub mod recipes; pub mod skins; diff --git a/model/src/items/finishers.rs b/model/src/items/finishers.rs new file mode 100644 index 0000000..68c87c7 --- /dev/null +++ b/model/src/items/finishers.rs @@ -0,0 +1,31 @@ +use serde::{Deserialize, Serialize}; + +use crate::{items::ItemId, BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Finisher { + pub id: u32, + pub name: String, + pub icon: String, + pub unlock_details: String, + pub unlock_items: Vec, + pub order: u32, +} + +impl Endpoint for Finisher { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/finishers"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Finisher { + type IdType = u32; +} +impl BulkEndpoint for Finisher { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/items/materials.rs b/model/src/items/materials.rs new file mode 100644 index 0000000..e7121ce --- /dev/null +++ b/model/src/items/materials.rs @@ -0,0 +1,29 @@ +use serde::{Deserialize, Serialize}; + +use crate::{items::ItemId, BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct MaterialCategory { + pub id: u32, + pub name: String, + pub items: Vec, + pub order: Option, +} + +impl Endpoint for MaterialCategory { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/materials"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for MaterialCategory { + type IdType = u32; +} +impl BulkEndpoint for MaterialCategory { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/lib.rs b/model/src/lib.rs index 2241fd0..0d6ed65 100644 --- a/model/src/lib.rs +++ b/model/src/lib.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; pub mod achievements; pub mod authenticated; +pub mod daily_rewards; pub mod game_mechanics; pub mod guild; pub mod home_instance; @@ -11,6 +12,7 @@ pub mod items; pub mod maps; pub mod misc; pub mod pvp; +pub mod story; pub mod tradingpost; pub mod wvw; @@ -62,21 +64,9 @@ pub struct ErrorResponse { } pub trait Endpoint: Sized { - /// whether this endpoint requires authentication const AUTHENTICATED: bool; - - /// whether this endpoint supports the language parameter const LOCALE: bool; - - /// endpoint url in the format `v2/account` - /// ### Remarks - /// Among other things, this URL is used to fetch ids. - /// `v2/characters/My Character/core` still requires `v2/characters` to be - /// set here. For special cases like characters, override the fetch url - /// of single items here: [EndpointWithId::format_url] const URL: &'static str; - - /// version of the endpoint to request const VERSION: &'static str; } @@ -95,7 +85,6 @@ pub trait EndpointWithId: Endpoint { pub trait FixedEndpoint: Endpoint {} pub trait BulkEndpoint: EndpointWithId { - /// whether this endpoint supports `ids=all` const ALL: bool; fn id(&self) -> &Self::IdType; diff --git a/model/src/misc.rs b/model/src/misc.rs index 0b9a100..1467b81 100644 --- a/model/src/misc.rs +++ b/model/src/misc.rs @@ -1,7 +1,10 @@ pub mod build; pub mod colors; pub mod currencies; +pub mod dungeons; +pub mod files; pub mod minis; +pub mod quaggans; pub mod raids; pub mod titles; pub mod worlds; diff --git a/model/src/misc/dungeons.rs b/model/src/misc/dungeons.rs new file mode 100644 index 0000000..f7eb45f --- /dev/null +++ b/model/src/misc/dungeons.rs @@ -0,0 +1,35 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct DungeonPath { + pub id: String, + #[serde(rename = "type")] + pub _type: String, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Dungeon { + pub id: String, + pub paths: Vec, +} + +impl Endpoint for Dungeon { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/dungeons"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Dungeon { + type IdType = String; +} +impl BulkEndpoint for Dungeon { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/misc/files.rs b/model/src/misc/files.rs new file mode 100644 index 0000000..51a2bc9 --- /dev/null +++ b/model/src/misc/files.rs @@ -0,0 +1,27 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct GameFile { + pub id: String, + pub icon: String, +} + +impl Endpoint for GameFile { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/files"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for GameFile { + type IdType = String; +} +impl BulkEndpoint for GameFile { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/misc/minis.rs b/model/src/misc/minis.rs index b93cc68..f29764e 100644 --- a/model/src/misc/minis.rs +++ b/model/src/misc/minis.rs @@ -1 +1,32 @@ pub type MiniPetId = u64; + +use serde::{Deserialize, Serialize}; + +use crate::{items::ItemId, BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Mini { + pub id: MiniPetId, + pub name: String, + pub icon: String, + pub order: u32, + pub item_id: ItemId, +} + +impl Endpoint for Mini { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/minis"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Mini { + type IdType = MiniPetId; +} +impl BulkEndpoint for Mini { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/misc/quaggans.rs b/model/src/misc/quaggans.rs new file mode 100644 index 0000000..81642fd --- /dev/null +++ b/model/src/misc/quaggans.rs @@ -0,0 +1,27 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Quaggan { + pub id: String, + pub url: String, +} + +impl Endpoint for Quaggan { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/quaggans"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Quaggan { + type IdType = String; +} +impl BulkEndpoint for Quaggan { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/misc/titles.rs b/model/src/misc/titles.rs index d4e38df..e93580c 100644 --- a/model/src/misc/titles.rs +++ b/model/src/misc/titles.rs @@ -1 +1,31 @@ pub type TitleId = u16; + +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Title { + pub id: TitleId, + pub name: String, + pub achievement: Option, + pub achievements: Vec, +} + +impl Endpoint for Title { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/titles"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Title { + type IdType = TitleId; +} +impl BulkEndpoint for Title { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/pvp.rs b/model/src/pvp.rs index 6eef2b6..a99eb8b 100644 --- a/model/src/pvp.rs +++ b/model/src/pvp.rs @@ -1 +1,3 @@ pub mod amulets; +pub mod ranks; +pub mod seasons; diff --git a/model/src/pvp/amulets.rs b/model/src/pvp/amulets.rs index 90ebc82..23950cf 100644 --- a/model/src/pvp/amulets.rs +++ b/model/src/pvp/amulets.rs @@ -1 +1,33 @@ pub type AmuletId = u16; + +use std::collections::HashMap; + +use serde::{Deserialize, Serialize}; + +use crate::{items::AttributeType, BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Amulet { + pub id: AmuletId, + pub name: String, + pub icon: String, + pub attributes: HashMap, +} + +impl Endpoint for Amulet { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/pvp/amulets"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Amulet { + type IdType = AmuletId; +} +impl BulkEndpoint for Amulet { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/pvp/ranks.rs b/model/src/pvp/ranks.rs new file mode 100644 index 0000000..1edfdf2 --- /dev/null +++ b/model/src/pvp/ranks.rs @@ -0,0 +1,40 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct PvpRankLevel { + pub min_rank: u32, + pub max_rank: u32, + pub points: u32, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct PvpRank { + pub id: u32, + pub finisher_id: u32, + pub name: String, + pub icon: String, + pub min_rank: u32, + pub max_rank: u32, + pub levels: Vec, +} + +impl Endpoint for PvpRank { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/pvp/ranks"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for PvpRank { + type IdType = u32; +} +impl BulkEndpoint for PvpRank { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/pvp/seasons.rs b/model/src/pvp/seasons.rs new file mode 100644 index 0000000..e23be5c --- /dev/null +++ b/model/src/pvp/seasons.rs @@ -0,0 +1,49 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId, TimeStamp}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct PvpTier { + pub points: u32, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct PvpDivision { + pub name: String, + pub flags: Vec, + pub large_icon: String, + pub small_icon: String, + pub pip_icon: String, + pub tiers: Vec, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct PvpSeason { + pub id: String, + pub name: String, + pub start: TimeStamp, + pub end: TimeStamp, + pub active: bool, + pub divisions: Vec, + pub leaderboards: Option, +} + +impl Endpoint for PvpSeason { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/pvp/seasons"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for PvpSeason { + type IdType = String; +} +impl BulkEndpoint for PvpSeason { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/story.rs b/model/src/story.rs new file mode 100644 index 0000000..ee30992 --- /dev/null +++ b/model/src/story.rs @@ -0,0 +1,2 @@ +pub mod backstory; +pub mod stories; diff --git a/model/src/story/backstory.rs b/model/src/story/backstory.rs new file mode 100644 index 0000000..c5d8bee --- /dev/null +++ b/model/src/story/backstory.rs @@ -0,0 +1,61 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct BackstoryAnswer { + pub id: String, + pub title: String, + pub description: String, + pub journal: String, + pub question: u32, + pub professions: Option>, + pub races: Option>, +} + +impl Endpoint for BackstoryAnswer { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/backstory/answers"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for BackstoryAnswer { + type IdType = String; +} +impl BulkEndpoint for BackstoryAnswer { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct BackstoryQuestion { + pub id: u32, + pub title: String, + pub description: String, + pub answers: Vec, + pub order: u32, + pub races: Option>, + pub professions: Option>, +} + +impl Endpoint for BackstoryQuestion { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/backstory/questions"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for BackstoryQuestion { + type IdType = u32; +} +impl BulkEndpoint for BackstoryQuestion { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/story/stories.rs b/model/src/story/stories.rs new file mode 100644 index 0000000..e8dea7e --- /dev/null +++ b/model/src/story/stories.rs @@ -0,0 +1,68 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct StoryChapter { + pub name: String, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Story { + pub id: u32, + pub season: String, + pub name: String, + pub description: String, + pub timeline: String, + pub level: u8, + pub races: Option>, + pub order: u32, + pub chapters: Vec, + pub professions: Option>, + pub flags: Option>, +} + +impl Endpoint for Story { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/stories"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Story { + type IdType = u32; +} +impl BulkEndpoint for Story { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct StorySeason { + pub id: String, + pub name: String, + pub order: u32, + pub stories: Vec, +} + +impl Endpoint for StorySeason { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/stories/seasons"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for StorySeason { + type IdType = String; +} +impl BulkEndpoint for StorySeason { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/wvw.rs b/model/src/wvw.rs index b8efac5..fad9977 100644 --- a/model/src/wvw.rs +++ b/model/src/wvw.rs @@ -1 +1,5 @@ pub mod abilities; +pub mod matches; +pub mod objectives; +pub mod ranks; +pub mod upgrades; diff --git a/model/src/wvw/abilities.rs b/model/src/wvw/abilities.rs index 92a0c58..fac0bc7 100644 --- a/model/src/wvw/abilities.rs +++ b/model/src/wvw/abilities.rs @@ -1 +1,39 @@ pub type AbilityId = u32; + +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct AbilityRank { + pub cost: u32, + pub effect: String, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct Ability { + pub id: AbilityId, + pub name: String, + pub description: String, + pub icon: String, + pub ranks: Vec, +} + +impl Endpoint for Ability { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/wvw/abilities"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for Ability { + type IdType = AbilityId; +} +impl BulkEndpoint for Ability { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/wvw/matches.rs b/model/src/wvw/matches.rs new file mode 100644 index 0000000..32bd2dc --- /dev/null +++ b/model/src/wvw/matches.rs @@ -0,0 +1,52 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId, TimeStamp}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct WvwTeamScore { + pub red: u32, + pub blue: u32, + pub green: u32, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct WvwTeamVecScore { + pub red: Vec, + pub blue: Vec, + pub green: Vec, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct WvwMatch { + pub id: String, + pub start_time: TimeStamp, + pub end_time: TimeStamp, + pub scores: WvwTeamScore, + pub worlds: WvwTeamScore, + pub all_worlds: WvwTeamVecScore, + pub deaths: WvwTeamScore, + pub kills: WvwTeamScore, + pub victory_points: WvwTeamScore, + pub skirmishes: Vec, + pub maps: Vec, +} + +impl Endpoint for WvwMatch { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/wvw/matches"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for WvwMatch { + type IdType = String; +} +impl BulkEndpoint for WvwMatch { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/wvw/objectives.rs b/model/src/wvw/objectives.rs new file mode 100644 index 0000000..a0ee947 --- /dev/null +++ b/model/src/wvw/objectives.rs @@ -0,0 +1,37 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct WvwObjective { + pub id: String, + pub name: Option, + pub sector_id: Option, + #[serde(rename = "type")] + pub _type: String, + pub map_type: Option, + pub map_id: Option, + pub upgrade_id: Option, + pub coord: Option>, + pub label_coord: Option>, + pub marker: Option, + pub chat_link: String, +} + +impl Endpoint for WvwObjective { + const AUTHENTICATED: bool = false; + const LOCALE: bool = true; + const URL: &'static str = "v2/wvw/objectives"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for WvwObjective { + type IdType = String; +} +impl BulkEndpoint for WvwObjective { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/wvw/ranks.rs b/model/src/wvw/ranks.rs new file mode 100644 index 0000000..ed7dc2f --- /dev/null +++ b/model/src/wvw/ranks.rs @@ -0,0 +1,28 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct WvwRank { + pub id: u32, + pub title: String, + pub min_rank: u32, +} + +impl Endpoint for WvwRank { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/wvw/ranks"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for WvwRank { + type IdType = u32; +} +impl BulkEndpoint for WvwRank { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +} diff --git a/model/src/wvw/upgrades.rs b/model/src/wvw/upgrades.rs new file mode 100644 index 0000000..4d181a0 --- /dev/null +++ b/model/src/wvw/upgrades.rs @@ -0,0 +1,43 @@ +use serde::{Deserialize, Serialize}; + +use crate::{BulkEndpoint, Endpoint, EndpointWithId}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct WvwUpgradeDetail { + pub name: String, + pub description: String, + pub icon: String, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct WvwUpgradeTier { + pub name: String, + pub yaks_required: u32, + pub upgrades: Vec, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[cfg_attr(test, serde(deny_unknown_fields))] +pub struct WvwUpgrade { + pub id: u32, + pub tiers: Vec, +} + +impl Endpoint for WvwUpgrade { + const AUTHENTICATED: bool = false; + const LOCALE: bool = false; + const URL: &'static str = "v2/wvw/upgrades"; + const VERSION: &'static str = "2021-01-11T00:00:00.000Z"; +} +impl EndpointWithId for WvwUpgrade { + type IdType = u32; +} +impl BulkEndpoint for WvwUpgrade { + const ALL: bool = true; + + fn id(&self) -> &Self::IdType { + &self.id + } +}