Class: Honeybadger::Api::Outage

Inherits:
Object
  • Object
show all
Defined in:
lib/honeybadger-api/outage.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Outage

Public: Build a new instance of Outage

opts - A Hash of attributes to initialize an Outage

Returns a new Outage



12
13
14
15
16
17
18
19
# File 'lib/honeybadger-api/outage.rb', line 12

def initialize(opts)
  @down_at = opts[:down_at].nil? ? nil : DateTime.parse(opts[:down_at])
  @up_at = opts[:up_at].nil? ? nil : DateTime.parse(opts[:up_at])
  @created_at = opts[:created_at].nil? ? nil : DateTime.parse(opts[:created_at])
  @status = opts[:status]
  @reason = opts[:reason]
  @headers = opts[:headers]
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



5
6
7
# File 'lib/honeybadger-api/outage.rb', line 5

def created_at
  @created_at
end

#down_atObject (readonly)

Returns the value of attribute down_at.



5
6
7
# File 'lib/honeybadger-api/outage.rb', line 5

def down_at
  @down_at
end

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/honeybadger-api/outage.rb', line 5

def headers
  @headers
end

#reasonObject (readonly)

Returns the value of attribute reason.



5
6
7
# File 'lib/honeybadger-api/outage.rb', line 5

def reason
  @reason
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/honeybadger-api/outage.rb', line 5

def status
  @status
end

#up_atObject (readonly)

Returns the value of attribute up_at.



5
6
7
# File 'lib/honeybadger-api/outage.rb', line 5

def up_at
  @up_at
end

Class Method Details

.all(project_id, site_id) ⇒ Object

Public: Find all outages for a given project and site.



22
23
24
25
# File 'lib/honeybadger-api/outage.rb', line 22

def self.all(project_id, site_id)
  path = "projects/#{project_id}/sites/#{site_id}/outages"
  Honeybadger::Api::Request.all(path, handler)
end

.handlerObject

Internal: The handler used to build objects from API responses.



34
35
36
# File 'lib/honeybadger-api/outage.rb', line 34

def self.handler
  Proc.new { |response| Outage.new(response) }
end

.paginate(project_id, site_id, filters = {}) ⇒ Object

Public: Paginate all outages for a given project and site.



28
29
30
31
# File 'lib/honeybadger-api/outage.rb', line 28

def self.paginate(project_id, site_id, filters = {})
  path = "projects/#{project_id}/sites/#{site_id}/outages"
  Honeybadger::Api::Request.paginate(path, handler, filters)
end