/
user.go
149 lines (124 loc) · 4.59 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
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
package codeforces
import (
"strconv"
)
// GetUserBlogEntries returns a list of all user's blog entries.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#user.blogEntries
func (c *Client) GetUserBlogEntries(handle string) ([]BlogEntry, error) {
params := make(map[string][]string)
params["handle"] = []string{handle}
var res []BlogEntry
err := c.makeAPICall("user.blogEntries", params, &res)
return res, err
}
// GetUserBlogEntries returns a list of all user's blog entries.
//
// GetUserBlogEntries is a wrapper around DefaultClient.GetUserBlogEntries.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#user.blogEntries
func GetUserBlogEntries(handle string) ([]BlogEntry, error) {
return DefaultClient.GetUserBlogEntries(handle)
}
// GetUserFriends Returns authorized user's friends. Using this method requires
// authorization.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#user.friends
func (c *Client) GetUserFriends(onlyOnline bool) ([]string, error) {
params := make(map[string][]string)
params["onlyOnline"] = []string{strconv.FormatBool(onlyOnline)}
var res []string
err := c.makeAPICall("user.friends", params, &res)
return res, err
}
// GetUserFriends returns authorized user's friends. Using this method requires
// authorization.
//
// GetUserFriends is a wrapper around DefaultClient.GetUserFriends.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#user.friends
func GetUserFriends(onlyOnline bool) ([]string, error) {
return DefaultClient.GetUserFriends(onlyOnline)
}
// GetUserInfo returns information about one or several users.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#user.info
func (c *Client) GetUserInfo(handles []string) ([]User, error) {
params := make(map[string][]string)
params["handles"] = handles
var res []User
err := c.makeAPICall("user.info", params, &res)
return res, err
}
// GetUserInfo returns information about one or several users.
//
// GetUserInfo is a wrapper around DefaultClient.GetUserInfo.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#user.info
func GetUserInfo(handles []string) ([]User, error) {
return DefaultClient.GetUserInfo(handles)
}
// GetUserRatedList returns the list users who have participated in at least
// one rated contest.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#user.ratedList
func (c *Client) GetUserRatedList(activeOnly bool) ([]User, error) {
params := make(map[string][]string)
params["activeOnly"] = []string{strconv.FormatBool(activeOnly)}
var res []User
err := c.makeAPICall("user.ratedList", params, &res)
return res, err
}
// GetUserRatedList returns the list users who have participated in at least
// one rated contest.
//
// GetUserRatedList is a wrapper around DefaultClient.GetUserRatedList.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#user.ratedList
func GetUserRatedList(activeOnly bool) ([]User, error) {
return DefaultClient.GetUserRatedList(activeOnly)
}
// GetUserRating returns rating history of the specified user.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#user.rating
func (c *Client) GetUserRating(handle string) ([]RatingChange, error) {
params := make(map[string][]string)
params["handle"] = []string{handle}
var res []RatingChange
err := c.makeAPICall("user.rating", params, &res)
return res, err
}
// GetUserRating returns rating history of the specified user.
//
// GetUserRating is a wrapper around DefaultClient.GetUserRating.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#user.rating
func GetUserRating(handle string) ([]RatingChange, error) {
return DefaultClient.GetUserRating(handle)
}
// GetUserStatus returns submissions of specified user.
//
// Set count to 0 for infinite count.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#user.status
func (c *Client) GetUserStatus(handle string, from, count int) ([]Submission, error) {
params := make(map[string][]string)
params["handle"] = []string{handle}
params["from"] = []string{strconv.FormatInt(int64(from), 10)}
if count != 0 {
params["count"] = []string{strconv.FormatInt(int64(count), 10)}
}
var res []Submission
err := c.makeAPICall("user.status", params, &res)
return res, err
}
// GetUserStatus returns submissions of specified user.
//
// Set count to 0 for infinite count.
//
// GetUserStatus is a wrapper around DefaultClient.GetUserStatus.
//
// Codeforces API docs: https://codeforces.com/apiHelp/methods#user.status
func GetUserStatus(handle string, from, count int) ([]Submission, error) {
return DefaultClient.GetUserStatus(handle, from, count)
}