File: users.go

package info (click to toggle)
golang-github-weppos-dnsimple-go 0.0~git20160204.0.65c1ca7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 156 kB
  • sloc: makefile: 2
file content (35 lines) | stat: -rw-r--r-- 730 bytes parent folder | download | duplicates (3)
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
package dnsimple

import ()

// UsersService handles communication with the uer related
// methods of the DNSimple API.
//
// DNSimple API docs: http://developer.dnsimple.com/users/
type UsersService struct {
	client *Client
}

// User represents a DNSimple user.
type User struct {
	Id    int    `json:"id,omitempty"`
	Email string `json:"email,omitempty"`
}

type userWrapper struct {
	User User `json:"user"`
}

// User gets the logged in user.
//
// DNSimple API docs: http://developer.dnsimple.com/users/
func (s *UsersService) User() (User, *Response, error) {
	wrappedUser := userWrapper{}

	res, err := s.client.get("user", &wrappedUser)
	if err != nil {
		return User{}, res, err
	}

	return wrappedUser.User, res, nil
}