1use std::collections::HashSet;
2
3use serde::{Deserialize, Serialize};
4use torn_api_macros::ApiCategory;
5
6#[derive(Debug, Clone, Copy, ApiCategory)]
7#[api(category = "key")]
8#[non_exhaustive]
9pub enum Selection {
10 #[api(type = "Info", flatten)]
11 Info,
12}
13
14#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
15#[non_exhaustive]
16pub enum AccessType {
17 #[serde(rename = "Custom")]
18 Custom,
19
20 #[serde(rename = "Public Only")]
21 Public,
22
23 #[serde(rename = "Minimal Access")]
24 Minimal,
25
26 #[serde(rename = "Limited Access")]
27 Limited,
28
29 #[serde(rename = "Full Access")]
30 Full,
31}
32
33#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
34#[serde(rename_all = "lowercase")]
35#[non_exhaustive]
36pub enum KeySelection {
37 Info,
38}
39
40#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
41#[serde(rename_all = "lowercase")]
42#[non_exhaustive]
43pub enum UserSelection {
44 Ammo,
45 Attacks,
46 AttacksFull,
47 Bars,
48 Basic,
49 BattleStats,
50 Bazaar,
51 Cooldowns,
52 Crimes,
53 Discord,
54 Display,
55 Education,
56 Events,
57 Gym,
58 Hof,
59 Honors,
60 Icons,
61 Inventory,
62 JobPoints,
63 Log,
64 Medals,
65 Merits,
66 Messages,
67 Missions,
68 Money,
69 Networth,
70 NewEvents,
71 NewMessages,
72 Notifications,
73 Perks,
74 PersonalStats,
75 Profile,
76 Properties,
77 ReceivedEvents,
78 Refills,
79 Reports,
80 Revives,
81 RevivesFull,
82 Skills,
83 Stocks,
84 Timestamp,
85 Travel,
86 WeaponExp,
87 WorkStats,
88 Lookup,
89 PublicStatus,
90 #[serde(other)]
91 Unknown,
92}
93
94#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
95#[serde(rename_all = "lowercase")]
96#[non_exhaustive]
97pub enum FactionSelection {
98 Applications,
99 Armor,
100 ArmoryNews,
101 AttackNews,
102 Attacks,
103 AttacksFull,
104 Basic,
105 Boosters,
106 Cesium,
107 Chain,
108 ChainReport,
109 Chains,
110 Contributors,
111 Crimenews,
112 Crimes,
113 Currency,
114 Donations,
115 Drugs,
116 FundsNews,
117 MainNews,
118 Medical,
119 MembershipNews,
120 Positions,
121 Reports,
122 Revives,
123 RevivesFull,
124 Stats,
125 Temporary,
126 Territory,
127 TerritoryNews,
128 Timestamp,
129 Upgrades,
130 Weapons,
131 Lookup,
132 Caches,
133 CrimeExp,
134 #[serde(other)]
135 Unknown,
136}
137
138#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
139#[serde(rename_all = "lowercase")]
140#[non_exhaustive]
141pub enum CompanySelection {
142 Applications,
143 Companies,
144 Detailed,
145 Employees,
146 News,
147 NewsFull,
148 Profile,
149 Stock,
150 Timestamp,
151 Lookup,
152 #[serde(other)]
153 Unknown,
154}
155
156#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
157#[serde(rename_all = "lowercase")]
158#[non_exhaustive]
159pub enum TornSelection {
160 Bank,
161 Cards,
162 ChainReport,
163 Companies,
164 Competition,
165 Education,
166 FactionTree,
167 Gyms,
168 Honors,
169 Items,
170 ItemStats,
171 LogCategories,
172 LogTypes,
173 Medals,
174 OrganisedCrimes,
175 PawnShop,
176 PokerTables,
177 Properties,
178 Rackets,
179 Raids,
180 RankedWars,
181 RankedWarReport,
182 Stats,
183 Stocks,
184 Territory,
185 TerritoryWars,
186 Timestamp,
187 Lookup,
188 CityShops,
189 ItemDetails,
190 TerritoryNames,
191 TerritoryWarReport,
192 RaidReport,
193 #[serde(other)]
194 Unknown,
195}
196
197#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
198#[serde(rename_all = "lowercase")]
199#[non_exhaustive]
200pub enum MarketSelection {
201 Bazaar,
202 ItemMarket,
203 PointsMarket,
204 Timestamp,
205 Lookup,
206 #[serde(other)]
207 Unknown,
208}
209
210#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
211#[serde(rename_all = "lowercase")]
212#[non_exhaustive]
213pub enum PropertySelection {
214 Property,
215 Timestamp,
216 Lookup,
217 #[serde(other)]
218 Unknown,
219}
220
221#[derive(Debug, Clone, Serialize, Deserialize)]
222pub struct Selections {
223 pub user: HashSet<UserSelection>,
224 pub faction: HashSet<FactionSelection>,
225 pub company: HashSet<CompanySelection>,
226 pub torn: HashSet<TornSelection>,
227 pub market: HashSet<MarketSelection>,
228 pub property: HashSet<PropertySelection>,
229 pub key: HashSet<KeySelection>,
230}
231
232#[derive(Debug, Clone, Serialize, Deserialize)]
233pub struct Info {
234 pub access_level: i16,
235 pub access_type: AccessType,
236 pub selections: Selections,
237}
238
239#[cfg(test)]
240mod tests {
241 use super::*;
242 use crate::tests::{async_test, setup, Client, ClientTrait};
243
244 #[async_test]
245 async fn key() {
246 let key = setup();
247
248 let response = Client::default()
249 .torn_api(key)
250 .key(|b| b.selections([Selection::Info]))
251 .await
252 .unwrap();
253
254 response.info().unwrap();
255 }
256}