Skip to content

Commit bcb0bd3

Browse files
committed
add worlds endpoint
1 parent 2df841b commit bcb0bd3

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

http/tests/worlds.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![cfg(feature = "blocking")]
2+
3+
use gw2lib::Requester;
4+
use gw2lib_model::misc::worlds::World;
5+
6+
pub mod setup;
7+
8+
#[test]
9+
fn all() {
10+
let client = setup::setup();
11+
let _: Vec<World> = client.all().unwrap();
12+
}

model/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ An endpoint gets marked as completed once it's mapped out and a small test runs
55
Please do help out mapping the API! All you need to do is create the necessary struct and quickly implement 2 traits. If you need help, feel free to reach out.
66
You don't even need to fork this library to test your struct!
77

8-
Last update: 22/06/18
8+
Last update: 22/07/22
99

1010
- achievements
1111
- [ ] achievements
@@ -127,7 +127,7 @@ Last update: 22/06/18
127127
- [ ] minis
128128
- [ ] raids
129129
- [ ] titles
130-
- [ ] worlds
130+
- [x] worlds
131131
- Story
132132
- backstory
133133
- [ ] answers

model/src/misc/worlds.rs

+38
Original file line numberDiff line numberDiff line change
@@ -1 +1,39 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
use crate::*;
4+
15
pub type WorldId = u16;
6+
7+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
8+
pub enum PopulationLevel {
9+
Medium,
10+
High,
11+
VeryHigh,
12+
Full,
13+
}
14+
15+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
16+
pub struct World {
17+
id: WorldId,
18+
name: String,
19+
population: PopulationLevel,
20+
}
21+
22+
impl Endpoint for World {
23+
const AUTHENTICATED: bool = false;
24+
const LOCALE: bool = true;
25+
const URL: &'static str = "v2/worlds";
26+
const VERSION: &'static str = "2022-07-22T00:00:00.000Z";
27+
}
28+
29+
impl EndpointWithId for World {
30+
type IdType = WorldId;
31+
}
32+
33+
impl BulkEndpoint for World {
34+
const ALL: bool = true;
35+
36+
fn id(&self) -> &Self::IdType {
37+
&self.id
38+
}
39+
}

0 commit comments

Comments
 (0)