Class: InstantQuote::ConnectionTranslators::CapitalOnTap

Inherits:
InstantQuote::ConnectionTranslator show all
Defined in:
lib/instant_quote/connection_translators/capital_on_tap.rb

Constant Summary collapse

DEFAULT_SALUTATION =
'Mr'

Instance Attribute Summary

Attributes inherited from InstantQuote::ConnectionTranslator

#application, #connection, #extra_info

Instance Method Summary collapse

Methods inherited from InstantQuote::ConnectionTranslator

#initialize, translate

Constructor Details

This class inherits a constructor from InstantQuote::ConnectionTranslator

Instance Method Details

#translateObject

rubocop:disable Metrics/AbcSize



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/instant_quote/connection_translators/capital_on_tap.rb', line 11

def translate
  fields = {
    Salutation: app_user.salutation || DEFAULT_SALUTATION,
    FirstName: app_user.first_name,
    LastName: app_user.last_name,
    DateOfBirth: extra_info['date_of_birth'],
    MobilePhone: format_phone(extra_info['applicant_phone_number']),
    EmailAddress: app_user.email,
    PersonalAddress: translate_address,
    TradingName: app_org.name,
    BusinessLegalName: app_org.name,
    BusinessLandline: format_phone(extra_info['applicant_phone_number']),
    YearsTrading: app_org.years_in_business,
    MonthlyTurnOver: translate_turnover,
    BusinessType: translate_business_type,
    BusinessAddress: translate_address,
    RegistrationNumber: app_org.company_number,
    additionalQuestions: additional_questions
  }

  # If the borrower organisation is Sole Trader we need to merge two additional fields.
  if app_org.sole_trader?
    fields.merge!(
      MonthlyIncome: extra_info['monthly_income'],
      MonthlyExpenditure: extra_info['monthly_expenditure']
    )
  end

  fields
end