poe_ninja/
model.rs

1use chrono::DateTime;
2use chrono::Utc;
3use serde::Deserialize;
4
5/// A sample of transaction data for a currency.
6#[derive(Clone, Debug, Deserialize)]
7pub struct TransactionSample {
8	pub id: u64,
9	pub league_id: u16,
10	pub pay_currency_id: u16,
11	pub get_currency_id: u16,
12	pub sample_time_utc: DateTime<Utc>,
13	pub count: u16,
14	pub value: f64,
15	pub data_point_count: u16,
16	pub includes_secondary: bool,
17	pub listing_count: u16
18}
19
20/// A week's worth of price changes for a currency or item.
21#[derive(Clone, Debug, Deserialize)]
22pub struct WeekOfDailyPriceChanges {
23	/// Represented in percentages, comparing the end of a day with the beginning.
24	pub data: Vec<Option<f32>>,
25	#[serde(rename = "totalChange")]
26	/// Percentage comparing the end of the final day with the beginning of the first.
27	pub total_change: f32,
28}
29
30/// A Path of Exile currency.
31#[derive(Clone, Debug, Deserialize)]
32#[serde(rename_all = "camelCase")]
33pub struct Currency {
34	#[serde(rename = "currencyTypeName")]
35	pub name: String,
36	pub details_id: String,
37	pub pay: Option<TransactionSample>,
38	pub receive: Option<TransactionSample>,
39	#[serde(rename = "paySparkLine")]
40	pub pay_history: WeekOfDailyPriceChanges,
41	#[serde(rename = "receiveSparkLine")]
42	pub receive_history: WeekOfDailyPriceChanges,
43	pub chaos_equivalent: f32,
44	#[serde(rename = "lowConfidencePaySparkLine")]
45	pub low_confidence_pay_history: WeekOfDailyPriceChanges,
46	#[serde(rename = "lowConfidenceReceiveSparkLine")]
47	pub low_confidence_receive_history: WeekOfDailyPriceChanges
48}
49
50#[derive(Clone, Debug, Deserialize)]
51#[serde(rename_all = "camelCase")]
52#[allow(dead_code)]
53pub(crate) struct CurrencyDetail {
54	pub id: u64,
55	pub icon: String,
56	pub name: String,
57	pub trade_id: Option<String>
58}
59
60#[derive(Clone, Debug, Deserialize)]
61#[allow(dead_code)]
62pub(crate) struct Language {
63	pub name: String,
64	// TODO:  translations
65}
66
67#[derive(Clone, Debug, Deserialize)]
68#[serde(rename_all = "camelCase")]
69#[allow(dead_code)]
70pub(crate) struct CurrencyResponse {
71	pub lines: Vec<Currency>,
72	pub currency_details: Vec<CurrencyDetail>,
73	pub language: Language
74}
75
76#[derive(Clone, Debug, Deserialize)]
77pub struct ItemModifier {
78	pub text: String,
79	pub optional: bool
80}
81
82#[derive(Clone, Debug, Deserialize)]
83#[serde(rename_all = "camelCase")]
84/// A Path of Exile item.
85pub struct Item {
86	pub id: u64,
87	pub details_id: String,
88	pub name: String,
89	pub icon: Option<String>,
90	#[serde(default)]
91	pub stack_size: u16,
92	pub art_filename: Option<String>,
93	pub item_class: u8,
94	#[serde(rename = "sparkline")]
95	pub value_history: WeekOfDailyPriceChanges,
96	#[serde(rename = "lowConfidenceSparkline")]
97	pub low_confidence_value_history: WeekOfDailyPriceChanges,
98	pub implicit_modifiers: Vec<ItemModifier>,
99	pub explicit_modifiers: Vec<ItemModifier>,
100	#[serde(rename = "flavourText")] // trollface.jpeg
101	pub flavor_text: Option<String>,
102	pub chaos_value: f32,
103	pub exalted_value: f32,
104	pub count: u16,
105	#[serde(default)]
106	pub listing_count: u16
107}
108
109#[derive(Clone, Debug, Deserialize)]
110pub(crate) struct ItemResponse {
111	pub lines: Vec<Item>,
112	#[allow(dead_code)]
113	pub language: Language
114}
115