forked from EasyPost/easypost-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_key.go
34 lines (29 loc) · 1 KB
/
api_key.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
package easypost
import (
"context"
"time"
)
// APIKey represents a single API key.
type APIKey struct {
Object string `json:"object,omitempty"`
Mode string `json:"mode,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
Key string `json:"key,omitempty"`
}
// APIKeys contains information about a list of API keys for the given user and
// any child users.
type APIKeys struct {
ID string `json:"id,omitempty"`
Children []*APIKeys `json:"children,omitempty"`
Keys []*APIKey `json:"keys,omitempty"`
}
// GetAPIKeys returns the list of API keys associated with the current user.
func (c *Client) GetAPIKeys() (out *APIKeys, err error) {
return c.GetAPIKeysWithContext(context.Background())
}
// GetAPIKeysWithContext performs the same operation as GetAPIKeys, but allows
// specifying a context that can interrupt the request.
func (c *Client) GetAPIKeysWithContext(ctx context.Context) (out *APIKeys, err error) {
err = c.get(ctx, "api_keys", &out)
return
}