Class: UserRelationship
- Inherits:
-
Object
- Object
- UserRelationship
- Defined in:
- app/models/user_relationship.rb
Constant Summary collapse
- PERSON_TYPE_VETERAN =
'VET'
Instance Attribute Summary collapse
-
#birth_date ⇒ Object
Returns the value of attribute birth_date.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#gender ⇒ Object
Returns the value of attribute gender.
-
#icn ⇒ Object
Returns the value of attribute icn.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#participant_id ⇒ Object
Returns the value of attribute participant_id.
-
#ssn ⇒ Object
Returns the value of attribute ssn.
-
#veteran_status ⇒ Object
Returns the value of attribute veteran_status.
Class Method Summary collapse
-
.from_bgs_dependent(bgs_dependent) ⇒ Object
Initializer with a single ‘person’ from a BGS get_dependents call.
-
.from_mpi_relationship(mpi_relationship) ⇒ Object
Initializer with a single ‘person’ from an MPI response RelationshipHolder stanza.
Instance Method Summary collapse
- #build_user_identity ⇒ Object private
-
#get_full_attributes ⇒ Object
Full MPI Profile object.
-
#to_hash ⇒ Object
Sparse hash to serialize to frontend.
Instance Attribute Details
#birth_date ⇒ Object
Returns the value of attribute birth_date.
4 5 6 |
# File 'app/models/user_relationship.rb', line 4 def birth_date @birth_date end |
#first_name ⇒ Object
Returns the value of attribute first_name.
4 5 6 |
# File 'app/models/user_relationship.rb', line 4 def first_name @first_name end |
#gender ⇒ Object
Returns the value of attribute gender.
4 5 6 |
# File 'app/models/user_relationship.rb', line 4 def gender @gender end |
#icn ⇒ Object
Returns the value of attribute icn.
4 5 6 |
# File 'app/models/user_relationship.rb', line 4 def icn @icn end |
#last_name ⇒ Object
Returns the value of attribute last_name.
4 5 6 |
# File 'app/models/user_relationship.rb', line 4 def last_name @last_name end |
#participant_id ⇒ Object
Returns the value of attribute participant_id.
4 5 6 |
# File 'app/models/user_relationship.rb', line 4 def participant_id @participant_id end |
#ssn ⇒ Object
Returns the value of attribute ssn.
4 5 6 |
# File 'app/models/user_relationship.rb', line 4 def ssn @ssn end |
#veteran_status ⇒ Object
Returns the value of attribute veteran_status.
4 5 6 |
# File 'app/models/user_relationship.rb', line 4 def veteran_status @veteran_status end |
Class Method Details
.from_bgs_dependent(bgs_dependent) ⇒ Object
Initializer with a single ‘person’ from a BGS get_dependents call
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/user_relationship.rb', line 10 def self.from_bgs_dependent(bgs_dependent) user_relationship = new # Profile attributes user_relationship.first_name = bgs_dependent[:first_name] user_relationship.last_name = bgs_dependent[:last_name] user_relationship.birth_date = Formatters::DateFormatter.format_date(bgs_dependent[:date_of_birth]) user_relationship.ssn = bgs_dependent[:ssn] user_relationship.gender = bgs_dependent[:gender] user_relationship.veteran_status = bgs_dependent[:veteran_indicator] == 'Y' # ID attributes user_relationship.participant_id = bgs_dependent[:ptcpnt_id] user_relationship end |
.from_mpi_relationship(mpi_relationship) ⇒ Object
Initializer with a single ‘person’ from an MPI response RelationshipHolder stanza
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/user_relationship.rb', line 25 def self.from_mpi_relationship(mpi_relationship) user_relationship = new # Profile attributes user_relationship.first_name = mpi_relationship.given_names&.first user_relationship.last_name = mpi_relationship.family_name user_relationship.birth_date = Formatters::DateFormatter.format_date(mpi_relationship.birth_date) user_relationship.ssn = mpi_relationship.ssn user_relationship.gender = mpi_relationship.gender user_relationship.veteran_status = mpi_relationship.person_types.include? PERSON_TYPE_VETERAN # ID attributes user_relationship.icn = mpi_relationship.icn user_relationship.participant_id = mpi_relationship.participant_id user_relationship end |
Instance Method Details
#build_user_identity ⇒ Object (private)
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/user_relationship.rb', line 57 def build_user_identity UserIdentity.new( uuid: SecureRandom.uuid, first_name: first_name.to_s, last_name: last_name.to_s, birth_date: birth_date.to_s, gender: gender.to_s, ssn: ssn.to_s, icn: icn.to_s, mhv_icn: icn.to_s, loa: { current: LOA::THREE, highest: LOA::THREE } ) end |
#get_full_attributes ⇒ Object
Full MPI Profile object
50 51 52 53 |
# File 'app/models/user_relationship.rb', line 50 def get_full_attributes user_identity = build_user_identity MPIData.for_user(user_identity) end |
#to_hash ⇒ Object
Sparse hash to serialize to frontend
41 42 43 44 45 46 47 |
# File 'app/models/user_relationship.rb', line 41 def to_hash { first_name:, last_name:, birth_date: } end |