-
Notifications
You must be signed in to change notification settings - Fork 79
/
search.go
43 lines (33 loc) · 903 Bytes
/
search.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
package gochimp3
const (
search_members_path = "/search-members"
)
type SearchMembersQueryParams struct {
BasicQueryParams
Query string
listID string
}
func (q *SearchMembersQueryParams) Params() map[string]string {
m := q.BasicQueryParams.Params()
m["query"] = q.Query
m["list_id"] = q.listID
return m
}
type SearchMembersResponse struct {
ExactMatches Matches `json:"exact_matches"`
FullSearch Matches `json:"full_search"`
Links []Link `json:"_links"`
}
type Matches struct {
Members []Member `json:"members"`
TotalItems int64 `json:"total_items"`
}
func (list *ListResponse) SearchMembers(params *SearchMembersQueryParams) (*SearchMembersResponse, error) {
response := new(SearchMembersResponse)
params.listID = list.ID
err := list.api.Request("GET", search_members_path, params, nil, response)
if err != nil {
return nil, err
}
return response, nil
}