steam_api/
structs.rs

1use serde::{Deserialize, Serialize};
2
3pub mod bans {
4    use super::{Deserialize, Serialize};
5
6    #[derive(Debug, Deserialize, Serialize, Default)]
7    #[allow(non_snake_case)]
8    pub struct User {
9        /// Returns Steam ID of specified account
10        pub SteamId: String,
11        /// Whether or not the account is community banned.
12        pub CommunityBanned: bool,
13        /// Whether or not the account is VAC banned.
14        pub VACBanned: bool,
15        /// Amount of VAC bans the account has, Returns 0 if the account has none.
16        pub NumberOfVACBans: i32,
17        /// Amount of days since the last ban
18        pub DaysSinceLastBan: i32,
19        /// Amount of Game bans the account has, Returns 0 if the account has none.
20        pub NumberOfGameBans: i32,
21        /// Whether or not the account has an economy ban
22        pub EconomyBan: String,
23    }
24
25    #[derive(Debug, Deserialize, Default)]
26    pub struct Response {
27        /// A vector of [`structs::bans::User`]
28        pub players: Vec<User>,
29    }
30}
31
32pub mod level {
33    use super::{Deserialize, Serialize};
34
35    #[derive(Debug, Serialize, Deserialize, Default)]
36    #[allow(non_snake_case)]
37    pub struct User {
38        /// The steam level of the profile
39        pub player_level: Option<i32>,
40    }
41
42    #[derive(Debug, Serialize, Deserialize, Default)]
43    #[allow(non_snake_case)]
44    pub struct Response {
45        /// [`structs::level::User`]
46        pub response: User,
47    }
48}
49
50pub mod friends {
51    use super::{Deserialize, Serialize};
52
53    #[derive(Debug, Deserialize, Serialize, Default)]
54    #[allow(non_snake_case)]
55    pub struct User {
56        /// Returns Steam ID of friend
57        pub steamid: String,
58        /// Friends relationship to the specified Steam ID
59        pub relationship: String,
60        /// Amount of time the users has been friends with the specified Steam ID
61        pub friend_since: i32,
62    }
63
64    #[derive(Debug, Deserialize, Default)]
65    #[allow(non_snake_case)]
66    pub struct Users {
67        /// A vector of [`structs::friends::User`]
68        pub friends: Vec<User>,
69    }
70
71    #[derive(Debug, Deserialize, Default)]
72    pub struct Response {
73        /// [`structs::friends::Users`]
74        pub friendslist: Users,
75    }
76}
77
78pub mod summaries {
79    use super::{Deserialize, Serialize};
80
81    /// `communityvisibilitystate`
82    /// Returns `3` if the profile is public
83    /// Otherwise the profile isn't visible to you
84    /// # Example output
85    /// `3`
86    ///
87    /// `relationship`
88    /// Friends relationship to the specified Steam ID
89    ///
90    /// `friend_since`
91    /// Amount of time the users has been friends with the specified Steam ID
92    #[derive(Debug, Deserialize, Serialize, Default)]
93    pub struct User {
94        /// Returns Steam ID of specified account
95        pub steamid: String,
96
97        /// The current visibility state of the profile
98        /// 1 = Private
99        /// 2 = Friends Only
100        /// 3 = Public
101        pub communityvisibilitystate: i32,
102
103        /// Profile state
104        ///
105        /// 0 if the profile doesn't have a community profile
106        /// 1 if it does
107        pub profilestate: i32,
108
109        /// Profile name (not the actual account login name)
110        pub personaname: String,
111
112        /// If set, comments are allowed on the profile
113        /// 1 = Public comments
114        /// 2 = Private/Friends Only
115        /// TODO: Check me further
116        pub commentpermission: Option<i32>,
117
118        // The profiles custom steam url
119        pub profileurl: String,
120        /// Url of the players avatar (32x32px)
121        pub avatar: String,
122
123        /// Url of the players avatar (64x64px)
124        pub avatarmedium: String,
125
126        /// Url of the players avatar (184x184px)
127        pub avatarfull: String,
128
129        /// Hash of the users avatar
130        pub avatarhash: String,
131
132        /// Time since user was last online (unix timestamp)
133        pub lastlogoff: Option<i32>,
134
135        /// The Users current status:
136        ///
137        /// 0 = Offline
138        ///
139        /// 1 = Online
140        ///
141        /// 2 = Busy
142        ///
143        /// 3 = Away
144        ///
145        /// 4 = Snooze
146        ///
147        /// 5 = looking to trade
148        ///
149        /// 6 = looking to play
150        ///
151        /// If the player's profile is private, this will always be 0.
152        pub personastate: i32,
153
154        // WARN: private data (not available if profile is not available to us)
155        /// Real name of the user if set
156        pub realname: Option<String>,
157
158        /// Primary clan ID of the user if set
159        pub primaryclanid: Option<String>,
160
161        /// Age of the profile
162        pub timecreated: Option<i32>,
163
164        /// ID of the game the user is in
165        pub gameid: Option<String>,
166
167        /// IP of the game server the user is in
168        pub gameserverip: Option<String>,
169
170        /// Country the user resides in
171        pub loccountrycode: Option<String>,
172
173        /// State the user resides in
174        pub locstatecode: Option<String>,
175
176        /// City the use resides in
177        pub loccityid: Option<i32>,
178    }
179
180    #[derive(Debug, Deserialize, Default)]
181    pub struct Users {
182        /// A vector of [`structs::summaries::User`]
183        pub players: Vec<User>,
184    }
185
186    #[derive(Debug, Deserialize, Default)]
187    pub struct Response {
188        /// [`structs::summaries::Users`]
189        pub response: Users,
190    }
191}
192
193pub mod profile {
194    use super::Serialize;
195    // This will hold the info for each player from all the above structs
196    #[derive(Default, Debug, Serialize)]
197    #[allow(non_snake_case)] // blame valve for the random variable naming schemes
198    pub struct User {
199        // GetPlayerSummaries
200        // lowercase
201        pub steamid: String,
202        pub communityvisibilitystate: i32,
203        pub profilestate: i32,
204        pub personaname: String,
205        pub commentpermission: i32,
206        pub profileurl: String,
207        pub avatar: String,
208        pub avatarmedium: String,
209        pub avatarfull: String,
210        pub avatarhash: String,
211        pub lastlogoff: i32,
212        pub personastate: i32,
213
214        // private data
215        pub realname: String,
216        pub primaryclanid: String,
217        pub timecreated: i32,
218        pub gameid: String,
219        pub gameserverip: String,
220        pub loccountrycode: String,
221        pub locstatecode: String,
222        pub loccityid: i32,
223
224        //GetPlayerBans
225        //CamelCase
226        pub CommunityBanned: bool,
227        pub VACBanned: bool,
228        pub NumberOfVACBans: i32,
229        pub DaysSinceLastBan: i32,
230        pub NumberOfGameBans: i32,
231        pub EconomyBan: String,
232
233        //GetSteamLevel
234        //snake_case
235        pub player_level: i32,
236    }
237
238    // this will store all the above structs if multiple id's are requested
239    #[derive(Debug, Serialize, Default)]
240    pub struct Users {
241        pub api_call_count: i32,
242        pub user: Vec<User>,
243    }
244}
245
246pub mod api {
247    #[derive(Default)]
248    pub struct Api<'a> {
249        pub interface: &'a str,
250        pub version: &'a str,
251        pub accepts_multiple_ids: bool,
252    }
253}