Class: BGS::DependentHigherEdAttendance

Inherits:
Object
  • Object
show all
Defined in:
lib/bgs/dependent_higher_ed_attendance.rb

Instance Method Summary collapse

Constructor Details

#initialize(proc_id:, payload:, user:) ⇒ DependentHigherEdAttendance

Returns a new instance of DependentHigherEdAttendance.



7
8
9
10
11
12
# File 'lib/bgs/dependent_higher_ed_attendance.rb', line 7

def initialize(proc_id:, payload:, user:)
  @proc_id = proc_id
  @payload = payload
  @dependents = {}
  @user = user
end

Instance Method Details

#bgs_serviceObject



44
45
46
# File 'lib/bgs/dependent_higher_ed_attendance.rb', line 44

def bgs_service
  @bgs_service ||= BGS::Service.new(@user)
end

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bgs/dependent_higher_ed_attendance.rb', line 14

def create
  adult_attending_school = BGSDependents::AdultChildAttendingSchool.new(@payload['dependents_application'])
  formatted_info = adult_attending_school.format_info
  participant = bgs_service.create_participant(@proc_id)

  bgs_service.create_person(person_params(adult_attending_school, participant, formatted_info))
  send_address(adult_attending_school, participant, adult_attending_school.address)

  @dependents = adult_attending_school.serialize_dependent_result(
    participant,
    'Child',
    'Biological',
    {
      type: '674',
      dep_has_income_ind: formatted_info['dependent_income']
    }
  )
end

#person_params(calling_object, participant, dependent_info) ⇒ Object



33
34
35
# File 'lib/bgs/dependent_higher_ed_attendance.rb', line 33

def person_params(calling_object, participant, dependent_info)
  calling_object.create_person_params(@proc_id, participant[:vnp_ptcpnt_id], dependent_info)
end

#send_address(calling_object, participant, address_info) ⇒ Object



37
38
39
40
41
42
# File 'lib/bgs/dependent_higher_ed_attendance.rb', line 37

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