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
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;

/// A possible json error.
///
/// See http://documentation.rocketleaguestats.com/#response-codes
#[derive(Debug, Deserialize)]
pub struct ResponseCode {
    pub code: i32,
    pub message: String,
}

/// A platform that RocketLeague supports.
#[derive(Clone, Debug, Deserialize)]
pub struct Platform {
    /// Some known IDs:
    ///
    /// * 1 is Steam
    /// * 2 is PS4
    /// * 3 is XboxOne
    pub id: i32,
    pub name: String,
}

/// A RocketLeague season.
#[derive(Debug, Deserialize)]
pub struct Season {
    /// 1, 2, 3, 4 and onwards.
    #[serde(rename = "seasonId")]
    pub season_id: i64,
    /// This is a unix timestamp.
    #[serde(rename = "startedOn")]
    pub started_on: i64,
    /// This is a unix timestamp.
    ///
    /// This field will be `None` if the season has not yet ended.
    #[serde(rename = "endedOn")]
    pub ended_on: Option<i64>,
}

/// Population of a `Playlist`.
#[derive(Debug, Deserialize)]
pub struct Population {
    /// Number of players currently playing the playlist.
    pub players: i32,
    /// This is a unix timestamp.
    #[serde(rename = "updatedAt")]
    pub updated_at: i64,
}

/// A RocketLeague playlist.
#[derive(Debug, Deserialize)]
pub struct Playlist {
    pub id: i32,
    /// See the `Platform` struct.
    #[serde(rename = "platformId")]
    pub platform_id: i32,
    pub name: String,
    pub population: Population,
}

/// A RocketLeague ranked tier.
#[derive(Debug, Deserialize)]
pub struct Tier {
    /// Increments for every tier and sub-tier.
    ///
    /// Example:
    ///
    /// ```no-run
    /// [
    ///     Tier {
    ///         id: 0,
    ///         name: "Unranked"
    ///     },
    ///     Tier {
    ///         id: 1,
    ///         name: "Bronze I"
    ///     },
    ///     Tier {
    ///         id: 2,
    ///         name: "Bronze II"
    ///     },
    ///     Tier {
    ///         id: 3,
    ///         name: "Bronze III"
    ///     },
    ///     Tier {
    ///         id: 4,
    ///         name: "Silver I"
    ///     },
    ///     Tier {
    ///         id: 5,
    ///         name: "Silver II"
    ///     },
    ///     Tier {
    ///         id: 6,
    ///         name: "Silver III"
    ///     },
    ///     Tier {
    ///         id: 7,
    ///         name: "Gold I"
    ///     },
    ///     Tier {
    ///         id: 8,
    ///         name: "Gold II"
    ///     },
    ///     ...
    /// ]
    /// ```
    #[serde(rename = "tierId")]
    pub id: i32,
    #[serde(rename = "tierName")]
    pub name: String,
}

/// Stats about a player.
#[derive(Debug, Deserialize)]
pub struct Stats {
    pub wins: i32,
    pub goals: i32,
    pub mvps: i32,
    pub saves: i32,
    pub shots: i32,
    pub assists: i32,
}

/// Information about a season.
#[derive(Debug, Deserialize)]
pub struct RankedData {
    #[serde(rename = "rankPoints")]
    pub rank_points: Option<i32>,
    #[serde(rename = "matchesPlayed")]
    pub matches_played: Option<i32>,
    pub tier: Option<i32>,
    pub division: Option<i32>,
}

/// A RocketLeague player.
///
/// Players will only exist if they have scored at least one goal.
#[derive(Debug, Deserialize)]
pub struct Player {
    /// Steam 64 ID / PSN Username / Xbox XUID
    #[serde(rename = "uniqueId")]
    pub unique_id: String,
    #[serde(rename = "displayName")]
    pub display_name: String,
    pub platform: Platform,
    pub avatar: Option<String>,
    #[serde(rename = "profileUrl")]
    pub profile_url: String,
    #[serde(rename = "signatureUrl")]
    pub signature_url: String,
    pub stats: Stats,
    #[serde(rename = "rankedSeasons")]
    pub ranked_seasons: BTreeMap<String, BTreeMap<String, RankedData>>,
    /// This is a unix timestamp.
    #[serde(rename = "lastRequested")]
    pub last_requested: i64,
    /// This is a unix timestamp.
    #[serde(rename = "createdAt")]
    pub created_at: i64,
    /// This is a unix timestamp.
    #[serde(rename = "updatedAt")]
    pub updated_at: i64,
    /// This is a unix timestamp.
    #[serde(rename = "nextUpdateAt")]
    pub next_update_at: i64,
}

/// A search response.
#[derive(Debug, Deserialize)]
pub struct SearchResponse {
    pub page: Option<i32>,
    pub results: i32,
    /// The total number of players that match the search.
    #[serde(rename = "totalResults")]
    pub total_results: i32,
    #[serde(rename = "maxResultsPerPage")]
    pub max_results_per_page: i32,
    pub data: Vec<Player>,
}

/// A batch player.
#[derive(Debug, Serialize)]
pub struct BatchPlayer {
    #[serde(rename = "uniqueId")]
    pub id: String,
    #[serde(rename = "platformId")]
    pub platform_id: i32,
}