Class: Geet::Github::Milestone
- Inherits:
-
Object
- Object
- Geet::Github::Milestone
- Extended by:
- Helpers::JsonHelper
- Defined in:
- lib/geet/github/milestone.rb
Constant Summary collapse
- STATE_CLOSED =
'closed'
Instance Attribute Summary collapse
-
#due_on ⇒ Object
readonly
Returns the value of attribute due_on.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
- .close(number, api_interface) ⇒ Object
- .create(title, api_interface) ⇒ Object
- .find(number, api_interface) ⇒ Object
- .list(api_interface) ⇒ Object
Instance Method Summary collapse
-
#initialize(number, title, due_on, api_interface) ⇒ Milestone
constructor
A new instance of Milestone.
Methods included from Helpers::JsonHelper
Constructor Details
#initialize(number, title, due_on, api_interface) ⇒ Milestone
Returns a new instance of Milestone.
18 19 20 21 22 23 24 |
# File 'lib/geet/github/milestone.rb', line 18 def initialize(number, title, due_on, api_interface) @number = number @title = title @due_on = due_on @api_interface = api_interface end |
Instance Attribute Details
#due_on ⇒ Object (readonly)
Returns the value of attribute due_on.
8 9 10 |
# File 'lib/geet/github/milestone.rb', line 8 def due_on @due_on end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
8 9 10 |
# File 'lib/geet/github/milestone.rb', line 8 def number @number end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
8 9 10 |
# File 'lib/geet/github/milestone.rb', line 8 def title @title end |
Class Method Details
.close(number, api_interface) ⇒ Object
See docs.github.com/en/free-pro-team@latest/rest/reference/issues#update-a-milestone
This is a convenience method; the underlying operation is a generic update.
74 75 76 77 78 79 |
# File 'lib/geet/github/milestone.rb', line 74 def self.close(number, api_interface, **) api_path = "milestones/#{number}" request_data = { state: STATE_CLOSED } api_interface.send_request(api_path, data: request_data) end |
.create(title, api_interface) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/geet/github/milestone.rb', line 27 def self.create(title, api_interface, **) api_path = 'milestones' request_data = { title: title } response = api_interface.send_request(api_path, data: request_data) number = response.fetch('number') title = response.fetch('title') due_on = nil new(number, title, due_on, api_interface) end |
.find(number, api_interface) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/geet/github/milestone.rb', line 42 def self.find(number, api_interface, **) api_path = "milestones/#{number}" response = api_interface.send_request(api_path) number = response.fetch('number') title = response.fetch('title') due_on = (raw_due_on) new(number, title, due_on, api_interface) end |
.list(api_interface) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/geet/github/milestone.rb', line 56 def self.list(api_interface, **) api_path = 'milestones' response = api_interface.send_request(api_path, multipage: true) response.map do |milestone_data| number = milestone_data.fetch('number') title = milestone_data.fetch('title') due_on = (milestone_data.fetch('due_on')) new(number, title, due_on, api_interface) end end |