forked from FuzzyStatic/blizzard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwowcgd.go
537 lines (435 loc) · 12.2 KB
/
wowcgd.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
package blizzard
import (
"encoding/json"
"fmt"
"github.com/FuzzyStatic/blizzard/wowcgd"
"github.com/FuzzyStatic/blizzard/wowgd"
)
// ClassicWoWCreatureFamiliesIndex returns an index of creature families.
func (c *Client) ClassicWoWCreatureFamiliesIndex() (*wowcgd.CreatureFamiliesIndex, []byte, error) {
var (
dat wowcgd.CreatureFamiliesIndex
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/creature-family/index?locale=%s", c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWCreatureFamily returns a creature family by ID.
func (c *Client) ClassicWoWCreatureFamily(creatureFamilyID int) (*wowcgd.CreatureFamily, []byte, error) {
var (
dat wowcgd.CreatureFamily
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/creature-family/%d?locale=%s", creatureFamilyID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWCreatureTypesIndex returns an index of creature types.
func (c *Client) ClassicWoWCreatureTypesIndex() (*wowcgd.CreatureTypesIndex, []byte, error) {
var (
dat wowcgd.CreatureTypesIndex
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/creature-type/index?locale=%s", c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWCreatureType returns a creature type by ID.
func (c *Client) ClassicWoWCreatureType(creatureTypeID int) (*wowcgd.CreatureType, []byte, error) {
var (
dat wowcgd.CreatureType
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/creature-type/%d?locale=%s", creatureTypeID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWCreature returns a creature type by ID.
func (c *Client) ClassicWoWCreature(creatureID int) (*wowcgd.Creature, []byte, error) {
var (
dat wowcgd.Creature
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/creature/%d?locale=%s", creatureID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWCreatureDisplayMedia returns media for a creature display by ID.
func (c *Client) ClassicWoWCreatureDisplayMedia(creatureDisplayID int) (*wowcgd.CreatureDisplayMedia, []byte, error) {
var (
dat wowcgd.CreatureDisplayMedia
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/media/creature-display/%d?locale=%s", creatureDisplayID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWCreatureFamilyMedia returns media for a creature family by ID.
func (c *Client) ClassicWoWCreatureFamilyMedia(creatureFamilyID int) (*wowcgd.CreatureFamilyMedia, []byte, error) {
var (
dat wowcgd.CreatureFamilyMedia
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/media/creature-family/%d?locale=%s", creatureFamilyID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWGuildCrestComponentsIndex returns an index of guild crest media
func (c *Client) ClassicWoWGuildCrestComponentsIndex() (*wowcgd.GuildCrestComponentsIndex, []byte, error) {
var (
dat wowcgd.GuildCrestComponentsIndex
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/guild-crest/index?locale=%s", c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWGuildCrestBorderMedia returns media for a guild crest border by ID
func (c *Client) ClassicWoWGuildCrestBorderMedia(borderID int) (*wowcgd.GuildCrestBorderMdedia, []byte, error) {
var (
dat wowcgd.GuildCrestBorderMdedia
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/media/guild-crest/border/%d?locale=%s", borderID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWGuildCrestEmblemMedia returns media for a guild crest emblem by ID
func (c *Client) ClassicWoWGuildCrestEmblemMedia(emblemID int) (*wowcgd.GuildCrestEmblemMdedia, []byte, error) {
var (
dat wowcgd.GuildCrestEmblemMdedia
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/media/guild-crest/emblem/%d?locale=%s", emblemID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWItemClassesIndex returns an index of item classes
func (c *Client) ClassicWoWItemClassesIndex() (*wowcgd.ItemClassesIndex, []byte, error) {
var (
dat wowcgd.ItemClassesIndex
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/item-class/index?locale=%s", c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWItemClass returns an item class by ID
func (c *Client) ClassicWoWItemClass(itemClassID int) (*wowcgd.ItemClass, []byte, error) {
var (
dat wowcgd.ItemClass
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/item-class/%d?locale=%s", itemClassID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWItemSubclass returns an item subclass by ID
func (c *Client) ClassicWoWItemSubclass(itemClassID, itemSubclassID int) (*wowcgd.ItemSubclass, []byte, error) {
var (
dat wowcgd.ItemSubclass
b []byte
err error
)
b, err = c.getURLBody(
c.apiURL+fmt.Sprintf("/data/wow/item-class/%d/item-subclass/%d?locale=%s", itemClassID, itemSubclassID, c.locale),
c.staticClassicNamespace,
)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWItem returns an item by ID
func (c *Client) ClassicWoWItem(itemID int) (*wowcgd.Item, []byte, error) {
var (
dat wowcgd.Item
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/item/%d?locale=%s", itemID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWItemMedia returns media for an item by ID
func (c *Client) ClassicWoWItemMedia(itemID int) (*wowcgd.ItemMedia, []byte, error) {
var (
dat wowcgd.ItemMedia
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/media/item/%d?locale=%s", itemID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWPlayableClassesIndex returns an index of playable classes
func (c *Client) ClassicWoWPlayableClassesIndex() (*wowcgd.PlayableClassesIndex, []byte, error) {
var (
dat wowcgd.PlayableClassesIndex
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/playable-class/index?locale=%s", c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWPlayableClass returns a playable class by ID
func (c *Client) ClassicWoWPlayableClass(classID int) (*wowcgd.PlayableClass, []byte, error) {
var (
dat wowcgd.PlayableClass
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/playable-class/%d?locale=%s", classID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWPlayableClassMedia returns media for a playable class by ID
func (c *Client) ClassicWoWPlayableClassMedia(playableClassID int) (*wowcgd.PlayableClassMedia, []byte, error) {
var (
dat wowcgd.PlayableClassMedia
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/media/playable-class/%d?locale=%s", playableClassID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWPlayableRacesIndex returns an index of playable races
func (c *Client) ClassicWoWPlayableRacesIndex() (*wowcgd.PlayableRacesIndex, []byte, error) {
var (
dat wowcgd.PlayableRacesIndex
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/playable-race/index?locale=%s", c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWPlayableRace returns a playable race by ID
func (c *Client) ClassicWoWPlayableRace(raceID int) (*wowcgd.PlayableRace, []byte, error) {
var (
dat wowcgd.PlayableRace
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/playable-race/%d?locale=%s", raceID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWPowerTypesIndex returns an index of power types
func (c *Client) ClassicWoWPowerTypesIndex() (*wowcgd.PowerTypesIndex, []byte, error) {
var (
dat wowcgd.PowerTypesIndex
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/power-type/index?locale=%s", c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWPowerType returns a power type by ID
func (c *Client) ClassicWoWPowerType(powerTypeID int) (*wowcgd.PowerType, []byte, error) {
var (
dat wowcgd.PowerType
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/power-type/%d?locale=%s", powerTypeID, c.locale), c.staticClassicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWRealmIndex returns an index of realms.
func (c *Client) ClassicWoWRealmIndex() (*wowgd.RealmIndex, []byte, error) {
var (
dat wowgd.RealmIndex
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/realm/index?locale=%s", c.locale), c.dynamicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWRealm returns a single realm by slug or ID.
func (c *Client) ClassicWoWRealm(realmSlug string) (*wowgd.Realm, []byte, error) {
var (
dat wowgd.Realm
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/realm/%s?locale=%s", realmSlug, c.locale), c.dynamicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}
// ClassicWoWRegionIndex returns an index of regions.
func (c *Client) ClassicWoWRegionIndex() (*wowgd.RegionIndex, []byte, error) {
var (
dat wowgd.RegionIndex
b []byte
err error
)
b, err = c.getURLBody(c.apiURL+fmt.Sprintf("/data/wow/region/index?locale=%s", c.locale), c.dynamicNamespace)
if err != nil {
return &dat, b, err
}
err = json.Unmarshal(b, &dat)
if err != nil {
return &dat, b, err
}
return &dat, b, nil
}