instant_quote 1.1.2 → 1.1.7

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: 5ef7de39482768419b0f8fcceef1a519f9a6f59d806663f87855b112255fb901
4
- data.tar.gz: 365472c89d076772550acd39988412d8fc6a7501b0684d6a694a88e151802010
3
+ metadata.gz: 358724fb16cc0c89f578d0b59b1dc3b7f962af917986c46d8c77406cab783abf
4
+ data.tar.gz: 3cdff1f454bfdb1ac5637912ac0bf421671fcbadf33c98bc0d3533c4f981c054
5
5
  SHA512:
6
- metadata.gz: 7ba1a1214b4eb23a89b69f90f60195bf7f50d2d45f17b1727571f506dbc033513ec127c56ba18a5061fd93abb6df30b5952cf57bcf0ada33bdda091962fd43b8
7
- data.tar.gz: 655bec0c02d728f1e2f39ffa32decbad0754359ede1b60dcfa866b65509316cddc1d0e5ea3ded3b279b1e850b89f2b6d0508d26af472d18f1eececf730bf0a2d
6
+ metadata.gz: f3bb568804077b6526a0c39debbb36c39da156bbb158dd6e5f4ca32d59797aad9ab140aba3ee37955021196a833754e35281db9d26bf757ac080da991a077526
7
+ data.tar.gz: 8301b9bd8ce4c50f502e86b0a62faca488a35150a7ad247af3b3148004552c04e70c3c6febf31895bdba94e0c96316e70cf4214be0dd4b68113c26d47b4ab463
@@ -15,3 +15,12 @@ Metrics/BlockLength:
15
15
 
16
16
  Naming/AccessorMethodName:
17
17
  Enabled: false
18
+
19
+ Style/HashEachMethods:
20
+ Enabled: true
21
+
22
+ Style/HashTransformKeys:
23
+ Enabled: true
24
+
25
+ Style/HashTransformValues:
26
+ Enabled: true
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- instant_quote (1.1.2)
4
+ instant_quote (1.1.7)
5
5
  activesupport
6
6
  capital_on_tap
7
7
  iwoca
@@ -11,7 +11,7 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activesupport (6.0.2.1)
14
+ activesupport (6.0.2.2)
15
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
16
  i18n (>= 0.7, < 2)
17
17
  minitest (~> 5.1)
@@ -29,13 +29,16 @@ GEM
29
29
  rainbow
30
30
  coderay (1.1.2)
31
31
  concurrent-ruby (1.1.6)
32
+ crack (0.4.3)
33
+ safe_yaml (~> 1.0.0)
32
34
  diff-lcs (1.3)
33
35
  docile (1.3.2)
34
36
  dotenv (2.7.5)
35
- faraday (0.17.3)
37
+ faraday (1.0.1)
36
38
  multipart-post (>= 1.2, < 3)
37
- faraday_middleware (0.14.0)
38
- faraday (>= 0.7.4, < 1.0)
39
+ faraday_middleware (1.0.0)
40
+ faraday (~> 1.0)
41
+ hashdiff (1.0.1)
39
42
  i18n (1.8.2)
40
43
  concurrent-ruby (~> 1.0)
41
44
  iwoca (1.0.0)
@@ -45,54 +48,61 @@ GEM
45
48
  multi_json
46
49
  rainbow
47
50
  jaro_winkler (1.5.4)
48
- method_source (0.9.2)
51
+ method_source (1.0.0)
49
52
  minitest (5.14.0)
50
53
  money (6.13.7)
51
54
  i18n (>= 0.6.4, <= 2)
52
55
  multi_json (1.14.1)
53
56
  multipart-post (2.1.1)
54
57
  parallel (1.19.1)
55
- parser (2.7.0.2)
58
+ parser (2.7.0.5)
56
59
  ast (~> 2.4.0)
57
60
  phonelib (0.6.42)
58
- pry (0.12.2)
59
- coderay (~> 1.1.0)
60
- method_source (~> 0.9.0)
61
- pry-byebug (3.8.0)
61
+ pry (0.13.0)
62
+ coderay (~> 1.1)
63
+ method_source (~> 1.0)
64
+ pry-byebug (3.9.0)
62
65
  byebug (~> 11.0)
63
- pry (~> 0.10)
66
+ pry (~> 0.13.0)
64
67
  public_suffix (4.0.3)
65
68
  rainbow (3.0.0)
66
69
  rake (10.5.0)
70
+ rexml (3.2.4)
67
71
  rspec (3.9.0)
68
72
  rspec-core (~> 3.9.0)
69
73
  rspec-expectations (~> 3.9.0)
70
74
  rspec-mocks (~> 3.9.0)
71
75
  rspec-core (3.9.1)
72
76
  rspec-support (~> 3.9.1)
73
- rspec-expectations (3.9.0)
77
+ rspec-expectations (3.9.1)
74
78
  diff-lcs (>= 1.2.0, < 2.0)
75
79
  rspec-support (~> 3.9.0)
76
80
  rspec-mocks (3.9.1)
77
81
  diff-lcs (>= 1.2.0, < 2.0)
78
82
  rspec-support (~> 3.9.0)
79
83
  rspec-support (3.9.2)
80
- rubocop (0.79.0)
84
+ rubocop (0.80.1)
81
85
  jaro_winkler (~> 1.5.1)
82
86
  parallel (~> 1.10)
83
87
  parser (>= 2.7.0.1)
84
88
  rainbow (>= 2.2.2, < 4.0)
89
+ rexml
85
90
  ruby-progressbar (~> 1.7)
86
91
  unicode-display_width (>= 1.4.0, < 1.7)
87
92
  ruby-progressbar (1.10.1)
88
- simplecov (0.18.1)
93
+ safe_yaml (1.0.5)
94
+ simplecov (0.18.5)
89
95
  docile (~> 1.1)
90
- simplecov-html (~> 0.11.0)
91
- simplecov-html (0.11.0)
96
+ simplecov-html (~> 0.11)
97
+ simplecov-html (0.12.2)
92
98
  thread_safe (0.3.6)
93
- tzinfo (1.2.6)
99
+ tzinfo (1.2.7)
94
100
  thread_safe (~> 0.1)
95
101
  unicode-display_width (1.6.1)
102
+ webmock (3.8.3)
103
+ addressable (>= 2.3.6)
104
+ crack (>= 0.3.2)
105
+ hashdiff (>= 0.4.0, < 2.0.0)
96
106
  zeitwerk (2.3.0)
97
107
 
98
108
  PLATFORMS
@@ -107,6 +117,7 @@ DEPENDENCIES
107
117
  rspec (~> 3.0)
108
118
  rubocop
109
119
  simplecov
120
+ webmock
110
121
 
111
122
  BUNDLED WITH
112
123
  2.0.2
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'rspec', '~> 3.0'
34
34
  spec.add_development_dependency 'rubocop'
35
35
  spec.add_development_dependency 'simplecov'
36
+ spec.add_development_dependency 'webmock'
36
37
 
37
38
  spec.add_dependency 'activesupport'
38
39
  spec.add_dependency 'capital_on_tap'
@@ -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
- raise ApiError.new(data: response.body, error: response.error) unless response.success?
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
@@ -75,9 +75,9 @@ module InstantQuote
75
75
  def get_status(state_key)
76
76
  response = ::Iwoca::Quote.credit_facility_status(state_key)
77
77
 
78
- return response.data if response.success?
78
+ raise_error(response) unless response.success?
79
79
 
80
- raise_error(response)
80
+ DecisionParsers::Iwoca.new(response.body)
81
81
  end
82
82
 
83
83
  # Gets the URL for the given state key.
@@ -97,7 +97,12 @@ module InstantQuote
97
97
  private
98
98
 
99
99
  def raise_error(response)
100
- raise ApiError.new(data: response.data, error: response.errors.first[:detail])
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)
@@ -61,7 +61,7 @@ module InstantQuote
61
61
 
62
62
  return '' unless addr && addr != ''
63
63
 
64
- street_parts = [addr.line_1, addr.line_2, addr.line_3, addr.line_4]
64
+ street_parts = [addr.line_1, addr.line_2]
65
65
 
66
66
  {
67
67
  CountryCode: 'UK',
@@ -30,7 +30,7 @@ module InstantQuote
30
30
  end
31
31
 
32
32
  def amount
33
- Money.new(credit_decision[:approvalAmount].to_f * 1000).format
33
+ Money.new(credit_decision[:approvalAmount].to_f * 100).format
34
34
  end
35
35
 
36
36
  def monthly_interest_rate
@@ -45,7 +45,7 @@ module InstantQuote
45
45
  # because it's silly :)
46
46
  def initialize(data = {})
47
47
  @data = super
48
- @data = @data[:data] || {}
48
+ @data = @data[:data] if @data.key?(:data)
49
49
  end
50
50
 
51
51
  def pending?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InstantQuote
4
- VERSION = '1.1.2'
4
+ VERSION = '1.1.7'
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.1.2
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - rikas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-16 00:00:00.000000000 Z
11
+ date: 2020-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: activesupport
113
127
  requirement: !ruby/object:Gem::Requirement