-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi_static_champion.go
More file actions
80 lines (66 loc) · 2.13 KB
/
api_static_champion.go
File metadata and controls
80 lines (66 loc) · 2.13 KB
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
package riotapi
import (
"net/url"
"strconv"
"strings"
)
// ChampDataTags tags that provide modifiers of what data is returned on a champion request
type ChampDataTag string
const (
ChampDataNil ChampDataTag = ""
ChampDataAll ChampDataTag = "all"
ChampDataAllyTips ChampDataTag = "allytips"
ChampDataAltImages ChampDataTag = "altimages"
ChampDataBlurb ChampDataTag = "blurb"
ChampDataEnemyTips ChampDataTag = "enemytips"
ChampDataImage ChampDataTag = "image"
ChampDataInfo ChampDataTag = "info"
ChampDataLore ChampDataTag = "lore"
ChampDataParType ChampDataTag = "partype"
ChampDataPassive ChampDataTag = "passive"
ChampDataRecommended ChampDataTag = "recommended"
ChampDataSkins ChampDataTag = "skins"
ChampDataSpells ChampDataTag = "spells"
ChampDataStats ChampDataTag = "stats"
ChampDataTags ChampDataTag = "tags"
)
// https://developer.riotgames.com/api/methods#!/1055/3633
// StaticChampion get static champion data
// If version is not defined then it uses the current version
func (c *APIClient) StaticChampion(version string, champData ...ChampDataTag) (cl *ChampionData, err error) {
// setup api query options
q := url.Values{}
if version != "" {
q.Add("version", version)
}
if len(champData) > 0 {
for i := range champData {
q.Add("champData", string(champData[i]))
}
}
err = c.makeStaticRequest("GET", "v1.2", "champion", q, true, cl)
if err != nil {
return cl, err
}
return cl, err
}
// https://developer.riotgames.com/api/methods#!/1055/3622
// StaticChampionByID get a champion by ID
// If version is not defined then it uses the current version
func (c *APIClient) StaticChampionByID(id int, version string, champData ...ChampDataTag) (cd *Champion, err error) {
// setup api query options
q := url.Values{}
if version != "" {
q.Add("version", version)
}
if len(champData) > 0 {
for i := range champData {
q.Add("champData", string(champData[i]))
}
}
err = c.makeStaticRequest("GET", "v1.2", strings.Join([]string{"champion", strconv.Itoa(id)}, "/"), q, true, cd)
if err != nil {
return cd, err
}
return cd, err
}