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
use serde::{
Deserialize,
Serialize,
};
use crate::{
entrant::*,
event::*,
page_info::*,
phase_group::*,
player::*,
standing_stats::*,
tournament::*,
};
/// Equivalent for start.gg StandingContainer.
#[derive(Clone, Serialize, Deserialize)]
#[serde(tag = "__typename")]
pub enum GGStandingContainer {
Tournament(GGTournament),
Event(GGEvent),
PhaseGroup(GGPhaseGroup),
// GGSet,
}
#[derive(Clone, Default, Serialize, Deserialize)]
pub struct GGStandingConnection {
pub nodes: Vec<GGStanding>,
pub page_info: Option<Box<GGPageInfo>>,
}
impl GGStandingConnection {
/// Returns the page info of the connection.
///
/// Returns empty page info if not set or wasn't queried.
pub fn page_info(&self) -> GGPageInfo {
let mut result: GGPageInfo = Default::default();
if self.page_info.is_some() {
result = *self.page_info.as_ref().unwrap().clone();
}
return result;
}
}
/// Equivalent for start.gg Standing.
///
/// Each element in the structure is optional, allowing a user to only query values they want.
/// Given each is an option and not a requirement, a method is included for each element with the same name.
/// These methods will unwrap and return the proper value without any unwrapping or references needed.
#[derive(Clone, Default, Serialize, Deserialize)]
pub struct GGStanding {
pub container: Option<Box<GGStandingContainer>>,
pub entrant: Option<Box<GGEntrant>>,
pub id: Option<i64>,
#[serde(rename(serialize = "isFinal", deserialize = "isFinal"))]
pub is_final: Option<bool>,
// pub metadata: Option<JSON>,
pub placement: Option<i64>,
pub player: Option<Box<GGPlayer>>,
pub stats: Option<Box<GGStandingStats>>,
#[serde(rename(serialize = "totalPoints", deserialize = "totalPoints"))]
pub total_points: Option<f64>,
}
impl GGStanding {
/// Returns the container of the standing.
///
/// Returns an empty container if not set or wasn't queried.
pub fn container(&self) -> i64 {
let result: i64 = 0;
// let mut result: GGStandingContainer;
match **self.container.as_ref().unwrap() {
GGStandingContainer::Tournament(_) => println!("{}", "type: tournament"),
GGStandingContainer::Event(_) => println!("{}", "type: event"),
GGStandingContainer::PhaseGroup(_) => println!("{}", "type: phase group"),
}
if self.container.is_some() {
//result = *self.container.as_ref().unwrap().clone();
}
return result;
}
/// Returns the entrant of the standing.
///
/// Returns an empty entrant if not set or wasn't queried.
pub fn entrant(&self) -> GGEntrant {
let mut result: GGEntrant = Default::default();
if self.entrant.is_some() {
result = *self.entrant.as_ref().unwrap().clone();
}
return result;
}
/// Returns the id of the standing.
///
/// Returns zero if not set or wasn't queried.
pub fn id(&self) -> i64 {
let mut result: i64 = 0;
if self.id.is_some() {
result = self.id.unwrap().clone();
}
return result;
}
/// Returns if the standing is final.
///
/// Returns false if not set or wasn't queried.
pub fn is_final(&self) -> bool {
let mut result: bool = false;
if self.is_final.is_some() {
result = self.is_final.unwrap().clone();
}
return result;
}
/// Returns the placement of the standing.
///
/// Returns zero if not set or wasn't queried.
pub fn placement(&self) -> i64 {
let mut result: i64 = 0;
if self.placement.is_some() {
result = self.placement.unwrap().clone();
}
return result;
}
/// Returns the player of the standing.
///
/// Returns an empty player if not set or wasn't queried.
pub fn player(&self) -> GGPlayer {
let mut result: GGPlayer = Default::default();
if self.player.is_some() {
result = *self.player.as_ref().unwrap().clone();
}
return result;
}
/// Returns the stats of the standing.
///
/// Returns an empty stats if not set or wasn't queried.
pub fn stats(&self) -> GGStandingStats {
let mut result: GGStandingStats = Default::default();
if self.stats.is_some() {
result = *self.stats.as_ref().unwrap().clone();
}
return result;
}
/// Returns the total points of the standing.
///
/// Returns zero if not set or wasn't queried.
pub fn total_points(&self) -> f64 {
let mut result: f64 = 0.0;
if self.total_points.is_some() {
result = self.total_points.unwrap().clone();
}
return result;
}
}