From c9849d667ab55c23d343332a11afb3eb8ede3f2d Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Sun, 17 Jul 2016 17:16:14 +0100 Subject: Update vendor libs --- vendor/github.com/google/go-github/github/users.go | 68 ++++++++++++++++++++-- 1 file changed, 63 insertions(+), 5 deletions(-) (limited to 'vendor/github.com/google/go-github/github/users.go') diff --git a/vendor/github.com/google/go-github/github/users.go b/vendor/github.com/google/go-github/github/users.go index 0312724..8f63746 100644 --- a/vendor/github.com/google/go-github/github/users.go +++ b/vendor/github.com/google/go-github/github/users.go @@ -11,9 +11,7 @@ import "fmt" // methods of the GitHub API. // // GitHub API docs: http://developer.github.com/v3/users/ -type UsersService struct { - client *Client -} +type UsersService service // User represents a GitHub user. type User struct { @@ -138,12 +136,16 @@ func (s *UsersService) Edit(user *User) (*User, *Response, error) { type UserListOptions struct { // ID of the last user seen Since int `url:"since,omitempty"` + + ListOptions } // ListAll lists all GitHub users. // +// To paginate through all users, populate 'Since' with the ID of the last user. +// // GitHub API docs: http://developer.github.com/v3/users/#get-all-users -func (s *UsersService) ListAll(opt *UserListOptions) ([]User, *Response, error) { +func (s *UsersService) ListAll(opt *UserListOptions) ([]*User, *Response, error) { u, err := addOptions("users", opt) if err != nil { return nil, nil, err @@ -154,7 +156,7 @@ func (s *UsersService) ListAll(opt *UserListOptions) ([]User, *Response, error) return nil, nil, err } - users := new([]User) + users := new([]*User) resp, err := s.client.Do(req, users) if err != nil { return nil, resp, err @@ -162,3 +164,59 @@ func (s *UsersService) ListAll(opt *UserListOptions) ([]User, *Response, error) return *users, resp, err } + +// ListInvitations lists all currently-open repository invitations for the +// authenticated user. +// +// GitHub API docs: https://developer.github.com/v3/repos/invitations/#list-a-users-repository-invitations +func (s *UsersService) ListInvitations() ([]*RepositoryInvitation, *Response, error) { + req, err := s.client.NewRequest("GET", "user/repository_invitations", nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview) + + invites := []*RepositoryInvitation{} + resp, err := s.client.Do(req, &invites) + if err != nil { + return nil, resp, err + } + + return invites, resp, err +} + +// AcceptInvitation accepts the currently-open repository invitation for the +// authenticated user. +// +// GitHub API docs: https://developer.github.com/v3/repos/invitations/#accept-a-repository-invitation +func (s *UsersService) AcceptInvitation(invitationID int) (*Response, error) { + u := fmt.Sprintf("user/repository_invitations/%v", invitationID) + req, err := s.client.NewRequest("PATCH", u, nil) + if err != nil { + return nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview) + + return s.client.Do(req, nil) +} + +// DeclineInvitation declines the currently-open repository invitation for the +// authenticated user. +// +// GitHub API docs: https://developer.github.com/v3/repos/invitations/#decline-a-repository-invitation +func (s *UsersService) DeclineInvitation(invitationID int) (*Response, error) { + u := fmt.Sprintf("user/repository_invitations/%v", invitationID) + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview) + + return s.client.Do(req, nil) +} -- cgit v1.2.3