Module: GitHub::Client::Issues

Included in:
GitHub::Client
Defined in:
lib/github_api_v3/client/issues.rb

Overview

Methods for the Issues API.

@ see developer.github.com/v3/issues/

Instance Method Summary collapse

Instance Method Details

#create_issue(owner, repo, title, options = {}) ⇒ Hash

Create an issue.

Requires authentication.

Examples:

client.create_issue('caseyscarborough', 'github', 'Found a bug', :assignee => 'caseyscarborough', :labels => ['label1', 'label2', 'label3'])

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

  • title (String)

    The issue title.

  • options (Hash) (defaults to: {})

    Parameters.

Options Hash (options):

  • :body (String)
  • :assignee (String)

    Login for user to assign the issue to (must have push access).

  • :milestone (Integer)

    The milestone to associate the issue with (must have push access).

  • :labels (Array)

    Array of strings of labels to associate with this issue.

Returns:

See Also:



123
124
125
126
# File 'lib/github_api_v3/client/issues.rb', line 123

def create_issue(owner, repo, title, options={})
  options.merge!(title: title)
  post "/repos/#{owner}/#{repo}/issues", body: options
end

#create_issue_comment(owner, repo, number, comment) ⇒ Hash

Create a new issue comment.

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

  • number (Integer)

    The issue number.

  • comment (String)

    The comment text.

Returns:

  • (Hash)

    The comment information.

See Also:



190
191
192
# File 'lib/github_api_v3/client/issues.rb', line 190

def create_issue_comment(owner, repo, number, comment)
  post "/repos/#{owner}/#{repo}/issues/#{number}/comments", body: { body: comment }
end

#delete_issue_comment(owner, repo, id) ⇒ Boolean

Delete a comment.

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

  • id (Integer)

    The comment ID.

Returns:

  • (Boolean)

    True if successful, false if not.

See Also:



213
214
215
# File 'lib/github_api_v3/client/issues.rb', line 213

def delete_issue_comment(owner, repo, id)
  boolean_request :delete, "/repos/#{owner}/#{repo}/issues/comments/#{id}"
end

#edit_issue(owner, repo, number, options = {}) ⇒ Hash

Edit an issue.

Requires authentication.

Examples:

client.edit_issue('caseyscarborough', 'github', 3, body: 'This is the body.', state: 'closed')

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

  • number (Integer)

    The issue number.

  • options (Hash) (defaults to: {})

    Parameters.

Options Hash (options):

  • :title (String)
  • :body (String)
  • :assignee (String)

    Login for user to assign the issue to (must have push access).

  • :state (String)

    open or closed

  • :milestone (Integer)

    The milestone to associate the issue with (must have push access).

  • :labels (Array)

    Array of strings of labels to associate with this issue.

Returns:

  • (Hash)

    Issue information.

See Also:



146
147
148
# File 'lib/github_api_v3/client/issues.rb', line 146

def edit_issue(owner, repo, number, options={})
  patch "/repos/#{owner}/#{repo}/issues/#{number}", body: options
end

#edit_issue_comment(owner, repo, id, comment) ⇒ Hash

Edit an issue comment.

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

  • id (Integer)

    The comment ID.

  • comment (String)

    The comment text.

Returns:

  • (Hash)

    The comment information.

See Also:



202
203
204
# File 'lib/github_api_v3/client/issues.rb', line 202

def edit_issue_comment(owner, repo, id, comment)
  patch "/repos/#{owner}/#{repo}/issues/comments/#{id}", body: { body: comment }
end

#issue(owner, repo, number) ⇒ Hash

Get a single issue.

Examples:

client.issue('caseyscarborough', 'github', 123)

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

  • number (Integer)

    The issue number.

Returns:

See Also:



103
104
105
# File 'lib/github_api_v3/client/issues.rb', line 103

def issue(owner, repo, number)
  get "/repos/#{owner}/#{repo}/issues/#{number}"
end

#issue_comment(owner, repo, id) ⇒ Hash

Get a single issue comment.

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

  • id (Integer)

    The comment ID.

Returns:

  • (Hash)

    The comment information.

See Also:



178
179
180
# File 'lib/github_api_v3/client/issues.rb', line 178

def issue_comment(owner, repo, id)
  get "/repos/#{owner}/#{repo}/issues/comments/#{id}"
end

#issue_comments(owner, repo, number) ⇒ Array

List comments on an issue.

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

  • number (Integer)

    The issue number.

Returns:

  • (Array)

    A list of issue comments.

See Also:



157
158
159
# File 'lib/github_api_v3/client/issues.rb', line 157

def issue_comments(owner, repo, number)
  get "/repos/#{owner}/#{repo}/issues/#{number}/comments"
end

#issue_event(owner, repo, id) ⇒ Object

Get a single issue event.

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

  • id (Integer)

    The event ID.

See Also:



234
235
236
# File 'lib/github_api_v3/client/issues.rb', line 234

def issue_event(owner, repo, id)
  get "/repos/#{owner}/#{repo}/issues/events/#{id}"
end

#issue_events(owner, repo, number) ⇒ Array

List events for an issue.

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

  • number (Integer)

    The issue number.

Returns:

  • (Array)

    List of events.

See Also:



224
225
226
# File 'lib/github_api_v3/client/issues.rb', line 224

def issue_events(owner, repo, number)
  get "/repos/#{owner}/#{repo}/issues/#{number}/events"
end

#issues(options = {}) ⇒ Array

List all issues for an authenticated user, including owned, member, and org repos.

Requires authentication.

Examples:

client.issues(:filter => 'created', :state => 'closed', :sort => 'updated')

Parameters:

  • options (Hash) (defaults to: {})

    Optional parameters.

Options Hash (options):

  • :filter (String)

    assigned (default), created, mentioned, subscribed, all

  • :state (String)

    open (default), closed

  • :labels (String)

    String list of comma separated label names, ex. “bug,ui,@high”

  • :sort (String)

    created (default), updated, comments

  • :directions (String)

    asc (default), desc

  • :since (String)

    Optional string of a timestamp in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)

Returns:

  • (Array)

    List of all issues.

See Also:



24
25
26
# File 'lib/github_api_v3/client/issues.rb', line 24

def issues(options={})
  get '/issues', params: options
end

#issues_comments(owner, repo) ⇒ Array

List all issues comments for a repository.

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

Returns:

  • (Array)

    A list of issue comments.

See Also:



167
168
169
# File 'lib/github_api_v3/client/issues.rb', line 167

def issues_comments(owner, repo)
  get "/repos/#{owner}/#{repo}/issues/comments"
end

#org_issues(org, options = {}) ⇒ Array

List all issues for a given organization for the authenticated user.

Requires authentication.

Examples:

client.org_issues('facebook', :filter => 'mentioned', :state => 'closed')

Parameters:

  • org (String)

    The organization name.

  • options (Hash) (defaults to: {})

    Optional parameters.

Options Hash (options):

  • :filter (String)

    assigned (default), created, mentioned, subscribed, all

  • :state (String)

    open (default), closed

  • :labels (String)

    String list of comma separated label names, ex. “bug,ui,@high”

  • :sort (String)

    created (default), updated, comments

  • :directions (String)

    asc (default), desc

  • :since (String)

    Optional string of a timestamp in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)

Returns:

  • (Array)

    List of all issues.

See Also:



63
64
65
# File 'lib/github_api_v3/client/issues.rb', line 63

def org_issues(org, options={})
  get "/orgs/#{org}/issues", params: options
end

#repo_issues(owner, repo, options = {}) ⇒ Array

List issues for a repository.

Examples:

Closed repo issues since 2013-08-10 created by @caseyscarborough for the caseyscarborough/github repository.

client.repo_issues(
  'caseyscarborough',
  'github', 
  :state => 'closed'
  :since => '2013-08-09T19:00:00-05:00'
)

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

  • options (Hash) (defaults to: {})

    Optional parameters.

Options Hash (options):

  • :milestone (Integer, String)

    Milestone number (Integer), ‘none’, or ‘*’ for issues with any milestone.

  • :state (String)

    open (default), closed

  • :assignee (String)

    User login, ‘none’, or ‘*’ for issues with any milestone.

  • :creator (String)

    User login

  • :mentioned (String)

    User login

  • :labels (String)

    String list of comma separated label names, ex. “bug,ui,@high”

  • :sort (String)

    created (default), updated, comments

  • :directions (String)

    asc (default), desc

  • :since (String)

    Optional string of a timestamp in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)

Returns:

  • (Array)

    List of issues.

See Also:



90
91
92
# File 'lib/github_api_v3/client/issues.rb', line 90

def repo_issues(owner, repo, options={})
  get "/repos/#{owner}/#{repo}/issues"
end

#user_issues(options = {}) ⇒ Array

List all issues across owned and member repositories for the authenticated user.

Requires authentication.

Examples:

client.user_issues(:filter => 'created')

Parameters:

  • options (Hash) (defaults to: {})

    Optional parameters.

Options Hash (options):

  • :filter (String)

    assigned (default), created, mentioned, subscribed, all

  • :state (String)

    open (default), closed

  • :labels (String)

    String list of comma separated label names, ex. “bug,ui,@high”

  • :sort (String)

    created (default), updated, comments

  • :directions (String)

    asc (default), desc

  • :since (String)

    Optional string of a timestamp in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)

Returns:

  • (Array)

    List of all issues.

See Also:



43
44
45
# File 'lib/github_api_v3/client/issues.rb', line 43

def user_issues(options={})
  get '/user/issues', params: options
end