-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrequests.go
210 lines (188 loc) · 4.61 KB
/
requests.go
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
package tbago
import "fmt"
func (b tbaStatusBuilder) Get() (TBAStatus, error) {
url := "status"
var d TBAStatus
err := b.client.URLStruct(url, &d)
return d, err
}
func (b teamsBuilder) Get() ([]Team, error) {
var url string
if b.event != "" {
url = fmt.Sprintf("event/%s/teams", b.event)
} else if b.district != "" {
url = fmt.Sprintf("district/%d%s/teams", b.year, b.district)
} else {
url = fmt.Sprintf("teams/%d", b.page)
}
if b.simple {
url += "/simple"
}
var d []Team
err := b.client.URLStruct(url, &d)
return d, err
}
func (b teamBuilder) Get() (Team, error) {
url := fmt.Sprintf("team/frc%d", b.number)
if b.simple {
url += "/simple"
}
var d Team
err := b.client.URLStruct(url, &d)
return d, err
}
func (b eventsBuilder) Get() ([]Event, error) {
var url string
if b.team != 0 {
url = fmt.Sprintf("team/frc%d/events", b.team)
} else if b.district != "" {
url = fmt.Sprintf("district/%d%s/events", b.year, b.district)
} else {
url = fmt.Sprintf("events/%d", b.year)
}
if b.simple {
url += "/simple"
}
var d []Event
err := b.client.URLStruct(url, &d)
return d, err
}
func (b eventBuilder) Get() (Event, error) {
url := fmt.Sprintf("event/%s", b.id)
var d Event
err := b.client.URLStruct(url, &d)
return d, err
}
func (b awardsBuilder) Get() ([]Award, error) {
var url string
if b.team != 0 {
url += fmt.Sprintf("team/frc%d/", b.team)
}
if b.event != "" {
url += fmt.Sprintf("event/%s/", b.event)
}
url += "awards"
if b.year != 0 {
url += fmt.Sprintf("/%d", b.year)
}
var d []Award
err := b.client.URLStruct(url, &d)
return d, err
}
func (b statusBuilder) Get() (Status, error) {
url := fmt.Sprintf("team/frc%d/event/%s/status", b.team, b.event)
var d Status
err := b.client.URLStruct(url, &d)
return d, err
}
func (b matchesBuilder) Get() ([]Match, error) {
var url string
if b.team != 0 {
url += fmt.Sprintf("team/frc%d/", b.team)
}
if b.event != "" {
url += fmt.Sprintf("event/%s/", b.event)
}
url += "matches"
if b.year != 0 {
url = fmt.Sprintf("%s/%d", url, b.year)
}
if b.simple {
url += "/simple"
}
var d []Match
err := b.client.URLStruct(url, &d)
return d, err
}
func (b matchBuilder) Get() (Match, error) {
url := fmt.Sprintf("match/%s", b.key)
if b.simple {
url += "/simple"
}
var d Match
err := b.client.URLStruct(url, &d)
return d, err
}
func (b yearsBuilder) Get() ([]Year, error) {
url := fmt.Sprintf("team/frc%d/years_participated", b.team)
var d []Year
err := b.client.URLStruct(url, &d)
return d, err
}
func (b mediaBuilder) Get() ([]Media, error) {
url := fmt.Sprintf("team/frc%d/media", b.team)
if b.tag != "" {
url = fmt.Sprintf("%s/tag/%s", url, b.tag)
}
if b.year != 0 {
url = fmt.Sprintf("%s/%d", url, b.year)
}
var d []Media
err := b.client.URLStruct(url, &d)
return d, err
}
func (b robotsBuilder) Get() ([]Robot, error) {
url := fmt.Sprintf("team/frc%d/robots", b.team)
var d []Robot
err := b.client.URLStruct(url, &d)
return d, err
}
func (b districtsBuilder) Get() ([]District, error) {
var url string
if b.team != 0 {
url = fmt.Sprintf("team/frc%d/districts", b.team)
} else {
url = fmt.Sprintf("districts/%d", b.year)
}
var d []District
err := b.client.URLStruct(url, &d)
return d, err
}
func (b profilesBuilder) Get() ([]Profile, error) {
url := fmt.Sprintf("team/frc%d/social_media", b.team)
var d []Profile
err := b.client.URLStruct(url, &d)
return d, err
}
func (b alliancesBuilder) Get() ([]Alliance, error) {
url := fmt.Sprintf("event/%s/alliances", b.event)
var d []Alliance
err := b.client.URLStruct(url, &d)
return d, err
}
func (b districtPointsBuilder) Get() (DistrictPoints, error) {
url := fmt.Sprintf("event/%s/district_points", b.event)
var d DistrictPoints
err := b.client.URLStruct(url, &d)
return d, err
}
func (b insightsBuilder) Get() (Insights, error) {
url := fmt.Sprintf("event/%s/insights", b.event)
var d Insights
err := b.client.URLStruct(url, &d)
return d, err
}
func (b oprsBuilder) Get() (OPRs, error) {
url := fmt.Sprintf("event/%s/oprs", b.event)
var d OPRs
err := b.client.URLStruct(url, &d)
return d, err
}
func (b predictionsBuilder) Get() (Predictions, error) {
url := fmt.Sprintf("event/%s/predictions", b.event)
var d Predictions
err := b.client.URLStruct(url, &d)
return d, err
}
func (b rankingsBuilder) Get() (Rankings, error) {
url := fmt.Sprintf("event/%s/rankings", b.event)
var d Rankings
err := b.client.URLStruct(url, &d)
return d, err
}
func (b districtRankingsBuilder) Get() ([]DistrictRankings, error) {
url := fmt.Sprintf("district/%d%s/rankings", b.year, b.abbreviation)
var d []DistrictRankings
err := b.client.URLStruct(url, &d)
return d, err
}