-
Notifications
You must be signed in to change notification settings - Fork 21
/
d3c.go
291 lines (258 loc) · 9.4 KB
/
d3c.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
package blizzard
import (
"context"
"fmt"
"github.com/FuzzyStatic/blizzard/v3/d3c"
)
// D3ActIndex returns an index of acts
func (c *Client) D3ActIndex(ctx context.Context) (*d3c.ActIndex, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/act",
&d3c.ActIndex{},
)
return dat.(*d3c.ActIndex), header, err
}
// D3Act returns information about act based on ID
func (c *Client) D3Act(ctx context.Context, id int) (*d3c.Act, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/data/act/%d", id),
&d3c.Act{},
)
return dat.(*d3c.Act), header, err
}
// D3Blacksmith returns blacksmith data
func (c *Client) D3Blacksmith(ctx context.Context) (*d3c.Artisan, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/artisan/blacksmith",
&d3c.Artisan{},
)
return dat.(*d3c.Artisan), header, err
}
// D3Jeweler returns jeweler data
func (c *Client) D3Jeweler(ctx context.Context) (*d3c.Artisan, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/artisan/jeweler",
&d3c.Artisan{},
)
return dat.(*d3c.Artisan), header, err
}
// D3Mystic returns mystic data
func (c *Client) D3Mystic(ctx context.Context) (*d3c.Artisan, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/artisan/mystic",
&d3c.Artisan{},
)
return dat.(*d3c.Artisan), header, err
}
// D3BlacksmithRecipe returns blacksmith recipe data
func (c *Client) D3BlacksmithRecipe(ctx context.Context, recipeSlug string) (*d3c.Recipe, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/data/artisan/blacksmith/recipe/%s", recipeSlug),
&d3c.Recipe{},
)
return dat.(*d3c.Recipe), header, err
}
// D3JewelerRecipe returns jeweler recipe data
func (c *Client) D3JewelerRecipe(ctx context.Context, recipeSlug string) (*d3c.Recipe, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/data/artisan/jeweler/recipe/%s", recipeSlug),
&d3c.Recipe{},
)
return dat.(*d3c.Recipe), header, err
}
// D3Enchantress returns enchantress data
func (c *Client) D3Enchantress(ctx context.Context) (*d3c.Follower, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/follower/enchantress",
&d3c.Follower{},
)
return dat.(*d3c.Follower), header, err
}
// D3Scoundrel returns scoundrel data
func (c *Client) D3Scoundrel(ctx context.Context) (*d3c.Follower, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/follower/scoundrel",
&d3c.Follower{},
)
return dat.(*d3c.Follower), header, err
}
// D3Templar returns templar data
func (c *Client) D3Templar(ctx context.Context) (*d3c.Follower, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/follower/templar",
&d3c.Follower{},
)
return dat.(*d3c.Follower), header, err
}
// D3Barbarian returns barbarian data
func (c *Client) D3Barbarian(ctx context.Context) (*d3c.Hero, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/hero/barbarian",
&d3c.Hero{},
)
return dat.(*d3c.Hero), header, err
}
// D3Crusader returns crusader data
func (c *Client) D3Crusader(ctx context.Context) (*d3c.Hero, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/hero/crusader",
&d3c.Hero{},
)
return dat.(*d3c.Hero), header, err
}
// D3DemonHunter returns demon hunter data
func (c *Client) D3DemonHunter(ctx context.Context) (*d3c.Hero, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/hero/demon-hunter",
&d3c.Hero{},
)
return dat.(*d3c.Hero), header, err
}
// D3Monk returns monk data
func (c *Client) D3Monk(ctx context.Context) (*d3c.Hero, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/hero/monk",
&d3c.Hero{},
)
return dat.(*d3c.Hero), header, err
}
// D3Necromancer returns necromancer data
func (c *Client) D3Necromancer(ctx context.Context) (*d3c.Hero, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/hero/necromancer",
&d3c.Hero{},
)
return dat.(*d3c.Hero), header, err
}
// D3Wizard returns wizard data
func (c *Client) D3Wizard(ctx context.Context) (*d3c.Hero, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/hero/wizard",
&d3c.Hero{},
)
return dat.(*d3c.Hero), header, err
}
// D3WitchDoctor returns witch doctor data
func (c *Client) D3WitchDoctor(ctx context.Context) (*d3c.Hero, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/hero/witch-doctor",
&d3c.Hero{},
)
return dat.(*d3c.Hero), header, err
}
// D3BarbarianSkill returns barbarian skill data
func (c *Client) D3BarbarianSkill(ctx context.Context, skillSlug string) (*d3c.Skill, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/data/hero/barbarian/skill/%s", skillSlug),
&d3c.Skill{},
)
return dat.(*d3c.Skill), header, err
}
// D3CrusaderSkill returns crusader skill data
func (c *Client) D3CrusaderSkill(ctx context.Context, skillSlug string) (*d3c.Skill, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/data/hero/crusader/skill/%s", skillSlug),
&d3c.Skill{},
)
return dat.(*d3c.Skill), header, err
}
// D3DemonHunterSkill returns demon hunter skill data
func (c *Client) D3DemonHunterSkill(ctx context.Context, skillSlug string) (*d3c.Skill, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/data/hero/demon-hunter/skill/%s", skillSlug),
&d3c.Skill{},
)
return dat.(*d3c.Skill), header, err
}
// D3MonkSkill returns monk skill data
func (c *Client) D3MonkSkill(ctx context.Context, skillSlug string) (*d3c.Skill, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/data/hero/monk/skill/%s", skillSlug),
&d3c.Skill{},
)
return dat.(*d3c.Skill), header, err
}
// D3NecromancerSkill returns necromancer skill data
func (c *Client) D3NecromancerSkill(ctx context.Context, skillSlug string) (*d3c.Skill, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/data/hero/necromancer/skill/%s", skillSlug),
&d3c.Skill{},
)
return dat.(*d3c.Skill), header, err
}
// D3WizardSkill returns wizard skill data
func (c *Client) D3WizardSkill(ctx context.Context, skillSlug string) (*d3c.Skill, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/data/hero/wizard/skill/%s", skillSlug),
&d3c.Skill{},
)
return dat.(*d3c.Skill), header, err
}
// D3WitchDoctorSkill returns witch doctor skill data
func (c *Client) D3WitchDoctorSkill(ctx context.Context, skillSlug string) (*d3c.Skill, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/data/hero/witch-doctor/skill/%s", skillSlug),
&d3c.Skill{},
)
return dat.(*d3c.Skill), header, err
}
// D3ItemTypeIndex returns an index of item types
func (c *Client) D3ItemTypeIndex(ctx context.Context) (*d3c.ItemTypeIndex, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
"/d3/data/item-type",
&d3c.ItemTypeIndex{},
)
return dat.(*d3c.ItemTypeIndex), header, err
}
// D3ItemType returns item type data
func (c *Client) D3ItemType(ctx context.Context, itemTypeSlug string) (*d3c.ItemType, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/data/item-type/%s", itemTypeSlug),
&d3c.ItemType{},
)
return dat.(*d3c.ItemType), header, err
}
// D3Item returns item data
func (c *Client) D3Item(ctx context.Context, itemSlug, itemID string) (*d3c.Item, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/data/item/%s-%s", itemSlug, itemID),
&d3c.Item{},
)
return dat.(*d3c.Item), header, err
}
// D3Profile returns profile data
// Formats accepted: Player-1234 or Player#1234
func (c *Client) D3Profile(ctx context.Context, account string) (*d3c.Profile, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/profile/%s/", formatAccount(account)),
&d3c.Profile{},
)
return dat.(*d3c.Profile), header, err
}
// D3ProfileHero returns profile's hero data
// Formats accepted: Player-1234 or Player#1234
func (c *Client) D3ProfileHero(ctx context.Context, account string, heroID int) (*d3c.ProfileHero, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/profile/%s/hero/%d", formatAccount(account), heroID),
&d3c.ProfileHero{},
)
return dat.(*d3c.ProfileHero), header, err
}
// D3ProfileHeroItems returns profile's hero's item data
// Formats accepted: Player-1234 or Player#1234
func (c *Client) D3ProfileHeroItems(ctx context.Context, account string, heroID int) (*d3c.ProfileHeroItems, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/profile/%s/hero/%d/items", formatAccount(account), heroID),
&d3c.ProfileHeroItems{},
)
return dat.(*d3c.ProfileHeroItems), header, err
}
// D3ProfileHeroFollowerItems returns profile's hero's follower item data
// Formats accepted: Player-1234 or Player#1234
func (c *Client) D3ProfileHeroFollowerItems(ctx context.Context, account string, heroID int) (*d3c.ProfileHeroFollowerItems, *Header, error) {
dat, header, err := c.getStructDataNoNamespace(ctx,
fmt.Sprintf("/d3/profile/%s/hero/%d/follower-items", formatAccount(account), heroID),
&d3c.ProfileHeroFollowerItems{},
)
return dat.(*d3c.ProfileHeroFollowerItems), header, err
}