Class: EVSS::DisabilityCompensationForm::Form8940

Inherits:
Object
  • Object
show all
Defined in:
lib/evss/disability_compensation_form/form8940.rb

Overview

Transforms a client 8940 form submission into the format expected by the EVSS service

Instance Method Summary collapse

Constructor Details

#initialize(user, form_content) ⇒ Form8940

Returns a new instance of Form8940.



11
12
13
14
15
16
# File 'lib/evss/disability_compensation_form/form8940.rb', line 11

def initialize(user, form_content)
  @user = user
  @phone_email = form_content.dig('form526', 'phoneAndEmail')
  @mailing_address = form_content.dig('form526', 'mailingAddress')
  @final_output = form_content.dig('form526', 'form8940')
end

Instance Method Details

#address(data) ⇒ Object (private)



45
46
47
48
49
50
51
52
53
54
# File 'lib/evss/disability_compensation_form/form8940.rb', line 45

def address(data)
  {
    city: data['city'],
    country: data['country'],
    postalCode: data['zipCode'],
    street: data['addressLine1'],
    street2: data['addressLine2'],
    state: data['state']
  }
end

#full_nameObject (private)



37
38
39
40
41
42
43
# File 'lib/evss/disability_compensation_form/form8940.rb', line 37

def full_name
  {
    first: @user.first_name,
    middle: @user.middle_name,
    last: @user.last_name
  }
end

#translateString

Merges the user data and performs the translation

Returns:

  • (String)

    The translated form ready for submission



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/evss/disability_compensation_form/form8940.rb', line 22

def translate
  return nil unless @final_output

  @final_output['vaFileNumber'] = @user.ssn
  @final_output['veteranSocialSecurityNumber'] = @user.ssn
  @final_output['veteranFullName'] = full_name
  @final_output['veteranDateOfBirth'] = @user.birth_date
  @final_output['veteranAddress'] = address(@mailing_address)
  @final_output['email'] = @phone_email['emailAddress']
  @final_output['veteranPhone'] = @phone_email['primaryPhone']
  @final_output.to_json
end