Class: GitHubV3API::IssuesAPI
- Inherits:
-
Object
- Object
- GitHubV3API::IssuesAPI
- Defined in:
- lib/github_v3_api/issues_api.rb
Overview
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'
Instance Method Summary collapse
-
#create(user, repo_name, data = {}) ⇒ Object
Returns a GitHubV3API::Issue instance representing the issue that it creates.
-
#get(user, repo_name, id, params = {}) ⇒ Object
Returns a GitHubV3API::Issue instance for the specified
user
,repo_name
, andid
. -
#initialize(connection) ⇒ IssuesAPI
constructor
Typically not used directly.
-
#list(options = nil, params = {}) ⇒ Object
Returns an array of GitHubV3API::Issue instances representing a user’s issues or issues for a repo.
-
#update(user, repo_name, id, data = {}) ⇒ Object
Returns a GitHubV3API::Issue instance representing the issue that it updated.
Constructor Details
#initialize(connection) ⇒ IssuesAPI
Typically not used directly. Use GitHubV3API#issues instead.
connection
-
an instance of GitHubV3API
27 28 29 |
# File 'lib/github_v3_api/issues_api.rb', line 27 def initialize(connection) @connection = connection end |
Instance Method Details
#create(user, repo_name, data = {}) ⇒ Object
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. => “omgbbq”
64 65 66 67 68 |
# 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 |
#get(user, repo_name, id, params = {}) ⇒ Object
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
51 52 53 54 55 56 |
# 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 |
#list(options = nil, params = {}) ⇒ Object
Returns an array of GitHubV3API::Issue instances representing a user’s issues or issues for a repo
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/github_v3_api/issues_api.rb', line 33 def list(=nil, params={}) path = if && [:user] && [:repo] "/repos/#{[:user]}/#{[:repo]}/issues" else '/issues' end @connection.get(path, params).map do |issue_data| GitHubV3API::Issue.new(self, issue_data) end end |
#update(user, repo_name, id, data = {}) ⇒ Object
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. => “lol, wtf”
77 78 79 80 |
# 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 |