Class: Optimum::CustomerGenerator
- Inherits:
-
Object
- Object
- Optimum::CustomerGenerator
- Defined in:
- lib/optimum/customer_generator.rb
Overview
This class can be used to generate fake customers for test purposes
Constant Summary collapse
- DEFAULTS =
{ id: SecureRandom.hex(4), first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, email: Faker::Internet.email, phone: Faker::PhoneNumber.phone_number, address: Faker::Address.street_address, date_of_birth: Faker::Date.birthday(min_age: 23, max_age: 65), city: Faker::Address.city, postcode: Faker::Address.postcode }.freeze
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#city ⇒ Object
Returns the value of attribute city.
-
#date_of_birth ⇒ Object
Returns the value of attribute date_of_birth.
-
#email ⇒ Object
Returns the value of attribute email.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#id ⇒ Object
Returns the value of attribute id.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#postcode ⇒ Object
Returns the value of attribute postcode.
Class Method Summary collapse
Instance Method Summary collapse
- #company_information ⇒ Object
- #emails ⇒ Object
- #generate ⇒ Object
-
#initialize(params = {}) ⇒ CustomerGenerator
constructor
A new instance of CustomerGenerator.
- #phones ⇒ Object
- #residential_addresses ⇒ Object
- #user_information ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ CustomerGenerator
Returns a new instance of CustomerGenerator.
27 28 29 30 31 32 33 |
# File 'lib/optimum/customer_generator.rb', line 27 def initialize(params = {}) Faker::Config.locale = 'en-GB' DEFAULTS.each do |key, default_value| send("#{key}=", params[key] || default_value) end end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
8 9 10 |
# File 'lib/optimum/customer_generator.rb', line 8 def address @address end |
#city ⇒ Object
Returns the value of attribute city.
8 9 10 |
# File 'lib/optimum/customer_generator.rb', line 8 def city @city end |
#date_of_birth ⇒ Object
Returns the value of attribute date_of_birth.
8 9 10 |
# File 'lib/optimum/customer_generator.rb', line 8 def date_of_birth @date_of_birth end |
#email ⇒ Object
Returns the value of attribute email.
8 9 10 |
# File 'lib/optimum/customer_generator.rb', line 8 def email @email end |
#first_name ⇒ Object
Returns the value of attribute first_name.
8 9 10 |
# File 'lib/optimum/customer_generator.rb', line 8 def first_name @first_name end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/optimum/customer_generator.rb', line 8 def id @id end |
#last_name ⇒ Object
Returns the value of attribute last_name.
8 9 10 |
# File 'lib/optimum/customer_generator.rb', line 8 def last_name @last_name end |
#phone ⇒ Object
Returns the value of attribute phone.
8 9 10 |
# File 'lib/optimum/customer_generator.rb', line 8 def phone @phone end |
#postcode ⇒ Object
Returns the value of attribute postcode.
9 10 11 |
# File 'lib/optimum/customer_generator.rb', line 9 def postcode @postcode end |
Class Method Details
.generate(params = {}) ⇒ Object
23 24 25 |
# File 'lib/optimum/customer_generator.rb', line 23 def self.generate(params = {}) new(params).generate end |
Instance Method Details
#company_information ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/optimum/customer_generator.rb', line 55 def company_information { last_12_months_turnover: { amount: 0.0 }, registered_company_name: 'HOKO LTD', industry: 'B | Mining and Quarrying', company_number: '09525857', type: 'limited_liability_company', trading_from_date: '2015-05-22', registered_address: { postcode: 'W1T 3NF', street_line_1: 'Berners House', street_line_2: '47-48 Berners Street', town: 'London', country: 'GB' }, vat_status: { is_vat_registered: true } } end |
#emails ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/optimum/customer_generator.rb', line 105 def emails [ { uid: SecureRandom.uuid, email: email, type: 'primary' } ] end |
#generate ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/optimum/customer_generator.rb', line 35 def generate { data: { application: { company: company_information, people: [user_information], requested_products: { credit_facility: { approval: { amount: 123_123, duration: 12, detailed_purpose: 'business loan' } } } } } } end |
#phones ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/optimum/customer_generator.rb', line 95 def phones [ { uid: SecureRandom.uuid, number: phone, type: 'primary' } ] end |
#residential_addresses ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/optimum/customer_generator.rb', line 115 def residential_addresses [ { uid: SecureRandom.uuid, town: city, street_line_1: address, street_line_2: '', country: 'GB', postcode: postcode, house_number: '10', residential_status: 'owner_no_mortgage' } ] end |
#user_information ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/optimum/customer_generator.rb', line 78 def user_information { uid: SecureRandom.uuid, first_name: first_name, last_name: last_name, date_of_birth: date_of_birth, roles: %w[applicant shareholder guarantor director], phones: phones, emails: emails, residential_addresses: residential_addresses, privacy_policy: { agreed: true, datetime: DateTime.now } } end |