-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathme.go
47 lines (42 loc) · 1.16 KB
/
me.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
package control
// The Me struct contains information about the token the current user authenticates with.
type Me struct {
// The access token used to authenticate.
Token Token `json:"token"`
// The user accociated with the used token.
User User `json:"user"`
// The account accociated with the used token.
Account Account `json:"account"`
}
// An access token used to authenticate with the Control API.
type Token struct {
// The ID of the token.
ID string `json:"id"`
// The name of the token.
Name string `json:"name"`
// The capabilities of the token.
Capabilities []string `json:"capabilities"`
}
// User associated with the used token and account.
type User struct {
// The ID of the user.
ID int `json:"id"`
// The user's email address.
Email string `json:"email"`
}
// The account detials of an Ably account.
type Account struct {
// The ID of the account.
ID string `json:"id"`
// The name of the account.
Name string `json:"name"`
}
// Me fetches information about the token the current user authenticates with.
func (c *Client) Me() (Me, error) {
var me Me
err := c.request("GET", "/me", nil, &me)
if err != nil {
return me, err
}
return me, nil
}