Skip to content

Commit 4f64926

Browse files
committed
current user
1 parent db94b58 commit 4f64926

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

account.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package webhookrelay
2+
3+
import (
4+
"encoding/json"
5+
"net/http"
6+
)
7+
8+
type UserInfo struct {
9+
Status string `json:"status"`
10+
Data struct {
11+
ID string `json:"id"`
12+
Username string `json:"username"`
13+
Email string `json:"email"`
14+
AuthType string `json:"auth_type"`
15+
PlanID string `json:"plan_id"`
16+
Role string `json:"role"`
17+
} `json:"data"`
18+
}
19+
20+
// UserInfo returns current user details
21+
func (api *API) UserInfo() (*UserInfo, error) {
22+
23+
resp, err := api.makeRequest(http.MethodGet, "/user/info", nil)
24+
if err != nil {
25+
return nil, err
26+
}
27+
28+
var userInfo UserInfo
29+
if err := json.Unmarshal(resp, &userInfo); err != nil {
30+
return nil, err
31+
}
32+
return &userInfo, nil
33+
}

0 commit comments

Comments
 (0)