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)
-
- (Object) create(user, repo_name, data = {})
Returns a GitHubV3API::Issue instance representing the issue that it creates.
-
- (Object) get(user, repo_name, id, params = {})
Returns a GitHubV3API::Issue instance for the specified user, repo_name, and id.
-
- (IssuesAPI) initialize(connection)
constructor
Typically not used directly.
-
- (Object) list(options = nil, params = {})
Returns an array of GitHubV3API::Issue instances representing a user's issues or issues for a repo.
-
- (Object) update(user, repo_name, id, data = {})
Returns a GitHubV3API::Issue instance representing the issue that it updated.
Constructor Details
- (IssuesAPI) initialize(connection)
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
- (Object) create(user, repo_name, data = {})
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 |
- (Object) get(user, repo_name, id, params = {})
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 |
- (Object) list(options = nil, params = {})
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 |
- (Object) update(user, repo_name, id, data = {})
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 |