instant_quote 1.7.24 → 1.7.26

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2a55ef0c8394b418534601643c4600bfe5eaf4557737024b5e7334f7bd31477
4
- data.tar.gz: c3798041fd702fc7920e5973e575f5468176e17e2ac6f4e7e218d7bbb35ecc08
3
+ metadata.gz: 1ec6c6b54ad7fcbae1c051dbcbbedcca488e333be4cc43d8e1fa9ae59e922718
4
+ data.tar.gz: 67d0eb7cfe1010ef0453a3432600c9d1fae69c9c2e415883cc3d4a3feeae9d8e
5
5
  SHA512:
6
- metadata.gz: e44b61c39dd92c15df4208d2a1272ef57adb2e8eb010ddfbc9035d71b522520702c9ca4635069f5690c7d60c0e02f09ce271089e566eeb4e2c236e3069d4f892
7
- data.tar.gz: d2ec83b794783ab108aa66532f37888b3793e8de1c7ccf3a84b7332a4546dbd253a7829d9c8c01e365daceb0d5f41fcb5cf5794ee576ad0e1b4acbf23debcacc
6
+ metadata.gz: 53b0606d174db814c57a5807b7dc6dccbf6a2db024b7e13e430eb4d1dea25f02a334b10a4b5b29cbcd23a881453ea73f794d9ff68c1ab558cf417516a96f4743
7
+ data.tar.gz: 4501ff4205734159be5c0007b2b6eb78067f89caabcda9d777c4ca4817e988ea4b9e91c00284676777b64d7616d4f10875f35454a0a8be5af24dbc7cb7d70bfb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- instant_quote (1.7.24)
4
+ instant_quote (1.7.26)
5
5
  activesupport
6
6
  capital_on_tap (~> 1.0.1)
7
7
  iwoca (~> 1.1.0)
@@ -58,16 +58,34 @@ module InstantQuote
58
58
  ]
59
59
 
60
60
  # Creates the iwoca customer and application and returns the customer_id from the response.
61
+ # The params come from the connection translator that returns 3 hashes:
62
+ # - company: The company information
63
+ # - people: The people information
64
+ # - requests: The requests information
61
65
  def get_quote(params, _connection)
62
- response = ::Iwoca::Customer.create(data: params)
66
+ company = params.dig(:data, :company)
67
+ people = params.dig(:data, :people)
68
+ requests = params.dig(:data, :requests)
69
+
70
+ # We can only send company and people
71
+ response = ::Iwoca::Customer.create(data: {
72
+ data: {
73
+ company: company,
74
+ people: people
75
+ }
76
+ })
63
77
 
64
78
  raise_error(response) unless response.success?
65
79
 
66
80
  customer_id = response.data[:customer_id]
67
81
 
82
+
68
83
  # This returns an application_id but we can't store it since we don't have more than one
69
84
  # external ID field. We shouldn't need it anyway.
70
- ::Iwoca::Application.create(customer_id: response.data[:customer_id], data: params)
85
+ ::Iwoca::Application.create(
86
+ customer_id: response.data[:customer_id],
87
+ data: { data: { requests: requests }}
88
+ )
71
89
 
72
90
  return customer_id if response.success?
73
91
 
@@ -8,12 +8,51 @@ module InstantQuote
8
8
  data: {
9
9
  company: company_information,
10
10
  people: [person_information],
11
+ requests: [
12
+ amount: application.amount_pennies / 100,
13
+ duration: { amount: 12, unit: 'months' },
14
+ purpose: proceeds_purpose,
15
+ product_type: product_name,
16
+ urgency: 'asap'
17
+ ]
11
18
  }
12
19
  }
13
20
  end
14
21
 
15
22
  private
16
23
 
24
+ # Maps the proceeds purpose to a valid value for iwoca.
25
+ # Possible iwoca values:
26
+ # - stock_purchase
27
+ # - bridging_loan
28
+ # - marketing
29
+ # - equipment_purchase
30
+ # - pay_bill
31
+ # - pay_staff
32
+ # - refinancing_debt
33
+ # - financing_client_order
34
+ # - pay_tax_bill
35
+ # - other
36
+ # - null
37
+ # - recovery_loan_working_capital
38
+ # - recovery_loan_expansion_or_growth
39
+ # - recovery_loan_replacing_external_finance
40
+ #
41
+ # TODO: There are a lot of proceeds purposes that we don't have a mapping for.
42
+ def proceeds_purpose
43
+ purpose = application.proceeds_purpose&.overview&.name
44
+ case purpose
45
+ when 'Invest in equipment or machinery'
46
+ 'equipment_purchase'
47
+ when 'Refinance an existing loan'
48
+ 'refinancing_debt'
49
+ when 'Buy or refinance vehicle(s)'
50
+ 'equipment_purchase'
51
+ else
52
+ 'other'
53
+ end
54
+ end
55
+
17
56
  def product_name
18
57
  case connection.adapter
19
58
  when 'iwoca'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InstantQuote
4
- VERSION = '1.7.24'
4
+ VERSION = '1.7.26'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instant_quote
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.24
4
+ version: 1.7.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - rikas