Skip to content

Commit 94a2189

Browse files
kittywitchgreaka
authored andcommitted
Add achievements related endpoints
Add wizard's vault endpoints.
1 parent c025628 commit 94a2189

File tree

15 files changed

+533
-7
lines changed

15 files changed

+533
-7
lines changed

http/tests/account_achievements.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![cfg(feature = "blocking")]
2+
3+
use gw2lib::{model::authenticated::account::achievements::AccountAchievements, Requester};
4+
5+
pub mod setup;
6+
7+
#[test]
8+
fn eff_testing() {
9+
let client = setup::setup();
10+
let _: AccountAchievements = client.get().unwrap();
11+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#![cfg(feature = "blocking")]
2+
3+
use gw2lib::{
4+
model::authenticated::account::wizards_vault::{
5+
daily::WizardsVaultDailies, listings::WizardsVaultListing, special::WizardsVaultSpecials,
6+
weekly::WizardsVaultWeeklies,
7+
},
8+
Requester,
9+
};
10+
11+
pub mod setup;
12+
13+
#[test]
14+
fn dailies() {
15+
let client = setup::setup();
16+
let _: WizardsVaultDailies = client.get().unwrap();
17+
}
18+
19+
#[test]
20+
fn listings() {
21+
let client = setup::setup();
22+
let _: Vec<WizardsVaultListing> = client.all().unwrap();
23+
}
24+
25+
#[test]
26+
fn specials() {
27+
let client = setup::setup();
28+
let _: WizardsVaultSpecials = client.get().unwrap();
29+
}
30+
31+
#[test]
32+
fn weeklies() {
33+
let client = setup::setup();
34+
let _: WizardsVaultWeeklies = client.get().unwrap();
35+
}

http/tests/achievements.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#![cfg(feature = "blocking")]
2+
3+
use gw2lib::{
4+
model::achievements::{
5+
categories::AchievementCategory, groups::AchievementGroup, Achievement,
6+
},
7+
Requester,
8+
};
9+
10+
pub mod setup;
11+
12+
#[test]
13+
fn achievement_single() {
14+
let client = setup::setup();
15+
let _: Achievement = client.single(739).unwrap();
16+
}
17+
18+
#[test]
19+
fn achievements() {
20+
let client = setup::setup();
21+
let _: Vec<Achievement> = client.all().unwrap();
22+
}
23+
24+
#[test]
25+
fn achievement_categories() {
26+
let client = setup::setup();
27+
let _: Vec<AchievementCategory> = client.all().unwrap();
28+
}
29+
30+
#[test]
31+
fn achievement_groups() {
32+
let client = setup::setup();
33+
let _: Vec<AchievementGroup> = client.all().unwrap();
34+
}

model/README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ You don't even need to fork this library to test your struct!
2020

2121
Example commit adding an endpoint: [bcb0bd3](https://github.com/greaka/gw2lib/commit/bcb0bd3e99f135f54fb01d088714ce8471a56d86)
2222

23-
> Last update: 2024/03/09
23+
> Last update: 2025/11/03
2424
2525
- achievements
26-
- [ ] achievements
27-
- [ ] daily
28-
- [ ] tomorrow
29-
- [ ] groups
30-
- [ ] categories
26+
- [x] achievements
27+
- [ ] daily (deprecated)
28+
- [ ] tomorrow (deprecated)
29+
- [x] groups
30+
- [x] categories
3131
- authenticated
3232
- [x] account
33-
- [ ] achievements
33+
- [x] achievements
3434
- [x] bank
3535
- [ ] dailycrafting
3636
- [ ] dungeons
@@ -61,6 +61,11 @@ Example commit adding an endpoint: [bcb0bd3](https://github.com/greaka/gw2lib/co
6161
- [ ] skins
6262
- [ ] titles
6363
- [x] wallet
64+
- wizardsvault
65+
- [x] listings
66+
- [x] daily
67+
- [x] weekly
68+
- [x] special
6469
- [ ] worldbosses
6570
- characters
6671
- [x] :id
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
use crate::{
4+
achievements::AchievementId, authenticated::account::Access, BulkEndpoint, Endpoint,
5+
EndpointWithId, FixedEndpoint,
6+
};
7+
8+
pub type AchievementCategoryId = u32;
9+
pub type AchievementCategoryOrder = u32;
10+
11+
#[derive(Clone, Debug, Serialize, Deserialize)]
12+
pub enum DailyAchievementType {
13+
PvE,
14+
PvP,
15+
WvW,
16+
SpecialEvent,
17+
}
18+
19+
#[derive(Clone, Debug, Serialize, Deserialize)]
20+
pub enum AchievementAccessCondition {
21+
HasAccess,
22+
NoAccess,
23+
}
24+
25+
#[derive(Clone, Debug, Serialize, Deserialize)]
26+
pub struct AchievementAccess {
27+
product: Access,
28+
condition: AchievementAccessCondition,
29+
}
30+
31+
#[derive(Clone, Debug, Serialize, Deserialize)]
32+
pub struct AchievementDetails {
33+
id: AchievementId,
34+
required_access: Option<AchievementAccess>,
35+
flags: Option<Vec<DailyAchievementType>>,
36+
level: Option<[u8; 2]>,
37+
}
38+
39+
#[derive(Clone, Debug, Serialize, Deserialize)]
40+
pub struct AchievementCategory {
41+
id: AchievementCategoryId,
42+
name: String,
43+
description: String,
44+
order: AchievementCategoryOrder,
45+
icon: String,
46+
achievements: Vec<AchievementDetails>,
47+
tomorrow: Option<Vec<AchievementDetails>>,
48+
}
49+
50+
impl Endpoint for AchievementCategory {
51+
const AUTHENTICATED: bool = false;
52+
const LOCALE: bool = true;
53+
const URL: &'static str = "v2/achievements/categories";
54+
const VERSION: &'static str = "2025-08-29T01:00:00.000Z";
55+
}
56+
57+
impl EndpointWithId for AchievementCategory {
58+
type IdType = AchievementCategoryId;
59+
}
60+
61+
impl FixedEndpoint for AchievementCategory {}
62+
63+
impl BulkEndpoint for AchievementCategory {
64+
const ALL: bool = true;
65+
66+
fn id(&self) -> &Self::IdType {
67+
&self.id
68+
}
69+
}

model/src/achievements/groups.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
use crate::{
4+
achievements::categories::AchievementCategoryId, BulkEndpoint, Endpoint, EndpointWithId,
5+
FixedEndpoint,
6+
};
7+
8+
pub type AchievementGroupGuid = String;
9+
pub type AchievementGroupOrder = u32;
10+
11+
#[derive(Clone, Debug, Serialize, Deserialize)]
12+
pub struct AchievementGroup {
13+
id: AchievementGroupGuid,
14+
name: String,
15+
description: String,
16+
order: AchievementGroupOrder,
17+
categories: Vec<AchievementCategoryId>,
18+
}
19+
20+
impl EndpointWithId for AchievementGroup {
21+
type IdType = AchievementGroupGuid;
22+
}
23+
24+
impl Endpoint for AchievementGroup {
25+
const AUTHENTICATED: bool = false;
26+
const LOCALE: bool = true;
27+
const URL: &'static str = "v2/achievements/groups";
28+
const VERSION: &'static str = "2025-08-29T01:00:00.000Z";
29+
}
30+
31+
impl FixedEndpoint for AchievementGroup {}
32+
33+
impl BulkEndpoint for AchievementGroup {
34+
const ALL: bool = true;
35+
36+
fn id(&self) -> &Self::IdType {
37+
&self.id
38+
}
39+
}

model/src/achievements/mod.rs

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
use crate::{
4+
items::{skins::SkinId, ItemId},
5+
maps::continents::{MasteryPointId, MasteryPointRegion},
6+
misc::{minis::MiniPetId, titles::TitleId},
7+
BulkEndpoint, Endpoint, EndpointWithId, FixedEndpoint,
8+
};
9+
10+
pub mod categories;
11+
pub mod groups;
12+
13+
pub type AchievementId = u32;
14+
15+
#[derive(Clone, Debug, Serialize, Deserialize)]
16+
pub enum AchievementFlags {
17+
Pvp,
18+
CategoryDisplay,
19+
MoveToTop,
20+
IgnoreNearlyComplete,
21+
Repeatable,
22+
Hidden,
23+
RequiresUnlock,
24+
RepairOnLogin,
25+
Daily,
26+
Weekly,
27+
Monthly,
28+
Permanent,
29+
}
30+
31+
#[derive(Clone, Debug, Serialize, Deserialize)]
32+
pub enum AchievementType {
33+
Default,
34+
ItemSet,
35+
}
36+
37+
#[derive(Clone, Debug, Serialize, Deserialize)]
38+
pub struct AchievementTier {
39+
count: u32,
40+
points: u32,
41+
}
42+
43+
#[derive(Clone, Debug, Serialize, Deserialize)]
44+
pub struct AchievementCoinsReward {
45+
count: u32,
46+
}
47+
48+
#[derive(Clone, Debug, Serialize, Deserialize)]
49+
pub struct AchievementItemReward {
50+
id: ItemId,
51+
count: u8,
52+
}
53+
54+
#[derive(Clone, Debug, Serialize, Deserialize)]
55+
pub struct AchievementMasteryReward {
56+
id: MasteryPointId,
57+
region: MasteryPointRegion,
58+
}
59+
60+
#[derive(Clone, Debug, Serialize, Deserialize)]
61+
pub struct AchievementTitleReward {
62+
id: TitleId,
63+
}
64+
65+
#[derive(Clone, Debug, Serialize, Deserialize)]
66+
#[serde(tag = "type")]
67+
pub enum AchievementReward {
68+
Coins(AchievementCoinsReward),
69+
Item(AchievementItemReward),
70+
Mastery(AchievementMasteryReward),
71+
Title(AchievementTitleReward),
72+
}
73+
74+
#[derive(Clone, Debug, Serialize, Deserialize)]
75+
pub struct AchievementTextBit {
76+
id: Option<u32>,
77+
text: Option<String>,
78+
}
79+
80+
#[derive(Clone, Debug, Serialize, Deserialize)]
81+
pub struct AchievementItemBit {
82+
id: Option<ItemId>,
83+
text: Option<String>,
84+
}
85+
86+
#[derive(Clone, Debug, Serialize, Deserialize)]
87+
pub struct AchievementMinipetBit {
88+
id: Option<MiniPetId>,
89+
text: Option<String>,
90+
}
91+
92+
#[derive(Clone, Debug, Serialize, Deserialize)]
93+
pub struct AchievementSkinBit {
94+
id: Option<SkinId>,
95+
text: Option<String>,
96+
}
97+
98+
#[derive(Clone, Debug, Serialize, Deserialize)]
99+
#[serde(deny_unknown_fields)]
100+
pub struct AchievementEmptyBit {}
101+
102+
#[derive(Clone, Debug, Serialize, Deserialize)]
103+
#[serde(tag = "type")]
104+
pub enum AchievementBit {
105+
Text(AchievementTextBit),
106+
Item(AchievementItemBit),
107+
Minipet(AchievementMinipetBit),
108+
Skin(AchievementSkinBit),
109+
}
110+
111+
#[derive(Clone, Debug, Serialize, Deserialize)]
112+
#[serde(untagged)]
113+
pub enum AchievementUntaggedBit {
114+
Tagged(AchievementBit),
115+
Empty(AchievementEmptyBit),
116+
}
117+
118+
#[derive(Clone, Debug, Serialize, Deserialize)]
119+
pub struct Achievement {
120+
id: AchievementId,
121+
icon: Option<String>,
122+
name: String,
123+
description: String,
124+
requirement: String,
125+
locked_text: String,
126+
#[serde(rename = "type")]
127+
_type: Option<AchievementType>,
128+
flags: Vec<AchievementFlags>,
129+
tiers: Vec<AchievementTier>,
130+
#[serde(default)]
131+
prerequisites: Vec<AchievementId>,
132+
#[serde(default)]
133+
rewards: Vec<AchievementReward>,
134+
bits: Option<Vec<AchievementUntaggedBit>>,
135+
point_cap: Option<i32>,
136+
}
137+
138+
impl EndpointWithId for Achievement {
139+
type IdType = AchievementId;
140+
}
141+
142+
impl Endpoint for Achievement {
143+
const AUTHENTICATED: bool = false;
144+
const LOCALE: bool = true;
145+
const URL: &'static str = "v2/achievements";
146+
const VERSION: &'static str = "2025-08-29T01:00:00.000Z";
147+
}
148+
149+
impl FixedEndpoint for Achievement {}
150+
151+
impl BulkEndpoint for Achievement {
152+
const ALL: bool = false;
153+
154+
fn id(&self) -> &Self::IdType {
155+
&self.id
156+
}
157+
}

model/src/authenticated/account.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
pub mod achievements;
12
pub mod bank;
23
pub mod inventory;
34
pub mod materials;
45
pub mod raids;
56
pub mod wallet;
7+
pub mod wizards_vault;
68

79
use std::collections::BTreeSet;
810

0 commit comments

Comments
 (0)