Class: PagerDuty::ExternalServices::Response

Inherits:
Response show all
Defined in:
lib/pagerduty/external_services/response.rb

Instance Attribute Summary

Attributes inherited from Common::Base

#errors_hash, #metadata

Class Method Summary collapse

Methods inherited from Response

#cache?, #initialize, #ok?

Methods inherited from Common::Base

#changed, #changed?, #changes, default_sort, filterable_attributes, #initialize, max_per_page, per_page, sortable_attributes

Constructor Details

This class inherits a constructor from PagerDuty::Response

Class Method Details

.from(raw_response) ⇒ PagerDuty::ExternalServices::Response

Returns An instance of this class.

Parameters:

  • raw_response (Faraday::Env)

    Response from PagerDuty ‘GET /services` call

Returns:



19
20
21
22
23
24
25
26
27
# File 'lib/pagerduty/external_services/response.rb', line 19

def self.from(raw_response)
  services = raw_response&.body&.dig('services').presence || []

  new(
    raw_response&.status,
    reported_at: Time.current.iso8601,
    statuses: PagerDuty::Models::Service.statuses_for(services).map(&:to_h)
  )
end