Class: BGS::VnpVeteran

Inherits:
Object
  • Object
show all
Includes:
SentryLogging
Defined in:
lib/bgs/vnp_veteran.rb

Instance Method Summary collapse

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Constructor Details

#initialize(proc_id:, payload:, user:, claim_type:) ⇒ VnpVeteran

Returns a new instance of VnpVeteran.



9
10
11
12
13
14
15
16
# File 'lib/bgs/vnp_veteran.rb', line 9

def initialize(proc_id:, payload:, user:, claim_type:)
  @user = user
  @proc_id = proc_id
  @payload = payload.with_indifferent_access
  @veteran_info = veteran.formatted_params(@payload)
  @claim_type = claim_type
  @va_file_number = @payload['veteran_information']['va_file_number']
end

Instance Method Details

#createObject

rubocop:disable Metrics/MethodLength



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/bgs/vnp_veteran.rb', line 19

def create
  participant = bgs_service.create_participant(@proc_id, @user.participant_id)
  claim_type_end_product = bgs_service.find_benefit_claim_type_increment(@claim_type)

  # This conditional makes it easier to write specs asserting that
  # log_message_to_sentry is called in #create_person. Though, we may
  # consider removing :warn logs like this from Sentry.
  unless Rails.env.test?
    log_message_to_sentry("#{@proc_id}-#{claim_type_end_product}", :warn, '', { team: 'vfs-ebenefits' })
  end

  address = create_address(participant)
  regional_office_number = get_regional_office(address[:zip_prefix_nbr], address[:cntry_nm], '')
  location_id = get_location_id(regional_office_number)
  create_person(participant)
  bgs_service.create_phone(@proc_id, participant[:vnp_ptcpnt_id], @veteran_info)
  veteran.veteran_response(
    participant,
    address,
    {
      va_file_number: @va_file_number,
      claim_type_end_product:,
      regional_office_number:,
      location_id:,
      net_worth_over_limit_ind: veteran.formatted_boolean(@payload['dependents_application']['household_income'])
    }
  )
end