-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathendpoints_profile.go
More file actions
69 lines (55 loc) · 2.24 KB
/
endpoints_profile.go
File metadata and controls
69 lines (55 loc) · 2.24 KB
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
package itchio
import "context"
//-------------------------------------------------------
// GetProfileResponse is what the API server responds when we ask for the user's profile
type GetProfileResponse struct {
User *User `json:"user"`
}
// GetProfile returns information about the user the current credentials belong to
func (c *Client) GetProfile(ctx context.Context) (*GetProfileResponse, error) {
q := NewQuery(c, "/profile")
r := &GetProfileResponse{}
return r, q.Get(ctx, r)
}
//-------------------------------------------------------
// ListProfileGamesResponse is what the API server answers when we ask for what games
// an account develops.
type ListProfileGamesResponse struct {
Games []*Game `json:"games"`
}
// ListProfileGames lists the games one develops (ie. can edit)
func (c *Client) ListProfileGames(ctx context.Context) (*ListProfileGamesResponse, error) {
q := NewQuery(c, "/profile/games")
r := &ListProfileGamesResponse{}
return r, q.Get(ctx, r)
}
//-------------------------------------------------------
// ListProfileOwnedKeysParams : params for ListProfileOwnedKeys
type ListProfileOwnedKeysParams struct {
Page int64
}
// ListProfileOwnedKeysResponse : response for ListProfileOwnedKeys
type ListProfileOwnedKeysResponse struct {
Page int64 `json:"page"`
PerPage int64 `json:"perPage"`
OwnedKeys []*DownloadKey `json:"ownedKeys"`
}
// ListProfileOwnedKeys lists the download keys the account with
// the current API key owns.
func (c *Client) ListProfileOwnedKeys(ctx context.Context, p ListProfileOwnedKeysParams) (*ListProfileOwnedKeysResponse, error) {
q := NewQuery(c, "/profile/owned-keys")
q.AddInt64IfNonZero("page", p.Page)
r := &ListProfileOwnedKeysResponse{}
return r, q.Get(ctx, r)
}
//-------------------------------------------------------
// ListProfileCollectionsResponse : response for ListProfileCollections
type ListProfileCollectionsResponse struct {
Collections []*Collection `json:"collections"`
}
// ListProfileCollections lists the collections associated to a profile.
func (c *Client) ListProfileCollections(ctx context.Context) (*ListProfileCollectionsResponse, error) {
q := NewQuery(c, "/profile/collections")
r := &ListProfileCollectionsResponse{}
return r, q.Get(ctx, r)
}