-
Notifications
You must be signed in to change notification settings - Fork 27
/
user.go
53 lines (47 loc) · 1.64 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package civogo
import (
"bytes"
"encoding/json"
"time"
)
// User is the user struct
type User struct {
ID string `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CompanyName string `json:"company_name"`
EmailAddress string `json:"email_address"`
Status string `json:"status"`
Flags string `json:"flags"`
Token string `json:"token"`
MarketingAllowed int `json:"marketing_allowed"`
DefaultAccountID string `json:"default_account_id"`
// DefaultAccountID string `json:"account_id"`
PasswordDigest string `json:"password_digest"`
Partner string `json:"partner"`
PartnerUserID string `json:"partner_user_id"`
ReferralID string `json:"referral_id"`
LastChosenRegion string `json:"last_chosen_region"`
}
// UserEverything is the combination structure for all team related data for the current user and account
type UserEverything struct {
User User
Accounts []Account
Organisations []Organisation
Teams []Team
Roles []Role
}
// GetUserEverything returns the organisation associated with the current account
func (c *Client) GetUserEverything(userID string) (*UserEverything, error) {
resp, err := c.SendGetRequest("/v2/users/" + userID + "/everything")
if err != nil {
return nil, decodeError(err)
}
everything := &UserEverything{}
if err := json.NewDecoder(bytes.NewReader(resp)).Decode(everything); err != nil {
return nil, err
}
return everything, nil
}