Class: Reactio::Service
- Inherits:
-
Object
- Object
- Reactio::Service
- Includes:
- Utils
- Defined in:
- lib/reactio/service.rb
Constant Summary
Constants included from Utils
Instance Method Summary collapse
- #create_incident(name, options = {}) ⇒ Object
- #describe_incident(incident_id) ⇒ Object
-
#initialize(options) ⇒ Service
constructor
A new instance of Service.
- #list_incidents(options = {}) ⇒ Object
- #notify_incident(incident_id, options = {}) ⇒ Object
Methods included from Utils
Constructor Details
Instance Method Details
#create_incident(name, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/reactio/service.rb', line 14 def create_incident(name, = {}) payload = { name: name }.tap do |me| me[:detection] = to_option_string(.delete(:detection)) if .key?(:detection) me[:cause] = to_option_string(.delete(:cause)) if .key?(:cause) me[:point] = to_option_string(.delete(:point)) if .key?(:point) me[:scale] = to_option_string(.delete(:scale)) if .key?(:scale) end .merge!() @api.request(:post, "/api/v1/incidents", body: payload) end |
#describe_incident(incident_id) ⇒ Object
25 26 27 |
# File 'lib/reactio/service.rb', line 25 def describe_incident(incident_id) @api.request(:get, "/api/v1/incidents/#{incident_id}") end |
#list_incidents(options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/reactio/service.rb', line 29 def list_incidents( = {}) payload = {}.tap do |me| me[:from] = .delete(:from).to_i if [:from] me[:to] = .delete(:to).to_i if [:to] me[:status] = .delete(:status).to_s if [:status] end .merge!() @api.request(:get, "/api/v1/incidents", body: payload) end |
#notify_incident(incident_id, options = {}) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/reactio/service.rb', line 39 def notify_incident(incident_id, = {}) @api.request( :post, "/api/v1/notifications", body: { incident_id: incident_id }.merge() ) end |