From fccbb9520b3a567b5438ae7a86d0ba6fd6d9a493 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Wed, 29 May 2013 09:33:51 -0700 Subject: [PATCH] add time fields and rename Users.List method Users.List renamed to Users.ListAll to align with the forthcoming Repositories.ListAll method. --- github/orgs.go | 12 +++++++----- github/repos.go | 12 ++++++++---- github/users.go | 32 +++++++++++++++++--------------- github/users_test.go | 6 +++--- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/github/orgs.go b/github/orgs.go index d987a08..7d60afc 100644 --- a/github/orgs.go +++ b/github/orgs.go @@ -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 { diff --git a/github/repos.go b/github/repos.go index 0826b0e..66e79f0 100644 --- a/github/repos.go +++ b/github/repos.go @@ -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 diff --git a/github/users.go b/github/users.go index 14c7f30..519853d 100644 --- a/github/users.go +++ b/github/users.go @@ -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{ diff --git a/github/users_test.go b/github/users_test.go index 087d523..1725129 100644 --- a/github/users_test.go +++ b/github/users_test.go @@ -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) } }