instant_quote 1.1.5 → 1.1.6
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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/instant_quote/adapters/capital_on_tap.rb +12 -4
- data/lib/instant_quote/adapters/iwoca.rb +6 -1
- data/lib/instant_quote/api_error.rb +3 -1
- data/lib/instant_quote/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4ef4d0ea8516cb2964a5ffb767aab8312c50e4a1a0b00b6d4f93a3621e2018a
|
4
|
+
data.tar.gz: 6d2e7d83712d2f16cf3366642e5ff315adcac56b6d9a1d16479ff3e66ad68a9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71993a58586581d1fcdcc722fc89d418b00a78f27eb252f49e94626e3aea56d8089a22c5a4b5b4b20d0e1fea6cad4275e6f9f7c132e19de932c779572bd31f7b
|
7
|
+
data.tar.gz: 4b31a45177b8dda43fb31ec9d852ab16a4cc99a5c9cc22e0a40f335d6c463cddec2e6d3f242b4d7c023a61984d9b060fbd5a09f7d4dc18c50b7f0c2000845d19
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
instant_quote (1.1.
|
4
|
+
instant_quote (1.1.6)
|
5
5
|
activesupport
|
6
6
|
capital_on_tap
|
7
7
|
iwoca
|
@@ -96,7 +96,7 @@ GEM
|
|
96
96
|
simplecov-html (~> 0.11)
|
97
97
|
simplecov-html (0.12.2)
|
98
98
|
thread_safe (0.3.6)
|
99
|
-
tzinfo (1.2.
|
99
|
+
tzinfo (1.2.7)
|
100
100
|
thread_safe (~> 0.1)
|
101
101
|
unicode-display_width (1.6.1)
|
102
102
|
webmock (3.8.3)
|
@@ -50,9 +50,7 @@ module InstantQuote
|
|
50
50
|
response = ::CapitalOnTap::Application.create(params)
|
51
51
|
|
52
52
|
# CoT responses can be 200 OK but still have an error!
|
53
|
-
unless response.success? && !response.error
|
54
|
-
raise ApiError.new(data: response.body, error: response.error || 'Unknown API error')
|
55
|
-
end
|
53
|
+
raise_error(response) unless response.success? && !response.error
|
56
54
|
|
57
55
|
response.body.dig(:result)
|
58
56
|
end
|
@@ -75,7 +73,7 @@ module InstantQuote
|
|
75
73
|
def get_status(application_id)
|
76
74
|
response = ::CapitalOnTap::Application.status(application_id)
|
77
75
|
|
78
|
-
|
76
|
+
raise_error(response) unless response.success?
|
79
77
|
|
80
78
|
DecisionParsers::CapitalOnTap.new(response.body[:applicationStatus])
|
81
79
|
end
|
@@ -89,6 +87,16 @@ module InstantQuote
|
|
89
87
|
def get_approval(_application_id)
|
90
88
|
true
|
91
89
|
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def raise_error(response)
|
94
|
+
raise ApiError.new(
|
95
|
+
adapter: 'capital_on_tap',
|
96
|
+
data: response.body,
|
97
|
+
error: response.error || 'Unknown API error'
|
98
|
+
)
|
99
|
+
end
|
92
100
|
end
|
93
101
|
end
|
94
102
|
end
|
@@ -97,7 +97,12 @@ module InstantQuote
|
|
97
97
|
private
|
98
98
|
|
99
99
|
def raise_error(response)
|
100
|
-
raise ApiError.new(
|
100
|
+
raise ApiError.new(
|
101
|
+
adapter: 'iwoca',
|
102
|
+
data: response.data,
|
103
|
+
code: response.errors.first[:code],
|
104
|
+
error: response.errors.first[:detail]
|
105
|
+
)
|
101
106
|
end
|
102
107
|
end
|
103
108
|
end
|
@@ -2,14 +2,16 @@
|
|
2
2
|
|
3
3
|
module InstantQuote
|
4
4
|
class ApiError < StandardError
|
5
|
-
attr_accessor :error, :data
|
5
|
+
attr_accessor :error, :data, :code, :adapter
|
6
6
|
|
7
7
|
alias message error
|
8
8
|
alias to_s error
|
9
9
|
|
10
10
|
def initialize(params = {})
|
11
|
+
@adapter = params[:adapter]
|
11
12
|
@error = params[:error]
|
12
13
|
@data = params[:data] || {}
|
14
|
+
@code = params[:code]
|
13
15
|
|
14
16
|
# Delete the metaData key, because it's irrelevant and has long strings
|
15
17
|
@data.delete(:metaData) if @data.key?(:metaData)
|
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.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rikas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|