-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.go
53 lines (46 loc) · 1.55 KB
/
user.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
package myanimelist
import (
"net/http"
"net/url"
"time"
)
type User struct {
mal *MAL
}
// UserInformation can only retrieve info about current user for now.
func (u *User) Info() (*UserInfo, error) {
method := http.MethodGet
path := "./users/@me"
data := url.Values{
"fields": {"anime_statistics"},
}
userInfo := new(UserInfo)
if err := u.mal.request(userInfo, method, path, data); err != nil {
return nil, err
}
return userInfo, nil
}
type UserInfo struct {
ID int `json:"id"`
Name string `json:"name"`
Location string `json:"location"`
JoinedAt time.Time `json:"joined_at"`
AnimeStatistics AnimeStatistics `json:"anime_statistics"`
}
type AnimeStatistics struct {
NumItemsWatching int `json:"num_items_watching"`
NumItemsCompleted int `json:"num_items_completed"`
NumItemsOnHold int `json:"num_items_on_hold"`
NumItemsDropped int `json:"num_items_dropped"`
NumItemsPlanToWatch int `json:"num_items_plan_to_watch"`
NumItems int `json:"num_items"`
NumDaysWatched float64 `json:"num_days_watched"`
NumDaysWatching float64 `json:"num_days_watching"`
NumDaysCompleted float64 `json:"num_days_completed"`
NumDaysOnHold float64 `json:"num_days_on_hold"`
NumDaysDropped float64 `json:"num_days_dropped"`
NumDays float64 `json:"num_days"`
NumEpisodes int `json:"num_episodes"`
NumTimesRewatched int `json:"num_times_rewatched"`
MeanScore float64 `json:"mean_score"`
}