-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharacter.go
158 lines (154 loc) · 3.75 KB
/
character.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
package wowapi
import (
"encoding/json"
"fmt"
)
type Character struct {
Realm struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
Id float64 `json:"id"`
Slug string `json:"slug"`
} `json:"realm"`
Specializations struct {
Href string `json:"href"`
} `json:"specializations"`
Statistics struct {
Href string `json:"href"`
} `json:"statistics"`
Gender struct {
Type string `json:"type"`
Name string `json:"name"`
} `json:"gender"`
EquippedItemLevel float64 `json:"equipped_item_level"`
Experience float64 `json:"experience"`
Reputations struct {
Href string `json:"href"`
} `json:"reputations"`
Professions struct {
Href string `json:"href"`
} `json:"professions"`
AchievementsStatistics struct {
Href string `json:"href"`
} `json:"achievements_statistics"`
Faction struct {
Type string `json:"type"`
Name string `json:"name"`
} `json:"faction"`
CharacterClass struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
Id float64 `json:"id"`
} `json:"character_class"`
Achievements struct {
Href string `json:"href"`
} `json:"achievements"`
PvpSummary struct {
Href string `json:"href"`
} `json:"pvp_summary"`
Encounters struct {
Href string `json:"href"`
} `json:"encounters"`
Media struct {
Href string `json:"href"`
} `json:"media"`
Equipment struct {
Href string `json:"href"`
} `json:"equipment"`
CovenantProgress struct {
ChosenCovenant struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
Id float64 `json:"id"`
} `json:"chosen_covenant"`
RenownLevel float64 `json:"renown_level"`
Soulbinds struct {
Href string `json:"href"`
} `json:"soulbinds"`
} `json:"covenant_progress"`
ActiveSpec struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
Id float64 `json:"id"`
} `json:"active_spec"`
Links struct {
Self struct {
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
Level float64 `json:"level"`
Appearance struct {
Href string `json:"href"`
} `json:"appearance"`
Collections struct {
Href string `json:"href"`
} `json:"collections"`
Id float64 `json:"id"`
Race struct {
Id float64 `json:"id"`
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
} `json:"race"`
AchievementPoints float64 `json:"achievement_points"`
Titles struct {
Href string `json:"href"`
} `json:"titles"`
LastLoginTimestamp float64 `json:"last_login_timestamp"`
AverageItemLevel float64 `json:"average_item_level"`
Name string `json:"name"`
Guild struct {
Faction struct {
Name string `json:"name"`
Type string `json:"type"`
} `json:"faction"`
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
Id float64 `json:"id"`
Realm struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
Id float64 `json:"id"`
Slug string `json:"slug"`
} `json:"realm"`
} `json:"guild"`
MythicKeystoneProfile struct {
Href string `json:"href"`
} `json:"mythic_keystone_profile"`
ActiveTitle struct {
DisplayString string `json:"display_string"`
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
Id float64 `json:"id"`
} `json:"active_title"`
Quests struct {
Href string `json:"href"`
} `json:"quests"`
}
func (req RequestFunc) CharacterInfo(realm string, name string) (s Character, err error) {
url := fmt.Sprintf("/profile/wow/character/%s/%s", realm, name)
body, err := req(url)
if err != nil {
return
}
err = json.Unmarshal(body, &s)
if err != nil {
return
}
return
}