github.com/crosbymichael/octokat@v0.0.0-20160826194511-076a32289ed5/gist.go (about) 1 package octokat 2 3 import ( 4 "fmt" 5 "time" 6 ) 7 8 type File struct { 9 Filename string `json:"filename,omitempty"` 10 RawUrl string `json:"raw_url,omitempty"` 11 Type string `json:"type,omitempty"` 12 Language string `json:"language,omitempty"` 13 Size int64 `json:"size,omitempty"` 14 Content string `json:"content,omitempty"` 15 } 16 17 type Gist struct { 18 Id string `json:"id,omitempty"` 19 Public bool `json:"public,omitempty"` 20 Description string `json:"description,omitempty"` 21 HtmlUrl string `json:"html_url,omitempty"` 22 Url string `json:"url,omitempty"` 23 Files File `json:"files,omitempty"` 24 User User `json:"user,omitempty"` 25 CreatedAt time.Time `json:"created_at,omitempty"` 26 UpdatedAt time.Time `json:"updated_at,omitempty"` 27 } 28 29 func (c *Client) CreateGist(desc string, public bool, files map[string]File) (gist Gist, err error) { 30 path := fmt.Sprintf("gists") 31 m := map[string]interface{}{ 32 "public": public, 33 "files": files, 34 } 35 36 if desc != "" { 37 m["description"] = desc 38 } 39 options := &Options{Params: m} 40 41 err = c.jsonPost(path, options, &gist) 42 return 43 }