Skip to content

Commit

Permalink
add worlds endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
greaka committed Jul 22, 2022
1 parent 2df841b commit bcb0bd3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
12 changes: 12 additions & 0 deletions http/tests/worlds.rs
@@ -0,0 +1,12 @@
#![cfg(feature = "blocking")]

use gw2lib::Requester;
use gw2lib_model::misc::worlds::World;

pub mod setup;

#[test]
fn all() {
let client = setup::setup();
let _: Vec<World> = client.all().unwrap();
}
4 changes: 2 additions & 2 deletions model/README.md
Expand Up @@ -5,7 +5,7 @@ An endpoint gets marked as completed once it's mapped out and a small test runs
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.
You don't even need to fork this library to test your struct!

Last update: 22/06/18
Last update: 22/07/22

- achievements
- [ ] achievements
Expand Down Expand Up @@ -127,7 +127,7 @@ Last update: 22/06/18
- [ ] minis
- [ ] raids
- [ ] titles
- [ ] worlds
- [x] worlds
- Story
- backstory
- [ ] answers
Expand Down
38 changes: 38 additions & 0 deletions model/src/misc/worlds.rs
@@ -1 +1,39 @@
use serde::{Deserialize, Serialize};

use crate::*;

pub type WorldId = u16;

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub enum PopulationLevel {
Medium,
High,
VeryHigh,
Full,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct World {
id: WorldId,
name: String,
population: PopulationLevel,
}

impl Endpoint for World {
const AUTHENTICATED: bool = false;
const LOCALE: bool = true;
const URL: &'static str = "v2/worlds";
const VERSION: &'static str = "2022-07-22T00:00:00.000Z";
}

impl EndpointWithId for World {
type IdType = WorldId;
}

impl BulkEndpoint for World {
const ALL: bool = true;

fn id(&self) -> &Self::IdType {
&self.id
}
}

0 comments on commit bcb0bd3

Please sign in to comment.