Class: VAProfile::Demographics::DemographicResponse

Inherits:
Response show all
Defined in:
lib/va_profile/demographics/demographic_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?, #initialize, #metadata, #ok?, #response_status

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 VAProfile::Response

Class Method Details

.from(opts = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/va_profile/demographics/demographic_response.rb', line 11

def self.from(opts = {})
  status = opts[:status]
  body = opts[:body]
  demographic = VAProfile::Models::Demographic.build_from(body&.dig('bio'))

  demographic.id = opts[:id]
  demographic.type = opts[:type]
  demographic.gender = opts[:gender]
  demographic.birth_date = opts[:birth_date]

  new(
    status,
    demographics: demographic
  )
end

Instance Method Details

#birth_dateObject



31
32
33
# File 'lib/va_profile/demographics/demographic_response.rb', line 31

def birth_date
  demographics&.birth_date
end

#genderObject



27
28
29
# File 'lib/va_profile/demographics/demographic_response.rb', line 27

def gender
  demographics&.gender
end