-
Notifications
You must be signed in to change notification settings - Fork 3
/
eventapi_information.go
48 lines (43 loc) · 1.12 KB
/
eventapi_information.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
package webapi
// Information contains all api endpoints regarding information
type Information struct {
api *EventAPI
}
// newParticipant creates a new Participant api endpoint group
func newInformation(api *EventAPI) *Information {
return &Information{
api: api,
}
}
// FrequentNames returns frequent first names have the given prefix
func (q *Information) FrequentNames(prefix string, maxNo int) ([]string, error) {
values := urlValues{
"prefix": prefix,
"maxNo": maxNo,
}
bts, err := q.api.get("information/frequentnames", values)
if err != nil {
return nil, err
}
return parseJsonStringArr(bts)
}
// GetSex returns gender of the given first name
func (q *Information) GetSex(name string) (string, error) {
values := urlValues{
"name": name,
}
bts, err := q.api.get("information/getsex", values)
if err != nil {
return "", err
}
return string(bts), nil
}
// AddFirstName adds a name to the database of first names
func (q *Information) AddFirstName(name string, sex string) error {
values := urlValues{
"name": name,
"sex": sex,
}
_, err := q.api.get("information/addfirstname", values)
return err
}