Class: VAProfile::Models::Person

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

Constant Summary

Constants inherited from Base

Base::SOURCE_SYSTEM

Class Method Summary collapse

Class Method Details

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

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

Parameters:

  • body (Hash)

    the decoded response body from VAProfile

Returns:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/va_profile/models/person.rb', line 26

def self.build_from(body)
  body ||= {}
  addresses = body['addresses']&.map { |a| VAProfile::Models::Address.build_from(a) }
  emails = body['emails']&.map { |e| VAProfile::Models::Email.build_from(e) }
  telephones = body['telephones']&.map { |t| VAProfile::Models::Telephone.build_from(t) }
  permissions = body['permissions']&.map { |t| VAProfile::Models::Permission.build_from(t) }

  VAProfile::Models::Person.new(
    created_at: body['create_date'],
    source_date: body['source_date'],
    updated_at: body['update_date'],
    transaction_id: body['trx_audit_id'],
    addresses: addresses || [],
    emails: emails || [],
    telephones: telephones || [],
    permissions: permissions || [],
    vet360_id: body['vet360_id']
  )
end