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
use serde::Deserialize;
use torn_api_macros::ApiCategory;

#[derive(Debug, Clone, Copy, ApiCategory)]
#[api(category = "market")]
pub enum MarketSelection {
    #[api(type = "Vec<BazaarItem>", field = "bazaar")]
    Bazaar,
}

#[derive(Clone, Debug, Deserialize)]
pub struct BazaarItem {
    #[serde(rename = "ID")]
    pub id: u32,
    pub cost: u64,
    pub quantity: u32,
}

#[cfg(test)]
mod test {
    use super::*;
    use crate::tests::{async_test, setup, Client, ClientTrait};

    #[async_test]
    async fn market_bazaar() {
        let key = setup();

        let response = Client::default()
            .torn_api(key)
            .market(|b| b.id(1).selections([MarketSelection::Bazaar]))
            .await
            .unwrap();

        _ = response.bazaar().unwrap();
    }
}