-
Notifications
You must be signed in to change notification settings - Fork 6
/
endpoints_search.go
51 lines (43 loc) · 1.45 KB
/
endpoints_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
44
45
46
47
48
49
50
51
package itchio
import "context"
// SearchGamesParams : params for SearchGames
type SearchGamesParams struct {
Query string
Page int64
}
// SearchGamesResponse : response for SearchGames
type SearchGamesResponse struct {
Page int64 `json:"page"`
PerPage int64 `json:"perPage"`
Games []*Game `json:"games"`
}
// SearchGames performs a text search for games (or any project type).
// The games must be published, and not deindexed. There are a bunch
// of subtleties about visibility and ranking, but that's internal.
func (c *Client) SearchGames(ctx context.Context, params SearchGamesParams) (*SearchGamesResponse, error) {
q := NewQuery(c, "/search/games")
q.AddString("query", params.Query)
q.AddInt64IfNonZero("page", params.Page)
r := &SearchGamesResponse{}
return r, q.Get(ctx, r)
}
//-------------------------------------------------------
// SearchUsersParams : params for SearchUsers
type SearchUsersParams struct {
Query string
Page int64
}
// SearchUsersResponse : response for SearchUsers
type SearchUsersResponse struct {
Page int64 `json:"page"`
PerPage int64 `json:"perPage"`
Users []*User `json:"users"`
}
// SearchUsers performs a text search for users.
func (c *Client) SearchUsers(ctx context.Context, params SearchUsersParams) (*SearchUsersResponse, error) {
q := NewQuery(c, "/search/users")
q.AddString("query", params.Query)
q.AddInt64IfNonZero("page", params.Page)
r := &SearchUsersResponse{}
return r, q.Get(ctx, r)
}