-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.go
56 lines (47 loc) · 1.27 KB
/
profile.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
52
53
54
55
56
package smmssdk
import (
"context"
"fmt"
"net/http"
)
type ProfileRequest struct {
}
func (*ProfileRequest) Request(ctx context.Context) (*http.Request, error) {
method := http.MethodPost
url := fmt.Sprintf("%s/profile", baseURL)
req, err := http.NewRequestWithContext(ctx, method, url, nil)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
return req, nil
}
func NewProfileRequest() *ProfileRequest {
return &ProfileRequest{}
}
type ProfileResponse struct {
baseResponse
Data *ProfileData `json:"data"`
}
type ProfileData struct {
Username string `json:"username"`
Email string `json:"email"`
Role string `json:"role"`
GroupExpire string `json:"group_expire"`
EmailVerified int `json:"email_verified"`
DiskUsage string `json:"disk_usage"`
DiskLimit string `json:"disk_limit"`
DiskUsageRaw int64 `json:"disk_usage_raw"`
DiskLimitRaw int64 `json:"disk_limit_raw"`
}
func (c *Client) Profile(ctx context.Context, req *ProfileRequest) (*ProfileResponse, error) {
return c.profile(ctx, req)
}
func (c *Client) profile(ctx context.Context, req *ProfileRequest) (*ProfileResponse, error) {
var rsp ProfileResponse
err := c.Do(ctx, req, &rsp)
if err != nil {
return nil, err
}
return &rsp, nil
}