class Reactio::Service

Public Class Methods

new(options) click to toggle source
# File lib/reactio/service.rb, line 7
def initialize(options)
  @api = APIClient.build(
    options[:api_key],
    options[:organization]
  )
end

Public Instance Methods

create_incident(name, options = {}) click to toggle source
# File lib/reactio/service.rb, line 14
def create_incident(name, options = {})
  payload = { name: name }.tap do |me|
    me[:detection] = to_option_string(options.delete(:detection)) if options.key?(:detection)
    me[:cause] = to_option_string(options.delete(:cause)) if options.key?(:cause)
    me[:point] = to_option_string(options.delete(:point)) if options.key?(:point)
    me[:scale] = to_option_string(options.delete(:scale)) if options.key?(:scale)
  end
    .merge!(options)
  @api.request(:post, "/api/v1/incidents", body: payload)
end
describe_incident(incident_id) click to toggle source
# File lib/reactio/service.rb, line 25
def describe_incident(incident_id)
  @api.request(:get, "/api/v1/incidents/#{incident_id}")
end
list_incidents(options = {}) click to toggle source
# File lib/reactio/service.rb, line 29
def list_incidents(options = {})
  payload = {}.tap do |me|
    me[:from] = options.delete(:from).to_i if options[:from]
    me[:to] = options.delete(:to).to_i if options[:to]
    me[:status] = options.delete(:status).to_s if options[:status]
  end
    .merge!(options)
  @api.request(:get, "/api/v1/incidents", body: payload)
end
notify_incident(incident_id, options = {}) click to toggle source
# File lib/reactio/service.rb, line 39
def notify_incident(incident_id, options = {})
  @api.request(
    :post, "/api/v1/notifications",
    body: { incident_id: incident_id }.merge(options)
  )
end