implement many GW2 API endpoints#34
Conversation
Add serde_json dependency and implement endpoints for: - Achievements (achievements, categories, groups) - Daily rewards (dailycrafting, mapchests, worldbosses) - Story (backstory answers/questions, stories, story seasons) - Account sub-endpoints (achievements, dailycrafting, dungeons, dyes, finishers, gliders, home cats/nodes, inventory, luck, mailcarriers, mapchests, masteries, minis, mounts, outfits, pvp heroes, recipes, skins, titles, worldbosses) - Authenticated PvP (stats, games, standings) - Commerce transactions (current/history buy/sell) - Characters (Heropoints, Sab sub-endpoints) - Game mechanics (legends, masteries, mounts, outfits, pets, professions, races) and endpoint impls for skills, specializations, traits - Guild (guild, permissions, search, emblem, authenticated log/members/ranks/stash/treasury/teams/upgrades) - Guild upgrade endpoint impl - Items (finishers, materials) - PvP (amulets, ranks, seasons) - Misc (dungeons, files, quaggans, mini, title endpoint impls) - WvW (abilities, matches, objectives, ranks, upgrades) Use newtype wrappers for Vec<primitive> endpoint types to avoid conflicting Endpoint impls for the same concrete type.
There was a problem hiding this comment.
Pull request overview
Adds a large set of Guild Wars 2 API model types (and a few HTTP integration tests) to expand gw2lib coverage across WvW, PvP, Story, Guild, Daily Rewards, Misc, Items, and Game Mechanics endpoints.
Changes:
- Introduces many new
modelendpoint structs implementingEndpoint/EndpointWithId/BulkEndpoint(plus several authenticated account/guild endpoints). - Adds
serde_jsonas a dependency to support partially-modeled response shapes (serde_json::Valuefields). - Adds new blocking HTTP tests covering several of the newly added endpoints.
Reviewed changes
Copilot reviewed 80 out of 80 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| model/src/wvw/upgrades.rs | Adds WvW upgrade endpoint models. |
| model/src/wvw/ranks.rs | Adds WvW rank endpoint model. |
| model/src/wvw/objectives.rs | Adds WvW objective endpoint model. |
| model/src/wvw/matches.rs | Adds WvW match endpoint model. |
| model/src/wvw/abilities.rs | Adds WvW ability endpoint model. |
| model/src/wvw.rs | Exposes new WvW modules. |
| model/src/story/stories.rs | Adds story + story season endpoint models. |
| model/src/story/backstory.rs | Adds backstory answers/questions endpoint models. |
| model/src/story.rs | Exposes story modules. |
| model/src/pvp/seasons.rs | Adds PvP seasons endpoint model. |
| model/src/pvp/ranks.rs | Adds PvP ranks endpoint model. |
| model/src/pvp/amulets.rs | Adds PvP amulets endpoint model. |
| model/src/pvp.rs | Exposes new PvP modules. |
| model/src/misc/titles.rs | Adds titles endpoint model. |
| model/src/misc/quaggans.rs | Adds quaggans endpoint model. |
| model/src/misc/minis.rs | Expands minis endpoint model. |
| model/src/misc/files.rs | Adds files endpoint model. |
| model/src/misc/dungeons.rs | Adds dungeons endpoint model. |
| model/src/misc.rs | Exposes new misc modules. |
| model/src/lib.rs | Registers new top-level model modules; trims trait docs. |
| model/src/items/materials.rs | Adds materials endpoint model. |
| model/src/items/finishers.rs | Adds finishers endpoint model. |
| model/src/items.rs | Exposes new items submodules. |
| model/src/guild/upgrades.rs | Adds guild upgrades endpoint model. |
| model/src/guild/guild.rs | Adds guild info/permissions/search endpoint models. |
| model/src/guild/emblem.rs | Adds emblem endpoints models. |
| model/src/guild/authenticated.rs | Adds authenticated guild sub-endpoints (log/members/ranks/etc.). |
| model/src/guild.rs | Exposes new guild modules. |
| model/src/game_mechanics/traits.rs | Adds traits endpoint model. |
| model/src/game_mechanics/specializations.rs | Adds specializations endpoint model. |
| model/src/game_mechanics/skills.rs | Adds skills endpoint model (plus fields using serde_json::Value). |
| model/src/game_mechanics/races.rs | Adds races endpoint model. |
| model/src/game_mechanics/professions.rs | Adds professions endpoint model. |
| model/src/game_mechanics/pets.rs | Adjusts pets module imports for new endpoint traits. |
| model/src/game_mechanics/outfits.rs | Adds outfits endpoint model. |
| model/src/game_mechanics/mounts.rs | Adds mounts skins/types endpoint models. |
| model/src/game_mechanics/masteries.rs | Adds masteries endpoint model. |
| model/src/game_mechanics/legends.rs | Adds legends endpoint model. |
| model/src/game_mechanics.rs | Exposes new game mechanics modules. |
| model/src/daily_rewards/worldbosses.rs | Adds daily-rewards worldbosses endpoint model. |
| model/src/daily_rewards/mapchests.rs | Adds daily-rewards mapchests endpoint model. |
| model/src/daily_rewards/dailycrafting.rs | Adds daily-rewards dailycrafting endpoint model. |
| model/src/daily_rewards.rs | Exposes daily rewards modules. |
| model/src/authenticated/pvp.rs | Adds authenticated PvP endpoints (stats/games/standings). |
| model/src/authenticated/commerce.rs | Adds commerce transaction endpoints models. |
| model/src/authenticated/characters.rs | Adds character heropoints + SAB endpoint models. |
| model/src/authenticated/account/worldbosses.rs | Adds authenticated account worldbosses endpoint model. |
| model/src/authenticated/account/titles.rs | Adds authenticated account titles endpoint model. |
| model/src/authenticated/account/skins.rs | Adds authenticated account skins endpoint model. |
| model/src/authenticated/account/recipes.rs | Adds authenticated account recipes endpoint model. |
| model/src/authenticated/account/pvp.rs | Adds authenticated account PvP heroes endpoint model. |
| model/src/authenticated/account/outfits.rs | Adds authenticated account outfits endpoint model. |
| model/src/authenticated/account/mounts.rs | Adds authenticated account mounts endpoint models. |
| model/src/authenticated/account/minis.rs | Adds authenticated account minis endpoint model. |
| model/src/authenticated/account/masteries.rs | Adds authenticated account masteries + mastery points endpoint models. |
| model/src/authenticated/account/mapchests.rs | Adds authenticated account mapchests endpoint model. |
| model/src/authenticated/account/mailcarriers.rs | Adds authenticated account mailcarriers endpoint model. |
| model/src/authenticated/account/luck.rs | Adds authenticated account luck endpoint model. |
| model/src/authenticated/account/inventory.rs | Expands account inventory/shared slots model. |
| model/src/authenticated/account/home.rs | Adds authenticated account home cats/nodes endpoint models. |
| model/src/authenticated/account/gliders.rs | Adds authenticated account gliders endpoint model. |
| model/src/authenticated/account/finishers.rs | Adds authenticated account finishers endpoint model. |
| model/src/authenticated/account/dyes.rs | Adds authenticated account dyes endpoint model. |
| model/src/authenticated/account/dungeons.rs | Adds authenticated account dungeons endpoint model. |
| model/src/authenticated/account/dailycrafting.rs | Adds authenticated account dailycrafting endpoint model. |
| model/src/authenticated/account.rs | Registers new authenticated account modules. |
| model/src/authenticated.rs | Exposes new authenticated PvP module. |
| model/README.md | Updates endpoint coverage checklist. |
| model/Cargo.toml | Adds serde_json dependency. |
| http/tests/wvw.rs | Adds blocking HTTP tests for WvW endpoints. |
| http/tests/story.rs | Adds blocking HTTP tests for Story endpoints. |
| http/tests/pvp_new.rs | Adds blocking HTTP tests for PvP endpoints. |
| http/tests/misc_new.rs | Adds blocking HTTP tests for misc/items endpoints. |
| http/tests/guild.rs | Adds blocking HTTP tests for guild endpoints. |
| http/tests/game_mechanics.rs | Adds blocking HTTP tests for game mechanics endpoints. |
| http/tests/daily_rewards.rs | Adds blocking HTTP tests for daily rewards endpoints. |
| http/tests/authenticated_new.rs | Adds blocking HTTP tests for authenticated endpoints. |
| http/tests/achievements.rs | Minor import formatting adjustment in tests. |
| http/tests/account_new.rs | Adds blocking HTTP tests for authenticated account endpoints. |
| http/src/client/requester.rs | Small refactor in match patterns for inflight/cache logic. |
Comments suppressed due to low confidence (3)
http/src/client/requester.rs:135
- In this
matchonOption, using a binding pattern (_none) is misleading because it would match any value that reaches this arm. Use the explicitNone => { ... }pattern for clarity and to avoid accidental behavior changes if the earlier arms are modified.
Some(Either::Left(mut rx)) => return rx.recv().await.map_err(Into::into),
Some(Either::Right(tx)) => break tx,
_none => {
if let Some(c) = self.try_get(&id).await {
return Ok(c);
}
}
http/src/client/requester.rs:242
- Same as above: prefer
None => { ... }instead of a binding pattern (_none) in thismatchfor readability and to prevent accidental matches if the preceding arms change.
Some(Either::Right(tx)) => {
txs.insert(id.clone(), tx);
break true;
}
_none => {
if let Some(c) =
check_cache::<T, I, T, Self, AUTHENTICATED, FORCE>(self, &id).await
{
result.push(c);
break false;
}
}
http/src/client/requester.rs:546
- Use
None => { ... }here instead of_none => { ... }. A binding pattern is less clear and could become a footgun if thematcharms are rearranged in the future.
match either {
Some(Either::Left(mut rx)) => return rx.recv().await.map_err(Into::into),
Some(Either::Right(tx)) => break tx,
_none => {
if let Some(c) = check_cache::<K, str, T, Req, A, F>(req, "").await {
return Ok(c);
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pub recharge: Option<f32>, | ||
| pub equip_ttype: Option<String>, | ||
| } |
There was a problem hiding this comment.
equip_ttype looks like a typo and will not deserialize data if the API field is actually equip_type. Rename the Rust field (or add a #[serde(rename = "equip_type")] attribute) so the JSON key maps correctly.
| use crate::{game_mechanics::skills::SkillId, BulkEndpoint, Endpoint, EndpointWithId, *}; | ||
|
|
There was a problem hiding this comment.
Avoid importing the entire crate with * here. The glob import is unused (since the needed traits are explicitly imported) and can cause name collisions/less clear dependencies; remove the * from the use crate::{...} list.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Hey there, thank you for the sizable contribution. There are unforced breaking changes in this pr and some changes I don't agree with and will need to touch up. It will also take quite a bit of time to verify all endpoints against the api. It's unlikely that I will merge this before I get around to complete the 4.0 changes, but I will not forget about this. Thank you again! |
Add serde_json dependency and implement endpoints for:
dyes, finishers, gliders, home cats/nodes, inventory, luck,
mailcarriers, mapchests, masteries, minis, mounts, outfits,
pvp heroes, recipes, skins, titles, worldbosses)
professions, races) and endpoint impls for skills,
specializations, traits
log/members/ranks/stash/treasury/teams/upgrades)