aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/google/go-github/github/gists.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/google/go-github/github/gists.go')
-rw-r--r--vendor/github.com/google/go-github/github/gists.go80
1 files changed, 71 insertions, 9 deletions
diff --git a/vendor/github.com/google/go-github/github/gists.go b/vendor/github.com/google/go-github/github/gists.go
index a662d35..697fcb5 100644
--- a/vendor/github.com/google/go-github/github/gists.go
+++ b/vendor/github.com/google/go-github/github/gists.go
@@ -14,9 +14,7 @@ import (
// methods of the GitHub API.
//
// GitHub API docs: http://developer.github.com/v3/gists/
-type GistsService struct {
- client *Client
-}
+type GistsService service
// Gist represents a GitHub's gist.
type Gist struct {
@@ -52,6 +50,32 @@ func (g GistFile) String() string {
return Stringify(g)
}
+// GistCommit represents a commit on a gist.
+type GistCommit struct {
+ URL *string `json:"url,omitempty"`
+ Version *string `json:"version,omitempty"`
+ User *User `json:"user,omitempty"`
+ ChangeStatus *CommitStats `json:"change_status,omitempty"`
+ CommitedAt *Timestamp `json:"commited_at,omitempty"`
+}
+
+func (gc GistCommit) String() string {
+ return Stringify(gc)
+}
+
+// GistFork represents a fork of a gist.
+type GistFork struct {
+ URL *string `json:"url,omitempty"`
+ User *User `json:"user,omitempty"`
+ ID *string `json:"id,omitempty"`
+ CreatedAt *Timestamp `json:"created_at,omitempty"`
+ UpdatedAt *Timestamp `json:"updated_at,omitempty"`
+}
+
+func (gf GistFork) String() string {
+ return Stringify(gf)
+}
+
// GistListOptions specifies the optional parameters to the
// GistsService.List, GistsService.ListAll, and GistsService.ListStarred methods.
type GistListOptions struct {
@@ -67,7 +91,7 @@ type GistListOptions struct {
// user.
//
// GitHub API docs: http://developer.github.com/v3/gists/#list-gists
-func (s *GistsService) List(user string, opt *GistListOptions) ([]Gist, *Response, error) {
+func (s *GistsService) List(user string, opt *GistListOptions) ([]*Gist, *Response, error) {
var u string
if user != "" {
u = fmt.Sprintf("users/%v/gists", user)
@@ -84,7 +108,7 @@ func (s *GistsService) List(user string, opt *GistListOptions) ([]Gist, *Respons
return nil, nil, err
}
- gists := new([]Gist)
+ gists := new([]*Gist)
resp, err := s.client.Do(req, gists)
if err != nil {
return nil, resp, err
@@ -96,7 +120,7 @@ func (s *GistsService) List(user string, opt *GistListOptions) ([]Gist, *Respons
// ListAll lists all public gists.
//
// GitHub API docs: http://developer.github.com/v3/gists/#list-gists
-func (s *GistsService) ListAll(opt *GistListOptions) ([]Gist, *Response, error) {
+func (s *GistsService) ListAll(opt *GistListOptions) ([]*Gist, *Response, error) {
u, err := addOptions("gists/public", opt)
if err != nil {
return nil, nil, err
@@ -107,7 +131,7 @@ func (s *GistsService) ListAll(opt *GistListOptions) ([]Gist, *Response, error)
return nil, nil, err
}
- gists := new([]Gist)
+ gists := new([]*Gist)
resp, err := s.client.Do(req, gists)
if err != nil {
return nil, resp, err
@@ -119,7 +143,7 @@ func (s *GistsService) ListAll(opt *GistListOptions) ([]Gist, *Response, error)
// ListStarred lists starred gists of authenticated user.
//
// GitHub API docs: http://developer.github.com/v3/gists/#list-gists
-func (s *GistsService) ListStarred(opt *GistListOptions) ([]Gist, *Response, error) {
+func (s *GistsService) ListStarred(opt *GistListOptions) ([]*Gist, *Response, error) {
u, err := addOptions("gists/starred", opt)
if err != nil {
return nil, nil, err
@@ -130,7 +154,7 @@ func (s *GistsService) ListStarred(opt *GistListOptions) ([]Gist, *Response, err
return nil, nil, err
}
- gists := new([]Gist)
+ gists := new([]*Gist)
resp, err := s.client.Do(req, gists)
if err != nil {
return nil, resp, err
@@ -211,6 +235,25 @@ func (s *GistsService) Edit(id string, gist *Gist) (*Gist, *Response, error) {
return g, resp, err
}
+// ListCommits lists commits of a gist.
+//
+// Github API docs: https://developer.github.com/v3/gists/#list-gist-commits
+func (s *GistsService) ListCommits(id string) ([]*GistCommit, *Response, error) {
+ u := fmt.Sprintf("gists/%v/commits", id)
+ req, err := s.client.NewRequest("GET", u, nil)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ gistCommits := new([]*GistCommit)
+ resp, err := s.client.Do(req, gistCommits)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return *gistCommits, resp, err
+}
+
// Delete a gist.
//
// GitHub API docs: http://developer.github.com/v3/gists/#delete-a-gist
@@ -279,3 +322,22 @@ func (s *GistsService) Fork(id string) (*Gist, *Response, error) {
return g, resp, err
}
+
+// ListForks lists forks of a gist.
+//
+// Github API docs: https://developer.github.com/v3/gists/#list-gist-forks
+func (s *GistsService) ListForks(id string) ([]*GistFork, *Response, error) {
+ u := fmt.Sprintf("gists/%v/forks", id)
+ req, err := s.client.NewRequest("GET", u, nil)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ gistForks := new([]*GistFork)
+ resp, err := s.client.Do(req, gistForks)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return *gistForks, resp, err
+}