Skip to content

Commit dd228ff

Browse files
authored
Update Get User to return response as a struct (ktrysmt#195)
And added `AccountID` field to User struct.
1 parent f2f4605 commit dd228ff

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

bitbucket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package bitbucket
22

33
type users interface {
4-
Get(username string) (interface{}, error)
4+
Get(username string) (*User, error)
55
Followers(username string) (interface{}, error)
66
Following(username string) (interface{}, error)
77
Repositories(username string) (interface{}, error)

user.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type User struct {
1212
Username string
1313
Nickname string
1414
Website string
15+
AccountId string `mapstructure:"account_id"`
1516
AccountStatus string `mapstructure:"account_status"`
1617
DisplayName string `mapstructure:"display_name"`
1718
CreatedOn string `mapstructure:"created_on"`

users.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ type Users struct {
44
c *Client
55
}
66

7-
func (u *Users) Get(t string) (interface{}, error) {
8-
7+
func (u *Users) Get(t string) (*User, error) {
98
urlStr := u.c.GetApiBaseURL() + "/users/" + t + "/"
10-
return u.c.execute("GET", urlStr, "")
11-
}
12-
13-
func (c *Client) Get(t string) (interface{}, error) {
14-
15-
urlStr := c.GetApiBaseURL() + "/users/" + t + "/"
16-
return c.execute("GET", urlStr, "")
9+
response, err := u.c.execute("GET", urlStr, "")
10+
if err != nil {
11+
return nil, err
12+
}
13+
return decodeUser(response)
1714
}
1815

1916
func (u *Users) Followers(t string) (interface{}, error) {

0 commit comments

Comments
 (0)