-
Notifications
You must be signed in to change notification settings - Fork 4
/
account.go
47 lines (38 loc) · 1.16 KB
/
account.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 mite
import "time"
// -------------------------------------------------------------
// ~ Types
// -------------------------------------------------------------
// Account is a type for mite the account
type Account struct {
ID string `json:"id"`
Name string `json:"name"`
Title string `json:"title"`
Currency string `json:"currency"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type accountResponseWrapper struct {
Account *Account `json:"account"`
}
// -------------------------------------------------------------
// ~ Functions
// -------------------------------------------------------------
// GetAccount returns the current mite account
func (m *Mite) GetAccount() (*Account, error) {
var resp *accountResponseWrapper
err := m.getAndDecodeFromSuffix("account.json", &resp, nil)
if err != nil {
return nil, err
}
return resp.Account, nil
}
// GetMyself returns the current user
func (m *Mite) GetMyself() (*User, error) {
var resp *getUsersResponseWrapper
err := m.getAndDecodeFromSuffix("myself.json", &resp, nil)
if err != nil {
return nil, err
}
return resp.User, nil
}