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
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
use serde::{Deserialize, Serialize};

pub mod bans {
    use super::{Deserialize, Serialize};

    #[derive(Debug, Deserialize, Serialize, Default)]
    #[allow(non_snake_case)]
    pub struct User {
        /// Returns Steam ID of specified account
        pub SteamId: String,
        /// Whether or not the account is community banned.
        pub CommunityBanned: bool,
        /// Whether or not the account is VAC banned.
        pub VACBanned: bool,
        /// Amount of VAC bans the account has, Returns 0 if the account has none.
        pub NumberOfVACBans: i32,
        /// Amount of days since the last ban
        pub DaysSinceLastBan: i32,
        /// Amount of Game bans the account has, Returns 0 if the account has none.
        pub NumberOfGameBans: i32,
        /// Whether or not the account has an economy ban
        pub EconomyBan: String,
    }

    #[derive(Debug, Deserialize, Default)]
    pub struct Response {
        /// A vector of all the users
        pub players: Vec<User>,
    }
}

pub mod level {
    use super::{Deserialize, Serialize};

    #[derive(Debug, Serialize, Deserialize, Default)]
    #[allow(non_snake_case)]
    pub struct User {
        pub player_level: Option<i32>,
    }

    #[derive(Debug, Serialize, Deserialize, Default)]
    #[allow(non_snake_case)]
    pub struct Response {
        pub response: User,
    }
}

pub mod friends {
    use super::{Deserialize, Serialize};

    #[derive(Debug, Deserialize, Serialize, Default)]
    #[allow(non_snake_case)]
    pub struct User {
        /// Returns Steam ID of friend
        pub steamid: String,
        /// Friends relationship to the specified Steam ID
        pub relationship: String,
        /// Amount of time the users has been friends with the specified Steam ID
        pub friend_since: i32,
    }

    #[derive(Debug, Deserialize, Default)]
    #[allow(non_snake_case)]
    pub struct Users {
        pub friends: Vec<User>,
    }

    #[derive(Debug, Deserialize, Default)]
    pub struct Response {
        pub friendslist: Users,
    }
}

pub mod summaries {
    use super::{Deserialize, Serialize};

    /// `communityvisibilitystate`
    /// Returns `3` if the profile is public
    /// Otherwise the profile isn't visible to you
    /// # Example output
    /// `3`
    ///
    /// `relationship`
    /// Friends relationship to the specified Steam ID
    ///
    /// `friend_since`
    /// Amount of time the users has been friends with the specified Steam ID
    #[derive(Debug, Deserialize, Serialize, Default)]
    pub struct User {
        /// Returns Steam ID of specified account
        pub steamid: String,

        /// The current visibility state of the profile
        pub communityvisibilitystate: i32,

        /// Profile state
        ///
        /// 0 if the profile doesn't have a community profile
        /// 1 if it does
        pub profilestate: i32,

        /// Profile name (not the actual account login name)
        pub personaname: String,

        /// Comment section permissions
        /// TODO: look into this further, docs online are lacking
        /// TODO: add tests
        pub commentpermissions: Option<i32>,

        // The profiles custom steam url
        pub profileurl: String,
        /// Url of the players avatar (32x32px)
        pub avatar: String,

        /// Url of the players avatar (64x64px)
        pub avatarmedium: String,

        /// Url of the players avatar (184x184px)
        pub avatarfull: String,

        /// Hash of the users avatar
        pub avatarhash: String,

        /// Time since user was last online (unix timestamp)
        pub lastlogoff: Option<i32>,

        /// The Users current status:
        ///
        /// 0 = Offline
        ///
        /// 1 = Online
        ///
        /// 2 = Busy
        ///
        /// 3 = Away
        ///
        /// 4 = Snooze
        ///
        /// 5 = looking to trade
        ///
        /// 6 = looking to play
        ///
        /// If the player's profile is private, this will always be 0.
        pub personastate: i32,

        // private data
        pub realname: Option<String>,
        pub primaryclanid: Option<String>,
        pub timecreated: Option<i32>,
        pub gameid: Option<String>,
        pub gameserverip: Option<String>,
        pub gameextrainfo: Option<String>,
        pub loccountrycode: Option<String>,
        pub locstatecode: Option<String>,
        pub loccityid: Option<i32>,
    }

    #[derive(Debug, Deserialize, Default)]
    pub struct Users {
        pub players: Vec<User>,
    }

    #[derive(Debug, Deserialize, Default)]
    pub struct Response {
        pub response: Users,
    }
}

pub mod profile {
    use super::Serialize;
    // This will hold the info for each player from all the above structs
    #[derive(Default, Debug, Serialize)]
    #[allow(non_snake_case)] // blame valve for the random variable naming schemes
    pub struct User {
        // GetPlayerSummaries
        // lowercase
        pub steamid: String,
        pub communityvisibilitystate: i32,
        pub profilestate: i32,
        pub personaname: String,
        pub commentpermissions: i32,
        pub profileurl: String,
        pub avatar: String,
        pub avatarmedium: String,
        pub avatarfull: String,
        pub avatarhash: String,
        pub lastlogoff: i32,
        pub personastate: i32,

        // private data
        pub realname: String,
        pub primaryclanid: String,
        pub timecreated: i32,
        pub gameid: String,
        pub gameserverip: String,
        pub gameextrainfo: String,
        pub loccountrycode: String,
        pub locstatecode: String,
        pub loccityid: i32,

        //GetPlayerBans
        //CamelCase
        pub CommunityBanned: bool,
        pub VACBanned: bool,
        pub NumberOfVACBans: i32,
        pub DaysSinceLastBan: i32,
        pub NumberOfGameBans: i32,
        pub EconomyBan: String,

        //GetSteamLevel
        //snake_case
        pub player_level: i32,
    }

    // this will store all the above structs if multiple id's are requested
    #[derive(Debug, Serialize, Default)]
    pub struct Users {
        pub api_call_count: i32,
        pub user: Vec<User>,
    }
}

pub mod api {
    #[derive(Default)]
    pub struct Api<'a> {
        pub interface: &'a str,
        pub version: &'a str,
        pub accepts_multiple_ids: bool,
    }
}