Class: Geet::GitHub::Issue
- Inherits:
-
AbstractIssue
- Object
- AbstractIssue
- Geet::GitHub::Issue
- Defined in:
- lib/geet/git_hub/issue.rb
Instance Attribute Summary
Attributes inherited from AbstractIssue
Class Method Summary collapse
- .create(repository, title, description, api_helper) ⇒ Object
-
.list(repository, api_helper) ⇒ Object
Returns an array of Struct(:number, :title); once this workflow is extended, the struct will likely be converted to a standard class.
Instance Method Summary collapse
Methods inherited from AbstractIssue
#add_labels, #assign_user, #initialize
Constructor Details
This class inherits a constructor from Geet::GitHub::AbstractIssue
Class Method Details
.create(repository, title, description, api_helper) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/geet/git_hub/issue.rb', line 8 def self.create(repository, title, description, api_helper) request_address = "#{api_helper.repo_link}/issues" request_data = { title: title, body: description, base: 'master' } response = api_helper.send_request(request_address, data: request_data) issue_number = response.fetch('number') new(repository, issue_number, api_helper) end |
.list(repository, api_helper) ⇒ Object
Returns an array of Struct(:number, :title); once this workflow is extended, the struct will likely be converted to a standard class.
See developer.github.com/v3/issues/#list-issues-for-a-repository
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/geet/git_hub/issue.rb', line 24 def self.list(repository, api_helper) request_address = "#{api_helper.repo_link}/issues" response = api_helper.send_request(request_address, multipage: true) issue_class = Struct.new(:number, :title, :link) response.each_with_object([]) do |issue_data, result| if ! issue_data.key?('pull_request') number = issue_data.fetch('number') title = issue_data.fetch('title') link = issue_data.fetch('html_url') result << issue_class.new(number, title, link) end end end |
Instance Method Details
#link ⇒ Object
41 42 43 |
# File 'lib/geet/git_hub/issue.rb', line 41 def link "https://github.com/#{@repository.owner}/#{@repository.repo}/issues/#{@issue_number}" end |