# frozen_string_literal: true module CapitalOnTap class Application SALUTATIONS = %w[Mr Mrs Miss Ms Dr].freeze BUSINESS_TYPES = %w[SoleTrader Partnership LimitedCompany LimitedLiabilityPartnership].freeze attr_accessor :salutation, :first_name, :middle_name, :last_name, :date_of_birth, :mobile_phone attr_accessor :home_phone, :email_address, :customer_uses_personal_bank_account_for_business attr_accessor :monthly_income, :monthly_expenditure, :personal_address attr_accessor :trading_name, :business_legal_name, :business_land_line, :years_trading attr_accessor :monthly_turn_over, :business_type, :registration_number, :business_address attr_accessor :promo_code, :on_paste_event_fields, :montly_business_expenditure attr_accessor :external_reference, :partner_code, :restricted_countries, :requested_credit DEFAULT_PARAMS = { CustomerId: nil, Salutation: 'Mr', FirstName: 'Amjed', MiddleName: '', LastName: 'Ali', DateOfBirth: '1967-07-14T00:00:00+01:00', MobilePhone: '07841580124', HomePhone: nil, EmailAddress: nil, MonthlyIncome: nil, MonthlyExpenditure: nil, PersonalAddress: {}, TradingName: 'Glamour Bikinis And Clothing Boutique Limited', BusinessLegalName: 'Glamour Bikinis And Clothing Boutique Limited', BusinessLandline: '07874186570', YearsTrading: 8, MonthlyTurnOver: 10_000, BusinessType: 'LimitedCompany', RegistrationNumber: 10_322_035, BusinessAddress: {}, PromoCode: nil, OnPasteEventFields: nil, MonthlyBusinessExpenditure: nil, GoogleSessionId: nil, PartnerCode: nil, ExternalReference: nil, RestrictedCountries: false, RequestedCredit: 10_000, ApplicationGuid: nil }.freeze # Create a new application with the given parameters # Example JSON: # { # "CustomerId": null, # "Salutation": "Mr", # "FirstName": "Amjed", # "MiddleName": "", # "LastName": "Ali", # "DateOfBirth": "1967-07-14T00:00:00+01:00", # "MobilePhone": "07841580124", # "HomePhone": null, # "EmailAddress": "something@anything.com", # "MonthlyIncome": 5000, # "MonthlyExpenditure": 4000, # "PersonalAddress": { # "Company": null, # "BuildingName": "", # "UnitNumber": "", # "BuildingNumber": "244", # "Street": "Grahams Road", # "PostCode": "CH61 7XF", # "City": "Wirral", # "CountryCode": "UK", # "Line1": "PostApplication", # "Line2": null # }, # "TradingName": "Glamour Bikinis And Clothing Boutique Limited", # "BusinessLegalName": "Glamour Bikinis And Clothing Boutique Limited", # "BusinessLandline": "07874186570", # "YearsTrading":8, # "MonthlyTurnOver":10000, # "BusinessType": "LimitedCompany", # "RegistrationNumber":10322035, # "BusinessAddress": { # "Company": null, # "BuildingName": "", # "UnitNumber": "", # "BuildingNumber": "102", # "Street": "Ford Road", # "PostCode": "CH49 0TQ", # "City": "Wirral", # "CountryCode": "UK", # "Line1": "PostApplication", # "Line2": null # }, # "PromoCode": null, # "OnPasteEventFields": null, # "MonthlyBusinessExpenditure": null, # "GoogleSessionId": null, # "PartnerCode": null, # "ExternalReference": null, # "RestrictedCountries":false, # "RequestedCredit":10000, # "ApplicationGuid": null # } def self.create(params) url = File.join(Connection::BASE_PATH, '/Applications') response = CapitalOnTap.connection.post(url, params) response end def self.status(locator_id) url = File.join(Connection::BASE_PATH, "/Applications/#{locator_id}") CapitalOnTap.connection.get(url) end end end