instant_quote 1.7.27 → 1.7.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2424b2348486f6496409333dec6dd3a29aca9b3b9eb0c0c549808fdde325df29
4
- data.tar.gz: a5a04c34820b4415b7d15daafd21280e926f53da647179590d22cd829d6c340c
3
+ metadata.gz: 909beee5ce464d02860dd308450cce67e83eac2d62f0657209f1eac39c160c1e
4
+ data.tar.gz: fb8d70ff32018f9cc144cbcd9db4430b781cba2bc38b5b93a6baa338337f75c7
5
5
  SHA512:
6
- metadata.gz: b40aee9090963735341973ef33a4d6b2aa1601c782bcc181ec6cee777eaed3d4db8f66c35fa03e46a2d1b321403f909d886779f7b956e3b89f6717cf9eebad35
7
- data.tar.gz: 5cfba07e7046953a5e13081dda4e79c99585060c0679a73244bc19292f94898bdcfd501cf792f48dc23b7a01329462462f778ce5cd2418e9b30489bbb9e0f5b7
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.27)
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)
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,17 +159,16 @@ 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
166
- puts "Getting monthly interest rate..."
167
- puts "First offer: #{first_offer}"
168
- puts "Offers: #{@offers.inspect}"
169
166
  first_offer[:interest_rate]
170
167
  end
171
168
 
172
169
  def status
170
+ return STATUSES[:not_defined] unless @status
171
+
173
172
  @status[:status] || STATUSES[:not_defined]
174
173
  end
175
174
 
@@ -184,6 +183,8 @@ module InstantQuote
184
183
  end
185
184
 
186
185
  def status_included?(status, status_keys)
186
+ return false unless status
187
+
187
188
  statuses = status_keys.map { |key| STATUSES[key] }
188
189
  statuses.include?(status)
189
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.27'
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.27
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