| 1 |
package dnsimple |
| 2 |
|
| 3 |
import () |
| 4 |
|
| 5 |
// UsersService handles communication with the uer related |
| 6 |
// methods of the DNSimple API. |
| 7 |
// |
| 8 |
// DNSimple API docs: http://developer.dnsimple.com/users/ |
| 9 |
type UsersService struct { |
| 10 |
client *Client |
| 11 |
} |
| 12 |
|
| 13 |
// User represents a DNSimple user. |
| 14 |
type User struct { |
| 15 |
Id int `json:"id,omitempty"` |
| 16 |
Email string `json:"email,omitempty"` |
| 17 |
} |
| 18 |
|
| 19 |
type userWrapper struct { |
| 20 |
User User `json:"user"` |
| 21 |
} |
| 22 |
|
| 23 |
// User gets the logged in user. |
| 24 |
// |
| 25 |
// DNSimple API docs: http://developer.dnsimple.com/users/ |
| 26 |
func (s *UsersService) User() (User, *Response, error) { |
| 27 |
wrappedUser := userWrapper{} |
| 28 |
|
| 29 |
res, err := s.client.get("user", &wrappedUser) |
| 30 |
if err != nil { |
| 31 |
return User{}, res, err |
| 32 |
} |
| 33 |
|
| 34 |
return wrappedUser.User, res, nil |
| 35 |
} |