class GitHubV3API::IssuesAPI
Provides access to the GitHub Issues API (developer.github.com/v3/issues/)
example:
api = GitHubV3API.new(ACCESS_TOKEN) # get list of your issues my_issues = api.issues.list #=> returns an array of GitHubV3API::Issue instances # get list of issues for a repo repo_issues = api.issues.list({:user => 'octocat', :repo => 'hello-world'}) #=> returns an array of GitHubV3API::Issue instances issue = api.issues.get('octocat', 'hello-world', '1234') #=> returns an instance of GitHubV3API::Issue issue.title #=> 'omgbbq'
Public Class Methods
Typically not used directly. Use GitHubV3API#issues
instead.
connection
-
an instance of
GitHubV3API
# File lib/github_v3_api/issues_api.rb, line 27 def initialize(connection) @connection = connection end
Public Instance Methods
Returns a GitHubV3API::Issue
instance representing the issue that it creates
user
-
the string ID of the user, e.g. “octocat”
repo_name
-
the string ID of the repository, e.g. “hello-world”
data
-
the hash DATA with attributes for the issue, e.g. {:title => “omgbbq”}
# File lib/github_v3_api/issues_api.rb, line 64 def create(user, repo_name, data={}) raise MissingRequiredData, "Title is required to create a new issue" unless data[:title] issue_data = @connection.post("/repos/#{user}/#{repo_name}/issues", data) GitHubV3API::Issue.new_with_all_data(self, issue_data) end
Returns a GitHubV3API::Issue
instance for the specified user
, repo_name
, and id
.
user
-
the string ID of the user, e.g. “octocat”
repo_name
-
the string ID of the repository, e.g. “hello-world”
id
-
the integer ID of the issue, e.g. 42
# File lib/github_v3_api/issues_api.rb, line 51 def get(user, repo_name, id, params={}) issue_data = @connection.get("/repos/#{user}/#{repo_name}/issues/#{id.to_s}", params) GitHubV3API::Issue.new_with_all_data(self, issue_data) rescue RestClient::ResourceNotFound raise NotFound, "The issue #{user}/#{repo_name}/issues/#{id} does not exist or is not visible to the user." end
Returns an array of GitHubV3API::Issue
instances representing a user’s issues or issues for a repo
# File lib/github_v3_api/issues_api.rb, line 33 def list(options=nil, params={}) path = if options && options[:user] && options[:repo] "/repos/#{options[:user]}/#{options[:repo]}/issues" else '/issues' end @connection.get(path, params).map do |issue_data| GitHubV3API::Issue.new(self, issue_data) end end
Returns a GitHubV3API::Issue
instance representing the issue that it updated
user
-
the string ID of the user, e.g. “octocat”
repo_name
-
the string ID of the repository, e.g. “hello-world”
id
-
the integer ID of the issue, e.g. 42
data
-
the hash with attributes for the issue, e.g. {:body => “lol, wtf”}
# File lib/github_v3_api/issues_api.rb, line 77 def update(user, repo_name, id, data={}) issue_data = @connection.patch("/repos/#{user}/#{repo_name}/issues/#{id.to_s}", data) GitHubV3API::Issue.new_with_all_data(self, issue_data) end