forked from bogosj/tesla
-
Notifications
You must be signed in to change notification settings - Fork 1
/
user.go
36 lines (32 loc) · 899 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
32
33
34
35
36
package tesla
type RegionResponse struct {
Response *Region `json:"response"`
}
type Region struct {
Region string `json:"region"`
FleetApiBaseUrl string `json:"fleet_api_base_url"`
}
// UserRegion fetches the users region
func (c *Client) UserRegion() (*Region, error) {
var regionResponse RegionResponse
if err := c.getJSON(c.baseURL+"/users/region", ®ionResponse); err != nil {
return nil, err
}
return regionResponse.Response, nil
}
type MeResponse struct {
Response *Me `json:"response"`
}
type Me struct {
Email string `json:"email"`
FullName string `json:"full_name"`
ProfileImageUrl string `json:"profile_image_url"`
}
// UserMe fetches the users me
func (c *Client) UserMe() (*Me, error) {
var meResponse MeResponse
if err := c.getJSON(c.baseURL+"/users/me", &meResponse); err != nil {
return nil, err
}
return meResponse.Response, nil
}