-
Notifications
You must be signed in to change notification settings - Fork 18
/
core_settings.go
49 lines (38 loc) · 1.16 KB
/
core_settings.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
package proton
import (
"context"
"github.com/go-resty/resty/v2"
)
func (c *Client) GetUserSettings(ctx context.Context) (UserSettings, error) {
var res struct {
UserSettings UserSettings
}
if err := c.do(ctx, func(r *resty.Request) (*resty.Response, error) {
return r.SetResult(&res).Get("/core/v4/settings")
}); err != nil {
return UserSettings{}, err
}
return res.UserSettings, nil
}
func (c *Client) SetUserSettingsTelemetry(ctx context.Context, req SetTelemetryReq) (UserSettings, error) {
var res struct {
UserSettings UserSettings
}
if err := c.do(ctx, func(r *resty.Request) (*resty.Response, error) {
return r.SetBody(req).SetResult(&res).Put("/core/v4/settings/telemetry")
}); err != nil {
return UserSettings{}, err
}
return res.UserSettings, nil
}
func (c *Client) SetUserSettingsCrashReports(ctx context.Context, req SetCrashReportReq) (UserSettings, error) {
var res struct {
UserSettings UserSettings
}
if err := c.do(ctx, func(r *resty.Request) (*resty.Response, error) {
return r.SetBody(req).SetResult(&res).Put("/core/v4/settings/crashreports")
}); err != nil {
return UserSettings{}, err
}
return res.UserSettings, nil
}