Browse Source

add time fields and rename Users.List method

Users.List renamed to Users.ListAll to align with the forthcoming
Repositories.ListAll method.
Will Norris 13 years ago
parent
commit
fccbb9520b
4 changed files with 35 additions and 27 deletions
  1. +7
    -5
      github/orgs.go
  2. +8
    -4
      github/repos.go
  3. +17
    -15
      github/users.go
  4. +3
    -3
      github/users_test.go

+ 7
- 5
github/orgs.go View File

@ -11,6 +11,7 @@ import (
"net/http"
"net/url"
"strconv"
"time"
)
// OrganizationsService provides access to the organization related functions
@ -22,11 +23,12 @@ type OrganizationsService struct {
}
type Organization struct {
Login string `json:"login,omitempty"`
ID int `json:"id,omitempty"`
URL string `json:"url,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
Location string `json:"location,omitempty"`
Login string `json:"login,omitempty"`
ID int `json:"id,omitempty"`
URL string `json:"url,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
Location string `json:"location,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
}
type Team struct {


+ 8
- 4
github/repos.go View File

@ -10,6 +10,7 @@ import (
"fmt"
"net/url"
"strconv"
"time"
)
// RepositoriesService handles communication with the repository related
@ -21,10 +22,13 @@ type RepositoriesService struct {
}
type Repository struct {
ID int `json:"id,omitempty"`
Owner *User `json:"owner,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
ID int `json:"id,omitempty"`
Owner *User `json:"owner,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
PushedAt *time.Time `json:"pushed_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
// RepositoryListOptions specifies the optional parameters to the


+ 17
- 15
github/users.go View File

@ -10,6 +10,7 @@ import (
"fmt"
"net/url"
"strconv"
"time"
)
// UsersService handles communication with the user related
@ -21,20 +22,21 @@ type UsersService struct {
}
type User struct {
Login string `json:"login,omitempty"`
ID int `json:"id,omitempty"`
URL string `json:"url,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
GravatarID string `json:"gravatar_id,omitempty"`
Name string `json:"name,omitempty"`
Company string `json:"company,omitempty"`
Blog string `json:"blog,omitempty"`
Location string `json:"location,omitempty"`
Email string `json:"email,omitempty"`
Hireable bool `json:"hireable,omitempty"`
PublicRepos int `json:"public_repos,omitempty"`
Followers int `json:"followers,omitempty"`
Following int `json:"following,omitempty"`
Login string `json:"login,omitempty"`
ID int `json:"id,omitempty"`
URL string `json:"url,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
GravatarID string `json:"gravatar_id,omitempty"`
Name string `json:"name,omitempty"`
Company string `json:"company,omitempty"`
Blog string `json:"blog,omitempty"`
Location string `json:"location,omitempty"`
Email string `json:"email,omitempty"`
Hireable bool `json:"hireable,omitempty"`
PublicRepos int `json:"public_repos,omitempty"`
Followers int `json:"followers,omitempty"`
Following int `json:"following,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
}
// Get fetches a user. Passing the empty string will fetch the authenticated
@ -77,7 +79,7 @@ type UserListOptions struct {
}
// List all users.
func (s *UsersService) List(opt *UserListOptions) ([]User, error) {
func (s *UsersService) ListAll(opt *UserListOptions) ([]User, error) {
url_ := "users"
if opt != nil {
params := url.Values{


+ 3
- 3
github/users_test.go View File

@ -100,7 +100,7 @@ func TestUsersService_Edit(t *testing.T) {
}
}
func TestUsersService_List(t *testing.T) {
func TestUsersService_ListAll(t *testing.T) {
setup()
defer teardown()
@ -116,13 +116,13 @@ func TestUsersService_List(t *testing.T) {
})
opt := &UserListOptions{1}
users, err := client.Users.List(opt)
users, err := client.Users.ListAll(opt)
if err != nil {
t.Errorf("Users.Get returned error: %v", err)
}
want := []User{User{ID: 2}}
if !reflect.DeepEqual(users, want) {
t.Errorf("Users.List returned %+v, want %+v", users, want)
t.Errorf("Users.ListAll returned %+v, want %+v", users, want)
}
}

Loading…
Cancel
Save