instant_quote 1.7.28 → 1.7.29

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: 584c0cc9a84109dbc9591e8b87959a2a4ade0b6362f7d15033107bf57d02a698
4
- data.tar.gz: a523501aec83fee0da738249ad3b54d00dd3c2788e3f4babed80eee2d3c9eaf0
3
+ metadata.gz: 909beee5ce464d02860dd308450cce67e83eac2d62f0657209f1eac39c160c1e
4
+ data.tar.gz: fb8d70ff32018f9cc144cbcd9db4430b781cba2bc38b5b93a6baa338337f75c7
5
5
  SHA512:
6
- metadata.gz: 56b95ebaea5f6cd5ac881ab1333d97b4128ee33e71e98436e7db9dc562fb93e09510f08bc27267b9b818b77feeba178f555790e266d0ff68deed031fdab43f9d
7
- data.tar.gz: e1aa7386c6becf37555c303a00b346f08e78fddcf4961071a9dbade5a512acb6b0ffed134642440597a8c1630b964b6983af7c7e00f7cd5856c89d8423ce6272
6
+ metadata.gz: edb69faea949be905d2d112bdc97fd50c4252694b0feee1b396fad1ff340d822063343d2a3ab5c4a757ec95ba715bf5140d909b05e5738c5cdb5e3d06d1e2291
7
+ data.tar.gz: 8ca5cb8aa26da747120ecca70777297fde443455f22131ea476ebf572b94898e9907f9f83a1400ab7d15d463731c369aa8eb66c57524d1b717caba518ec317e9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- instant_quote (1.7.28)
4
+ instant_quote (1.7.29)
5
5
  activesupport
6
6
  capital_on_tap (~> 1.0.1)
7
7
  iwoca (~> 1.1.0)
data/bin/console CHANGED
@@ -12,21 +12,21 @@ require 'capital_on_tap'
12
12
  require 'iwoca'
13
13
 
14
14
  CapitalOnTap.configure do |config|
15
- config.client_id = ENV['CAPITAL_ON_TAP_CLIENT_ID']
16
- config.client_secret = ENV['CAPITAL_ON_TAP_CLIENT_SECRET']
17
- config.username = ENV['CAPITAL_ON_TAP_USERNAME']
18
- config.password = ENV['CAPITAL_ON_TAP_PASSWORD']
15
+ config.client_id = ENV.fetch('CAPITAL_ON_TAP_CLIENT_ID')
16
+ config.client_secret = ENV.fetch('CAPITAL_ON_TAP_CLIENT_SECRET')
17
+ config.username = ENV.fetch('CAPITAL_ON_TAP_USERNAME')
18
+ config.password = ENV.fetch('CAPITAL_ON_TAP_PASSWORD')
19
19
  config.debug = true
20
20
  end
21
21
 
22
22
  Iwoca.configure do |config|
23
- config.api_key = ENV['IWOCA_API_KEY']
24
- config.webhook_signature = ENV['IWOCA_WEBHOOK_SIGNATURE']
23
+ config.api_key = ENV.fetch('IWOCA_API_KEY')
24
+ config.webhook_signature = ENV.fetch('IWOCA_WEBHOOK_SIGNATURE')
25
25
  end
26
26
 
27
27
  Youlend.configure do |config|
28
- config.client_id = ENV['YOULEND_CLIENT_ID']
29
- config.client_secret = ENV['YOULEND_CLIENT_SECRET']
28
+ config.client_id = ENV.fetch('YOULEND_CLIENT_ID')
29
+ config.client_secret = ENV.fetch('YOULEND_CLIENT_SECRET')
30
30
  config.debug = true
31
31
  end
32
32
 
@@ -39,7 +39,7 @@ I18n.locale = :en
39
39
  Money.locale_backend = :i18n
40
40
  Money.rounding_mode = BigDecimal::ROUND_HALF_EVEN
41
41
 
42
- def declined_v1_json
42
+ def declined_iwoca_v1_json
43
43
  json = '{
44
44
  "data": {
45
45
  "state_key": "[FILTERED]",
@@ -55,7 +55,7 @@ def declined_v1_json
55
55
  JSON.parse(json)
56
56
  end
57
57
 
58
- def approved_v1_json
58
+ def approved_iwoca_v1_json
59
59
  json = '{
60
60
  "data": {
61
61
  "state_key": "[FILTERED]",
@@ -68,12 +68,14 @@ module InstantQuote
68
68
  requests = params.dig(:data, :requests)
69
69
 
70
70
  # We can only send company and people
71
- response = ::Iwoca::Customer.create(data: {
71
+ response = ::Iwoca::Customer.create(
72
72
  data: {
73
- company: company,
74
- people: people
73
+ data: {
74
+ company: company,
75
+ people: people
76
+ }
75
77
  }
76
- })
78
+ )
77
79
 
78
80
  raise_error(response) unless response.success?
79
81
 
@@ -42,12 +42,10 @@ module InstantQuote
42
42
  def proceeds_purpose
43
43
  purpose = application.proceeds_purpose&.overview&.name
44
44
  case purpose
45
- when 'Invest in equipment or machinery'
45
+ when 'Invest in equipment or machinery' || 'Buy or refinance vehicle(s)'
46
46
  'equipment_purchase'
47
47
  when 'Refinance an existing loan'
48
48
  'refinancing_debt'
49
- when 'Buy or refinance vehicle(s)'
50
- 'equipment_purchase'
51
49
  else
52
50
  'other'
53
51
  end
@@ -55,8 +53,6 @@ module InstantQuote
55
53
 
56
54
  def product_name
57
55
  case connection.adapter
58
- when 'iwoca'
59
- 'flexi_loan'
60
56
  when 'iwoca_cbils'
61
57
  'cbils'
62
58
  when 'iwoca_revenue_based_loans'
@@ -100,11 +100,11 @@ module InstantQuote
100
100
  @data = super
101
101
 
102
102
  # Just in case (v1 has a lot of key 'data' nesting)
103
- @data = @data.dig(:data) if @data.key?(:data)
103
+ @data = @data[:data] if @data.key?(:data)
104
104
 
105
105
  # It's a v1 JSON response, so we need to translate it to v2 first!
106
- if @data.key?(:state_key) || @data.key?(:approval_status)
107
- puts "Translating v1 JSON to v2..."
106
+ if @data.key?(:state_key) || @data.key?(:approval_status) || @data.key?(:latest_approval_request)
107
+ puts '[iwoca] Translating v1 JSON to v2...'
108
108
  @data = DecisionParsers::IwocaV2Translator.translate(@data)
109
109
  end
110
110
 
@@ -159,7 +159,7 @@ module InstantQuote
159
159
  unit = suggested_product.dig(:duration, :unit)
160
160
  amount = suggested_product.dig(:duration, :amount)
161
161
 
162
- return { unit: unit, amount: amount }
162
+ { unit: unit, amount: amount }
163
163
  end
164
164
 
165
165
  def monthly_interest_rate
@@ -167,6 +167,8 @@ module InstantQuote
167
167
  end
168
168
 
169
169
  def status
170
+ return STATUSES[:not_defined] unless @status
171
+
170
172
  @status[:status] || STATUSES[:not_defined]
171
173
  end
172
174
 
@@ -181,6 +183,8 @@ module InstantQuote
181
183
  end
182
184
 
183
185
  def status_included?(status, status_keys)
186
+ return false unless status
187
+
184
188
  statuses = status_keys.map { |key| STATUSES[key] }
185
189
  statuses.include?(status)
186
190
  end
@@ -28,7 +28,7 @@ module InstantQuote
28
28
  duration: {
29
29
  unit: translate_interval(@decision.credit_interval),
30
30
  amount: @decision.credit_duration
31
- },
31
+ }
32
32
  }
33
33
  }
34
34
  ]
@@ -37,7 +37,7 @@ module InstantQuote
37
37
  {
38
38
  interest_rate: @decision.monthly_interest_rate
39
39
  }
40
- ],
40
+ ]
41
41
  }
42
42
  end
43
43
 
@@ -54,8 +54,6 @@ module InstantQuote
54
54
 
55
55
  def translate_interval(v1_interval)
56
56
  case v1_interval
57
- when '1m'
58
- 'months'
59
57
  when '1w'
60
58
  'weeks'
61
59
  when '1d'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InstantQuote
4
- VERSION = '1.7.28'
4
+ VERSION = '1.7.29'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instant_quote
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.28
4
+ version: 1.7.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - rikas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-07 00:00:00.000000000 Z
11
+ date: 2023-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport