Class: BGS::Marriages
- Inherits:
-
Object
- Object
- BGS::Marriages
- Defined in:
- lib/bgs/marriages.rb
Instance Method Summary collapse
- #add_spouse ⇒ Object private
- #bgs_service ⇒ Object private
- #create_all ⇒ Object
- #create_person(calling_object, participant, marriage_info) ⇒ Object private
- #does_live_with_vet ⇒ Object private
-
#initialize(proc_id:, payload:, user:) ⇒ Marriages
constructor
A new instance of Marriages.
- #report_marriage_history(type) ⇒ Object private
- #send_address(calling_object, participant, address_info) ⇒ Object private
- #spouse_dependent_optional_fields(type, marriage_info) ⇒ Object private
Constructor Details
#initialize(proc_id:, payload:, user:) ⇒ Marriages
Returns a new instance of Marriages.
7 8 9 10 11 12 13 |
# File 'lib/bgs/marriages.rb', line 7 def initialize(proc_id:, payload:, user:) @user = user @dependents = [] @proc_id = proc_id @payload = payload @dependents_application = @payload['dependents_application'] end |
Instance Method Details
#add_spouse ⇒ Object (private)
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/bgs/marriages.rb', line 57 def add_spouse spouse = BGSDependents::Spouse.new(@dependents_application) spouse_info = spouse.format_info participant = bgs_service.create_participant(@proc_id) create_person(spouse, participant, spouse_info) send_address(spouse, participant, spouse_info) @dependents << spouse.serialize_dependent_result( participant, 'Spouse', does_live_with_vet ? 'Spouse' : 'Estranged Spouse', { begin_date: @dependents_application['current_marriage_information']['date'], marriage_country: @dependents_application['current_marriage_information']['location']['country'], marriage_state: @dependents_application['current_marriage_information']['location']['state'], marriage_city: @dependents_application['current_marriage_information']['location']['city'], type: 'spouse', dep_has_income_ind: spouse_info['spouse_income'] } ) end |
#bgs_service ⇒ Object (private)
93 94 95 |
# File 'lib/bgs/marriages.rb', line 93 def bgs_service @bgs_service = BGS::Service.new(@user) end |
#create_all ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/bgs/marriages.rb', line 15 def create_all report_marriage_history('veteran_marriage_history') if @payload['veteran_was_married_before'] report_marriage_history('spouse_marriage_history') if @payload['spouse_was_married_before'] add_spouse if @payload['view:selectable686_options']['add_spouse'] @dependents end |
#create_person(calling_object, participant, marriage_info) ⇒ Object (private)
80 81 82 83 84 |
# File 'lib/bgs/marriages.rb', line 80 def create_person(calling_object, participant, marriage_info) params = calling_object.create_person_params(@proc_id, participant[:vnp_ptcpnt_id], marriage_info) bgs_service.create_person(params) end |
#does_live_with_vet ⇒ Object (private)
97 98 99 |
# File 'lib/bgs/marriages.rb', line 97 def does_live_with_vet @dependents_application['does_live_with_spouse']['spouse_does_live_with_veteran'] end |
#report_marriage_history(type) ⇒ Object (private)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bgs/marriages.rb', line 25 def report_marriage_history(type) @dependents_application[type].each do |former_spouse| former_marriage = BGSDependents::MarriageHistory.new(former_spouse) marriage_info = former_marriage.format_info participant = bgs_service.create_participant(@proc_id) create_person(former_marriage, participant, marriage_info) @dependents << former_marriage.serialize_dependent_result( participant, 'Spouse', 'Ex-Spouse', spouse_dependent_optional_fields(type, marriage_info) ) end end |
#send_address(calling_object, participant, address_info) ⇒ Object (private)
86 87 88 89 90 91 |
# File 'lib/bgs/marriages.rb', line 86 def send_address(calling_object, participant, address_info) address = calling_object.generate_address(address_info) address_params = calling_object.create_address_params(@proc_id, participant[:vnp_ptcpnt_id], address) bgs_service.create_address(address_params) end |
#spouse_dependent_optional_fields(type, marriage_info) ⇒ Object (private)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bgs/marriages.rb', line 42 def spouse_dependent_optional_fields(type, marriage_info) { type:, begin_date: marriage_info['start_date'], marriage_country: marriage_info['marriage_country'], marriage_state: marriage_info['marriage_state'], marriage_city: marriage_info['marriage_city'], divorce_state: marriage_info['divorce_state'], divorce_city: marriage_info['divorce_city'], divorce_country: marriage_info['divorce_country'], end_date: marriage_info['end_date'], marriage_termination_type_code: marriage_info['marriage_termination_type_code'] } end |