1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use serde::{Deserialize, Serialize};

use crate::{items::AttributeType, BulkEndpoint, Endpoint, EndpointWithId};

pub type StatsId = u32;

#[derive(Clone, PartialEq, PartialOrd, Debug, Serialize, Deserialize)]
#[cfg_attr(test, serde(deny_unknown_fields))]
pub struct Attribute {
    pub attribute: AttributeType,
    pub multiplier: f32,
    pub value: u8,
}

#[derive(Clone, PartialEq, PartialOrd, Debug, Serialize, Deserialize)]
#[cfg_attr(test, serde(deny_unknown_fields))]
pub struct ItemStat {
    pub id: StatsId,
    /// The name of the set of stats. Can be empty.
    pub name: String,
    pub attributes: Vec<Attribute>,
}

impl EndpointWithId for ItemStat {
    type IdType = StatsId;
}

impl Endpoint for ItemStat {
    const AUTHENTICATED: bool = false;
    const LOCALE: bool = true;
    const URL: &'static str = "v2/itemstats";
    const VERSION: &'static str = "2023-03-20T19:00:00.000Z";
}

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

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