forked from billglover/starling
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
user.go
31 lines (26 loc) · 739 Bytes
/
user.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
package starling
import (
"context"
"net/http"
)
// Identity is the identity of the current user
type Identity struct {
UID string `json:"customerUid"`
ExpiresAt string `json:"expiresAt"`
Authenticated bool `json:"authenticated"`
ExpiresInSeconds int64 `json:"expiresInSeconds"`
Scopes []string `json:"scopes"`
}
// CurrentUser returns the identity of the current user.
func (c *Client) CurrentUser(ctx context.Context) (*Identity, *http.Response, error) {
req, err := c.NewRequest("GET", "/api/v1/me", nil)
if err != nil {
return nil, nil, err
}
var ident *Identity
resp, err := c.Do(ctx, req, &ident)
if err != nil {
return ident, resp, err
}
return ident, resp, nil
}