Class: Spage::Api::Incident
- Inherits:
-
Object
- Object
- Spage::Api::Incident
- Includes:
- Spage::Api
- Defined in:
- lib/spage/api/incident.rb
Overview
Incident resources in the statuspage.io API
Instance Method Summary collapse
- #active_maintenance(page_id:) ⇒ Object
- #all(page_id:, per_page: 100, page: 1) ⇒ Object
- #create(incident, page_id:) ⇒ Object
- #delete(page_id:, id:) ⇒ Object
- #find(page_id:, id:) ⇒ Object
- #scheduled(page_id:) ⇒ Object
- #unresolved(page_id:) ⇒ Object
- #update(incident, page_id:, id:) ⇒ Object
Methods included from Spage::Api
Instance Method Details
#active_maintenance(page_id:) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/spage/api/incident.rb', line 42 def active_maintenance(page_id:) response = client.get("pages/#{page_id}/incidents/active_maintenance") handle_response(response) do response.body.map do |incident| Spage::Incident.new(incident) end end end |
#all(page_id:, per_page: 100, page: 1) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/spage/api/incident.rb', line 12 def all(page_id:, per_page: 100, page: 1) response = client.get("pages/#{page_id}/incidents", query: "per_page=#{per_page}&page=#{page}") handle_response(response) do response.body.map do |incident| Spage::Incident.new(incident) end end end |
#create(incident, page_id:) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/spage/api/incident.rb', line 60 def create(incident, page_id:) json = Spage::Serializers::Incident.new(incident, update: true).to_json response = client.post("pages/#{page_id}/incidents", json) handle_response(response) do Spage::Incident.new(response.body) end end |
#delete(page_id:, id:) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/spage/api/incident.rb', line 81 def delete(page_id:, id:) response = client.delete("pages/#{page_id}/incidents", id) handle_response(response) do Spage::Incident.new(response.body) end end |
#find(page_id:, id:) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/spage/api/incident.rb', line 52 def find(page_id:, id:) response = client.get("pages/#{page_id}/incidents", id) handle_response(response) do Spage::Incident.new(response.body) end end |
#scheduled(page_id:) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/spage/api/incident.rb', line 32 def scheduled(page_id:) response = client.get("pages/#{page_id}/incidents/scheduled") handle_response(response) do response.body.map do |incident| Spage::Incident.new(incident) end end end |
#unresolved(page_id:) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/spage/api/incident.rb', line 22 def unresolved(page_id:) response = client.get("pages/#{page_id}/incidents/unresolved") handle_response(response) do response.body.map do |incident| Spage::Incident.new(incident) end end end |
#update(incident, page_id:, id:) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/spage/api/incident.rb', line 71 def update(incident, page_id:, id:) json = Spage::Serializers::Incident.new(incident, update: true).to_json response = client.put("pages/#{page_id}/incidents", id, json) handle_response(response) do Spage::Incident.new(response.body) end end |