-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathachievements.go
84 lines (80 loc) · 1.94 KB
/
achievements.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
package wowapi
import (
"encoding/json"
"fmt"
)
type Achievements struct {
RecentEvents []struct {
Achievement struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
Id float64 `json:"id"`
} `json:"achievement"`
Timestamp float64 `json:"timestamp"`
} `json:"recent_events"`
Character struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
Id float64 `json:"id"`
Realm struct {
Id float64 `json:"id"`
Slug string `json:"slug"`
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
} `json:"realm"`
} `json:"character"`
Statistics struct {
Href string `json:"href"`
} `json:"statistics"`
Links struct {
Self struct {
Href string `json:"href"`
} `json:"self"`
} `json:"_links"`
TotalQuantity float64 `json:"total_quantity"`
TotalPoints float64 `json:"total_points"`
Achievements []struct {
Id float64 `json:"id"`
Achievement struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
Id float64 `json:"id"`
} `json:"achievement"`
Criteria struct {
Id float64 `json:"id"`
IsCompleted bool `json:"is_completed"`
} `json:"criteria"`
CompletedTimestamp float64 `json:"completed_timestamp"`
} `json:"achievements"`
CategoryProgress []struct {
Points float64 `json:"points"`
Category struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
Id float64 `json:"id"`
} `json:"category"`
Quantity float64 `json:"quantity"`
} `json:"category_progress"`
}
func (req RequestFunc) CharacterAchievements(realm string, name string) (s Achievements, err error) {
url := fmt.Sprintf("/profile/wow/character/%s/%s/achievements", realm, name)
body, err := req(url)
if err != nil {
return
}
err = json.Unmarshal(body, &s)
if err != nil {
return
}
return
}