github.com/crosbymichael/octokat@v0.0.0-20160826194511-076a32289ed5/issues.go (about)

     1  package octokat
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  )
     7  
     8  type Issue struct {
     9  	URL       string   `json:"url,omitempty,omitempty"`
    10  	HTMLURL   string   `json:"html_url,omitempty,omitempty"`
    11  	Number    int      `json:"number,omitempty"`
    12  	State     string   `json:"state,omitempty"`
    13  	Title     string   `json:"title,omitempty"`
    14  	Body      string   `json:"body,omitempty"`
    15  	User      User     `json:"user,omitempty"`
    16  	Labels    []*Label `json:"labels,omitempty"`
    17  	Assignee  User     `json:"assignee,omitempty"`
    18  	Milestone struct {
    19  		URL          string     `json:"url,omitempty"`
    20  		Number       int        `json:"number,omitempty"`
    21  		State        string     `json:"state,omitempty"`
    22  		Title        string     `json:"title,omitempty"`
    23  		Description  string     `json:"description,omitempty"`
    24  		Creator      User       `json:"creator,omitempty"`
    25  		OpenIssues   int        `json:"open_issues,omitempty"`
    26  		ClosedIssues int        `json:"closed_issues,omitempty"`
    27  		CreatedAt    time.Time  `json:"created_at,omitempty"`
    28  		DueOn        *time.Time `json:"due_on,omitempty"`
    29  	}
    30  	Comments    int `json:"comments,omitempty"`
    31  	PullRequest struct {
    32  		HTMLURL  string `json:"html_url,omitempty"`
    33  		DiffURL  string `json:"diff_url,omitempty"`
    34  		PatchURL string `json:"patch_url,omitempty"`
    35  	} `json:"pull_request,omitempty"`
    36  	CreatedAt time.Time  `json:"created_at,omitempty"`
    37  	ClosedAt  *time.Time `json:"closed_at,omitempty"`
    38  	UpdatedAt time.Time  `json:"updated_at,omitempty"`
    39  }
    40  
    41  // List issues
    42  //
    43  // See http://developer.github.com/v3/issues/#list-issues-for-a-repository
    44  func (c *Client) Issues(repo Repo, options *Options) (issues []*Issue, err error) {
    45  	path := fmt.Sprintf("repos/%s/issues", repo)
    46  	err = c.jsonGet(path, options, &issues)
    47  	return
    48  }
    49  
    50  // Fetch a single issue
    51  //
    52  // See http://developer.github.com/v3/issues/#get-a-single-issue
    53  func (c *Client) Issue(repo Repo, number int, options *Options) (issue *Issue, err error) {
    54  	path := fmt.Sprintf("repos/%s/issues/%d", repo, number)
    55  	err = c.jsonGet(path, options, &issue)
    56  	return
    57  }
    58  
    59  // Edit an issue
    60  //
    61  // See http://developer.github.com/v3/issues/#edit-an-issue
    62  func (c *Client) PatchIssue(repo Repo, number string, options *Options) (patchedIssue *Issue, err error) {
    63  	path := fmt.Sprintf("repos/%s/issues/%s", repo, number)
    64  	err = c.jsonPatch(path, options, &patchedIssue)
    65  	return
    66  }