Debian Codegraph @

putio/account.go

raw symbols SCIP
1 package putio
2
3 import "context"
4
5 // AccountService is the service to gather information about user account.
6 type AccountService struct {
7 client *Client
8 }
9
10 // Info retrieves user account information.
11 func (a *AccountService) Info(ctx context.Context) (AccountInfo, error) {
12 req, err := a.client.NewRequest(ctx, "GET", "/v2/account/info", nil)
13 if err != nil {
14 return AccountInfo{}, nil
15 }
16
17 var r struct {
18 Info AccountInfo
19 }
20 _, err = a.client.Do(req, &r)
21 if err != nil {
22 return AccountInfo{}, err
23 }
24 return r.Info, nil
25 }
26
27 // Settings retrieves user preferences.
28 func (a *AccountService) Settings(ctx context.Context) (Settings, error) {
29 req, err := a.client.NewRequest(ctx, "GET", "/v2/account/settings", nil)
30 if err != nil {
31 return Settings{}, nil
32 }
33 var r struct {
34 Settings Settings
35 }
36 _, err = a.client.Do(req, &r)
37 if err != nil {
38 return Settings{}, err
39 }
40
41 return r.Settings, nil
42 }