iwoca 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,9 @@
3
3
  require 'faker'
4
4
 
5
5
  module Iwoca
6
- # This class can be used to generate fake customers for test purposes
6
+ # This class can be used to generate fake customers for test purposes.
7
+ # It is based on the minimum data requirements described here:
8
+ # https://iwoca.stoplight.io/docs/lapi-uk/branches/2.1.0/2c44db4bf20fb-meeting-minimum-data-requirements
7
9
  class CustomerGenerator
8
10
  attr_accessor :id, :first_name, :last_name, :email, :phone, :address, :date_of_birth, :city
9
11
  attr_accessor :postcode
@@ -13,7 +15,7 @@ module Iwoca
13
15
  first_name: Faker::Name.first_name,
14
16
  last_name: Faker::Name.last_name,
15
17
  email: Faker::Internet.email,
16
- phone: Faker::PhoneNumber.phone_number,
18
+ phone: Faker::PhoneNumber.cell_phone_in_e164,
17
19
  address: Faker::Address.street_address,
18
20
  date_of_birth: Faker::Date.birthday(min_age: 23, max_age: 65),
19
21
  city: Faker::Address.city,
@@ -21,7 +23,7 @@ module Iwoca
21
23
  }.freeze
22
24
 
23
25
  def self.generate(params = {})
24
- new(params).generate
26
+ new(DEFAULTS.merge(params)).generate
25
27
  end
26
28
 
27
29
  def initialize(params = {})
@@ -35,59 +37,50 @@ module Iwoca
35
37
  def generate
36
38
  {
37
39
  data: {
38
- application: {
39
- company: company_information,
40
- people: [user_information],
41
- requested_products: {
42
- credit_facility: {
43
- approval: {
44
- amount: 123_123,
45
- duration: 12,
46
- detailed_purpose: 'business loan'
47
- }
48
- }
49
- }
50
- }
40
+ company: company_information,
41
+ people: [user_information]
51
42
  }
52
43
  }
53
44
  end
54
45
 
55
46
  def company_information
56
47
  {
48
+ company_number: '09525857',
57
49
  last_12_months_turnover: {
58
- amount: 0.0
50
+ amount: 70_000,
51
+ valid_from: "2019-08-24T14:15:22Z"
59
52
  },
60
53
  registered_company_name: 'HOKO LTD',
61
- industry: 'B | Mining and Quarrying',
62
- company_number: '09525857',
63
- type: 'limited_liability_company',
64
54
  trading_from_date: '2015-05-22',
55
+ type: 'limited_liability_company',
56
+ industry: 'B | Mining and Quarrying',
57
+ vat_status: {
58
+ is_vat_registered: true,
59
+ registered_over_3_months: true,
60
+ },
65
61
  registered_address: {
66
62
  postcode: 'W1T 3NF',
67
63
  street_line_1: 'Berners House',
68
64
  street_line_2: '47-48 Berners Street',
69
65
  town: 'London',
70
66
  country: 'GB'
71
- },
72
- vat_status: {
73
- is_vat_registered: true
74
67
  }
75
68
  }
76
69
  end
77
70
 
78
71
  def user_information
79
72
  {
73
+ date_of_birth: date_of_birth,
74
+ emails: emails,
80
75
  uid: SecureRandom.uuid,
81
76
  first_name: first_name,
82
77
  last_name: last_name,
83
- date_of_birth: date_of_birth,
84
- roles: %w[applicant shareholder guarantor director],
85
78
  phones: phones,
86
- emails: emails,
79
+ roles: %w[applicant shareholder guarantor director],
87
80
  residential_addresses: residential_addresses,
88
81
  privacy_policy: {
89
82
  agreed: true,
90
- datetime: DateTime.now
83
+ valid_from: DateTime.now - 1
91
84
  }
92
85
  }
93
86
  end
@@ -95,7 +88,6 @@ module Iwoca
95
88
  def phones
96
89
  [
97
90
  {
98
- uid: SecureRandom.uuid,
99
91
  number: phone,
100
92
  type: 'primary'
101
93
  }
@@ -105,8 +97,11 @@ module Iwoca
105
97
  def emails
106
98
  [
107
99
  {
108
- uid: SecureRandom.uuid,
109
100
  email: email,
101
+ marketing_opt_in: {
102
+ agreed: true,
103
+ valid_from: DateTime.now
104
+ },
110
105
  type: 'primary'
111
106
  }
112
107
  ]
@@ -115,14 +110,12 @@ module Iwoca
115
110
  def residential_addresses
116
111
  [
117
112
  {
118
- uid: SecureRandom.uuid,
119
- town: city,
113
+ country: 'GB',
114
+ residential_status: 'owner_no_mortgage',
120
115
  street_line_1: address,
121
116
  street_line_2: '',
122
- country: 'GB',
123
- postcode: postcode,
124
- house_number: '10',
125
- residential_status: 'owner_no_mortgage'
117
+ town: city,
118
+ postcode: postcode
126
119
  }
127
120
  ]
128
121
  end
@@ -0,0 +1,542 @@
1
+ {
2
+ "additionalProperties": false,
3
+ "description": "The customers endpoint. This holds state information about the customer.",
4
+ "properties": {
5
+ "data": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "company": {
9
+ "$ref": "#/definitions/company"
10
+ },
11
+ "correlation_id": {
12
+ "description": "Provided by partners to identify a customer in the optional quote_data endpoint payload posted to iwoca.",
13
+ "format": "uuid",
14
+ "type": "string"
15
+ },
16
+ "external_customer_id": {
17
+ "description": "Only used if you've set up a custom integration that requires iwoca to use your unique customer id.",
18
+ "type": "string"
19
+ },
20
+ "people": {
21
+ "description": "People associated with the company including the applicant and any other directors, shareholders or loan guarantors you wish to submit. For every customer there should be exactly one person with the role of 'applicant' that is also a 'director' and 'guarantor'.",
22
+ "items": {
23
+ "$ref": "#/definitions/person"
24
+ },
25
+ "type": "array"
26
+ }
27
+ },
28
+ "type": "object"
29
+ }
30
+ },
31
+ "title": "customer_payload",
32
+ "type": "object",
33
+ "definitions": {
34
+ "company": {
35
+ "additionalProperties": false,
36
+ "properties": {
37
+ "company_number": {
38
+ "description": "Company number as on Companies House.",
39
+ "maxLength": 50,
40
+ "type": "string"
41
+ },
42
+ "has_card_based_transactions": {
43
+ "type": "boolean"
44
+ },
45
+ "industry": {
46
+ "description": "Recommended format is one of: Agriculture, Forestry & Fishing / Architecture & Engineering / Business Support Services (e.g. recruitment or security) / Car Dealers, Garages & Mechanics / Cleaning, Landscaping & Gardening / Construction (e.g. builders, civil engineer or electrician) / Education & Training / Finance & Insurance / Health & Care (e.g. day-care, doctors or care homes) / Hotels, Restaurants & Pubs / IT & Communications/ Leisure / Other Services (e.g. hairdressers or travel agents) / Manufacturing, Food Processing & Printing / Professional Services (e.g. accounting or consulting) / Property & Real Estate / Publishing, Film & Media Production / Retail (online or offline) / Transport & Logistics (e.g. taxis, couriers or storage) / Wholesale / Other.",
47
+ "type": "string"
48
+ },
49
+ "last_12_months_profit": {
50
+ "additionalProperties": false,
51
+ "description": "Estimated profit over the last 12 months. For a young business without a full year of trading, the profit to date should be given. A negative value denotes a loss.",
52
+ "properties": {
53
+ "amount": {
54
+ "description": "Pre-tax amount submitted by customer in local currency. Note that this differs from monthly_non_business_income which is post-tax.",
55
+ "type": "number"
56
+ },
57
+ "valid_from": {
58
+ "description": "Datetime when user submitted data, with expected ISO 8601 format.",
59
+ "format": "date-time",
60
+ "type": "string"
61
+ }
62
+ },
63
+ "type": "object"
64
+ },
65
+ "last_12_months_turnover": {
66
+ "additionalProperties": false,
67
+ "description": "Estimated revenue over the last 12 months. For a young business without a full year of revenue, revenue to date should be given.",
68
+ "properties": {
69
+ "amount": {
70
+ "description": "Amount submitted by customer in local currency or other estimate.",
71
+ "type": "number"
72
+ },
73
+ "valid_from": {
74
+ "description": "Datetime when user submitted data, with expected ISO 8601 format.",
75
+ "format": "date-time",
76
+ "type": "string"
77
+ }
78
+ },
79
+ "type": "object"
80
+ },
81
+ "number_of_employees": {
82
+ "type": "integer"
83
+ },
84
+ "online_sales_percentage": {
85
+ "type": "integer"
86
+ },
87
+ "overdraft_status": {
88
+ "additionalProperties": false,
89
+ "properties": {
90
+ "has_overdraft": {
91
+ "description": "Specifies whether the user claims their company has a business overdraft.",
92
+ "type": "boolean"
93
+ },
94
+ "total_overdraft_limit": {
95
+ "description": "User declaration for total overdraft limit available to the company. If the company has multiple overdrafts, the sum of the limits should be used.",
96
+ "type": "number"
97
+ }
98
+ },
99
+ "type": "object"
100
+ },
101
+ "registered_address": {
102
+ "$ref": "#/definitions/company_address"
103
+ },
104
+ "registered_company_name": {
105
+ "description": "Registered company name for a registered business such as a limited company, as on Companies House.",
106
+ "maxLength": 200,
107
+ "type": "string"
108
+ },
109
+ "third_party_providers": {
110
+ "description": "Details of third-party providers used by the business such as Xero, eBay, PayPal or others.",
111
+ "items": {
112
+ "additionalProperties": false,
113
+ "properties": {
114
+ "name": {
115
+ "maxLength": 200,
116
+ "type": "string"
117
+ },
118
+ "type": {
119
+ "enum": ["ecommerce", "software", "bank"],
120
+ "type": "string"
121
+ }
122
+ },
123
+ "required": ["name", "type"],
124
+ "type": "object"
125
+ },
126
+ "type": "array"
127
+ },
128
+ "trading_address": {
129
+ "$ref": "#/definitions/company_address"
130
+ },
131
+ "trading_from_date": {
132
+ "description": "Date when company started trading, with expected ISO 8601 format.",
133
+ "format": "date",
134
+ "type": "string"
135
+ },
136
+ "trading_name": {
137
+ "description": "Primary company name used for sole traders and ordinary partnerships, otherwise registered name will typically be used.",
138
+ "maxLength": 200,
139
+ "type": "string"
140
+ },
141
+ "type": {
142
+ "enum": [
143
+ "limited_liability_company",
144
+ "sole_trader",
145
+ "ordinary_partnership",
146
+ "limited_liability_partnership",
147
+ "public_limited_company",
148
+ "other"
149
+ ],
150
+ "type": "string"
151
+ },
152
+ "vat_status": {
153
+ "additionalProperties": false,
154
+ "description": "Information on the company's VAT registration status.",
155
+ "properties": {
156
+ "is_vat_registered": {
157
+ "type": "boolean"
158
+ },
159
+ "registered_over_3_months": {
160
+ "type": "boolean"
161
+ },
162
+ "vat_number": {
163
+ "type": "string"
164
+ }
165
+ },
166
+ "type": "object"
167
+ },
168
+ "website": {
169
+ "description": "Company website.",
170
+ "format": "uri",
171
+ "maxLength": 200,
172
+ "type": "string"
173
+ }
174
+ },
175
+ "title": "company",
176
+ "type": "object"
177
+ },
178
+ "company_address": {
179
+ "additionalProperties": false,
180
+ "properties": {
181
+ "country": {
182
+ "enum": ["GB", "DE", "OTHER"],
183
+ "maxLength": 5,
184
+ "type": "string"
185
+ },
186
+ "postcode": {
187
+ "maxLength": 250,
188
+ "type": "string"
189
+ },
190
+ "street_line_1": {
191
+ "maxLength": 250,
192
+ "type": "string"
193
+ },
194
+ "street_line_2": {
195
+ "maxLength": 250,
196
+ "type": "string"
197
+ },
198
+ "town": {
199
+ "maxLength": 250,
200
+ "type": "string"
201
+ }
202
+ },
203
+ "title": "company_address",
204
+ "type": "object"
205
+ },
206
+ "person": {
207
+ "additionalProperties": false,
208
+ "properties": {
209
+ "date_of_birth": {
210
+ "description": "Date with expected ISO 8601 format.",
211
+ "format": "date",
212
+ "type": "string"
213
+ },
214
+ "emails": {
215
+ "items": {
216
+ "additionalProperties": false,
217
+ "properties": {
218
+ "email": {
219
+ "description": "Contact email address with format user@example.com (ideally not a generic address such as info@...).",
220
+ "format": "email",
221
+ "maxLength": 254,
222
+ "type": "string"
223
+ },
224
+ "marketing_opt_in": {
225
+ "$ref": "#/definitions/marketing_opt_in"
226
+ },
227
+ "type": {
228
+ "enum": ["primary", "secondary"],
229
+ "type": "string"
230
+ }
231
+ },
232
+ "required": ["email"],
233
+ "type": "object"
234
+ },
235
+ "type": "array"
236
+ },
237
+ "first_name": {
238
+ "description": "Middle name is not required.",
239
+ "maxLength": 100,
240
+ "type": "string"
241
+ },
242
+ "how_did_you_find_us": {
243
+ "properties": {
244
+ "answer": {
245
+ "description": "Enum denoting where the customer heard about us.",
246
+ "enum": [
247
+ "letter",
248
+ "search_engine",
249
+ "friend_or_press",
250
+ "advisor",
251
+ "email",
252
+ "online_advert",
253
+ "phone_call",
254
+ "no_answer",
255
+ "train_or_bus_ad",
256
+ "radio"
257
+ ],
258
+ "type": "string"
259
+ },
260
+ "details": {
261
+ "description": "Additional Details.",
262
+ "maxLength": 50,
263
+ "type": "string"
264
+ }
265
+ },
266
+ "type": "object"
267
+ },
268
+ "last_name": {
269
+ "maxLength": 100,
270
+ "type": "string"
271
+ },
272
+ "monthly_business_income": {
273
+ "additionalProperties": false,
274
+ "description": "The person's personal income or takings from the business per month.",
275
+ "properties": {
276
+ "amount": {
277
+ "description": "Post-tax amount submitted by customer in local currency.",
278
+ "type": "number"
279
+ },
280
+ "valid_from": {
281
+ "description": "Datetime when user submitted data, with expected ISO 8601 format.",
282
+ "format": "date-time",
283
+ "type": "string"
284
+ }
285
+ },
286
+ "type": "object"
287
+ },
288
+ "monthly_non_business_income": {
289
+ "additionalProperties": false,
290
+ "description": "All income from other jobs, pension etc. Required for lending to sole traders.",
291
+ "properties": {
292
+ "amount": {
293
+ "description": "Post-tax amount submitted by customer in local currency.",
294
+ "type": "number"
295
+ },
296
+ "valid_from": {
297
+ "description": "Datetime when user submitted data, with expected ISO 8601 format.",
298
+ "format": "date-time",
299
+ "type": "string"
300
+ }
301
+ },
302
+ "type": "object"
303
+ },
304
+ "monthly_non_housing_expenses": {
305
+ "additionalProperties": false,
306
+ "description": "All essential personal expenses, apart from housing. For example, food, transport and other loan repayments. Required for lending to sole traders.",
307
+ "properties": {
308
+ "amount": {
309
+ "description": "Amount submitted by customer in local currency.",
310
+ "type": "number"
311
+ },
312
+ "valid_from": {
313
+ "description": "Datetime when user submitted data, with expected ISO 8601 format.",
314
+ "format": "date-time",
315
+ "type": "string"
316
+ }
317
+ },
318
+ "type": "object"
319
+ },
320
+ "monthly_other_household_income": {
321
+ "additionalProperties": false,
322
+ "description": "Total income from other members of the applicant's household such as their wife or husband. Does not include their own income.",
323
+ "properties": {
324
+ "amount": {
325
+ "type": "number"
326
+ },
327
+ "valid_from": {
328
+ "description": "Datetime when user submitted data, with expected ISO 8601 format.",
329
+ "format": "date-time",
330
+ "type": "string"
331
+ }
332
+ },
333
+ "type": "object"
334
+ },
335
+ "number_of_dependents": {
336
+ "additionalProperties": false,
337
+ "description": "Number of people that are financially dependent on the person (such as children or people in their care).",
338
+ "properties": {
339
+ "count": {
340
+ "type": "integer"
341
+ },
342
+ "valid_from": {
343
+ "description": "Datetime when user submitted data, with expected ISO 8601 format.",
344
+ "format": "date-time",
345
+ "type": "string"
346
+ }
347
+ },
348
+ "type": "object"
349
+ },
350
+ "phones": {
351
+ "items": {
352
+ "additionalProperties": false,
353
+ "description": "Contact phone numbers. It's preferable to have both a primary and secondary phone number for the applicant if available.",
354
+ "properties": {
355
+ "number": {
356
+ "description": "Quite flexible, can handle with/without country code, e.g. +447778473883 / 07778473883.",
357
+ "maxLength": 20,
358
+ "type": "string"
359
+ },
360
+ "type": {
361
+ "description": "The applicant must have at least one primary number.",
362
+ "enum": ["primary", "secondary"]
363
+ }
364
+ },
365
+ "required": ["number"],
366
+ "type": "object"
367
+ },
368
+ "type": "array"
369
+ },
370
+ "privacy_policy": {
371
+ "additionalProperties": false,
372
+ "description": "Required to retrieve an automated decision. This field denotes both that the customer agrees to the iwoca privacy policy AND that they have received reasonable, visible notice that iwoca will perform a soft credit check.",
373
+ "properties": {
374
+ "agreed": {
375
+ "description": "Specify whether the user has agreed to the iwoca privacy policy.",
376
+ "type": "boolean"
377
+ },
378
+ "valid_from": {
379
+ "description": "Datetime when they agreed or disagreed with the iwoca privacy policy, with expected ISO 8601 format.",
380
+ "format": "date-time",
381
+ "type": "string"
382
+ }
383
+ },
384
+ "type": "object"
385
+ },
386
+ "residential_addresses": {
387
+ "items": {
388
+ "$ref": "#/definitions/address"
389
+ },
390
+ "type": "array"
391
+ },
392
+ "roles": {
393
+ "description": "There should only be one applicant but there may be multiple people with the other roles.",
394
+ "items": {
395
+ "enum": [
396
+ "shareholder",
397
+ "applicant",
398
+ "director",
399
+ "guarantor",
400
+ "partner",
401
+ "other",
402
+ "beneficial_owner"
403
+ ],
404
+ "type": "string"
405
+ },
406
+ "type": "array"
407
+ },
408
+ "title": {
409
+ "enum": [
410
+ "mr",
411
+ "ms",
412
+ "mrs",
413
+ "miss",
414
+ "doctor",
415
+ "professor",
416
+ "sir",
417
+ "lord",
418
+ "lady",
419
+ "baron",
420
+ "baroness",
421
+ "rev",
422
+ "other"
423
+ ],
424
+ "type": "string"
425
+ },
426
+ "uid": {
427
+ "description": "Unique identifier created and stored by the partner which will allow you to retrieve/update this data in the future.",
428
+ "format": "uuid",
429
+ "type": "string"
430
+ }
431
+ },
432
+ "required": ["uid"],
433
+ "title": "person",
434
+ "type": "object"
435
+ },
436
+ "marketing_opt_in": {
437
+ "additionalProperties": false,
438
+ "properties": {
439
+ "agreed": {
440
+ "description": "Specify if user has opted in to receive marketing emails from iwoca.",
441
+ "type": "boolean"
442
+ },
443
+ "valid_from": {
444
+ "description": "Datetime when they opted in or out of marketing emails, with expected ISO 8601 format.",
445
+ "format": "date-time",
446
+ "type": "string"
447
+ }
448
+ },
449
+ "title": "marketing_opt_in",
450
+ "type": "object"
451
+ },
452
+ "address": {
453
+ "additionalProperties": false,
454
+ "properties": {
455
+ "country": {
456
+ "enum": ["GB", "DE", "OTHER"],
457
+ "maxLength": 5,
458
+ "type": "string"
459
+ },
460
+ "date_from": {
461
+ "description": "Date with expected ISO 8601 format, for example, '2016-10-23'. Optionally specify the date when they moved to this address. This date can be an estimate.",
462
+ "example": "2016-10-23",
463
+ "format": "date",
464
+ "type": "string"
465
+ },
466
+ "equifax_token": {
467
+ "description": "Equifax's PTCABS token. If you have access to this, providing it here could help us retrieve credit information more consistently.",
468
+ "maxLength": 250,
469
+ "type": "string"
470
+ },
471
+ "flat_number": {
472
+ "maxLength": 250,
473
+ "type": "string"
474
+ },
475
+ "house_name": {
476
+ "maxLength": 250,
477
+ "type": "string"
478
+ },
479
+ "house_number": {
480
+ "maxLength": 250,
481
+ "type": "string"
482
+ },
483
+ "monthly_housing_expenses": {
484
+ "additionalProperties": false,
485
+ "description": "Monthly cost of rent or mortgage, depending on residential status, at this address. Required for lending to sole traders.",
486
+ "properties": {
487
+ "amount": {
488
+ "type": "number"
489
+ },
490
+ "valid_from": {
491
+ "description": "Datetime when user submitted data, with expected ISO 8601 format.",
492
+ "format": "date-time",
493
+ "type": "string"
494
+ }
495
+ },
496
+ "type": "object"
497
+ },
498
+ "postcode": {
499
+ "maxLength": 250,
500
+ "type": "string"
501
+ },
502
+ "property_value": {
503
+ "additionalProperties": false,
504
+ "description": "Estimated value of house or flat specified by address.",
505
+ "properties": {
506
+ "amount": {
507
+ "description": "Amount in local currency.",
508
+ "type": "number"
509
+ },
510
+ "valid_from": {
511
+ "description": "Datetime when user submitted data, with expected ISO 8601 format.",
512
+ "format": "date-time",
513
+ "type": "string"
514
+ }
515
+ },
516
+ "type": "object"
517
+ },
518
+ "residential_status": {
519
+ "description": "The rent_free option covers situations where they are living in a property that they don't own but they are not paying rent (e.g. living with parents or family).",
520
+ "enum": ["tenant", "owner_with_mortgage", "owner_no_mortgage", "rent_free"],
521
+ "type": "string"
522
+ },
523
+ "street_line_1": {
524
+ "description": "The first line of the customer's address. For best results, this should include their flat or house name or number where possible.",
525
+ "maxLength": 250,
526
+ "type": "string"
527
+ },
528
+ "street_line_2": {
529
+ "description": "The second line of the customer's address. For best results, this should include their street number where possible and applicable.",
530
+ "maxLength": 250,
531
+ "type": "string"
532
+ },
533
+ "town": {
534
+ "maxLength": 250,
535
+ "type": "string"
536
+ }
537
+ },
538
+ "title": "address",
539
+ "type": "object"
540
+ }
541
+ }
542
+ }