instant_quote 1.7.28 → 1.7.30

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: 5e378f88afb60fc4375ff831bfface6efa8ed1d87cfa95078ac6ea82886c0537
4
+ data.tar.gz: e5d3106d56d34ce1ec62e8a98982cad963154e0a85c78c91af5f57cf75781b84
5
5
  SHA512:
6
- metadata.gz: 56b95ebaea5f6cd5ac881ab1333d97b4128ee33e71e98436e7db9dc562fb93e09510f08bc27267b9b818b77feeba178f555790e266d0ff68deed031fdab43f9d
7
- data.tar.gz: e1aa7386c6becf37555c303a00b346f08e78fddcf4961071a9dbade5a512acb6b0ffed134642440597a8c1630b964b6983af7c7e00f7cd5856c89d8423ce6272
6
+ metadata.gz: 83b3fea6ccb1a5727a0ba87a2a52596a3ad302e7f8a9c76fe81b165bf5f613129e561765022c99c3c72f9b575053c30a38bcaa4ee0ce52936697fb1ac0cb56c1
7
+ data.tar.gz: bb81f685834b6d5e32f3df5c894328466b935a02f18d800eeb6da7ef4f76f33784633753ef54dcdeddcbfa058fcedad4a6666dac404d84a3e4adb0ebbbb8f789
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.30)
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,16 +100,17 @@ 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
 
111
111
  @status = @data[:status] if @data.key?(:status)
112
112
  @offers = @data[:offers] if @data.key?(:offers)
113
+ @offers = @offers[:offers] if @offers.key?(:offers) # for some reason
113
114
  end
114
115
 
115
116
  def pending?
@@ -159,7 +160,7 @@ module InstantQuote
159
160
  unit = suggested_product.dig(:duration, :unit)
160
161
  amount = suggested_product.dig(:duration, :amount)
161
162
 
162
- return { unit: unit, amount: amount }
163
+ { unit: unit, amount: amount }
163
164
  end
164
165
 
165
166
  def monthly_interest_rate
@@ -167,6 +168,8 @@ module InstantQuote
167
168
  end
168
169
 
169
170
  def status
171
+ return STATUSES[:not_defined] unless @status
172
+
170
173
  @status[:status] || STATUSES[:not_defined]
171
174
  end
172
175
 
@@ -181,6 +184,8 @@ module InstantQuote
181
184
  end
182
185
 
183
186
  def status_included?(status, status_keys)
187
+ return false unless status
188
+
184
189
  statuses = status_keys.map { |key| STATUSES[key] }
185
190
  statuses.include?(status)
186
191
  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.30'
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.30
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-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport