Class: VAProfile::HealthBenefit::AssociatedPersonsResponse

Inherits:
Response show all
Defined in:
lib/va_profile/health_benefit/associated_persons_response.rb

Constant Summary

Constants included from Common::Client::Concerns::ServiceStatus

Common::Client::Concerns::ServiceStatus::RESPONSE_STATUS

Instance Attribute Summary

Attributes inherited from Common::Base

#errors_hash, #metadata

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Response

#cache?, #metadata, #ok?, #response_status

Methods inherited from Common::Base

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

Constructor Details

#initialize(status_code, data) ⇒ AssociatedPersonsResponse

Returns a new instance of AssociatedPersonsResponse.



13
14
15
16
17
# File 'lib/va_profile/health_benefit/associated_persons_response.rb', line 13

def initialize(status_code, data)
  super(status_code)
  self.associated_persons = data[:associated_persons]
  self.messages = data[:messages]
end

Class Method Details

.from(response) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/va_profile/health_benefit/associated_persons_response.rb', line 20

def from(response)
  status_code = response.status
  json = JSON.parse(response.body)
  associated_persons = json['associated_persons']
                       &.map { |p| VAProfile::Models::AssociatedPerson.build_from(p) }
  messages = json['messages']
             &.map { |m| VAProfile::Models::Message.build_from(m) }
  new(status_code, { associated_persons:, messages: })
end