Class: VAProfile::Models::Demographic

Inherits:
Base
  • Object
show all
Defined in:
lib/va_profile/models/demographic.rb

Constant Summary

Constants inherited from Base

Base::SOURCE_SYSTEM

Class Method Summary collapse

Class Method Details

.build_from(body) ⇒ VAProfile::Models::Demographics

Converts a decoded JSON response from VAProfile to an instance of the Demographic model

Parameters:

  • body (Hash)

    the decoded response body from VAProfile

Returns:

  • (VAProfile::Models::Demographics)

    the model built from the response body



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/va_profile/models/demographic.rb', line 21

def self.build_from(body)
  preferred_name = VAProfile::Models::PreferredName.build_from(body&.dig('preferred_name'))

  # VA Profile API returns collection, but there should only be a single record.
  gender_identity = VAProfile::Models::GenderIdentity.build_from(body&.dig('gender_identity')&.first)

  VAProfile::Models::Demographic.new(
    preferred_name:,
    gender_identity:
  )
end