gw2lib_model/items/
itemstats.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{items::AttributeType, BulkEndpoint, Endpoint, EndpointWithId};
4
5pub type StatsId = u32;
6
7#[derive(Clone, PartialEq, PartialOrd, Debug, Serialize, Deserialize)]
8#[cfg_attr(test, serde(deny_unknown_fields))]
9pub struct Attribute {
10    pub attribute: AttributeType,
11    pub multiplier: f32,
12    pub value: u8,
13}
14
15#[derive(Clone, PartialEq, PartialOrd, Debug, Serialize, Deserialize)]
16#[cfg_attr(test, serde(deny_unknown_fields))]
17pub struct ItemStat {
18    pub id: StatsId,
19    /// The name of the set of stats. Can be empty.
20    pub name: String,
21    pub attributes: Vec<Attribute>,
22}
23
24impl EndpointWithId for ItemStat {
25    type IdType = StatsId;
26}
27
28impl Endpoint for ItemStat {
29    const AUTHENTICATED: bool = false;
30    const LOCALE: bool = true;
31    const URL: &'static str = "v2/itemstats";
32    const VERSION: &'static str = "2023-03-20T19:00:00.000Z";
33}
34
35impl BulkEndpoint for ItemStat {
36    const ALL: bool = true;
37
38    fn id(&self) -> &Self::IdType {
39        &self.id
40    }
41}