instant_quote 1.7.17 → 1.7.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -9
- data/lib/instant_quote/decision_parsers/iwoca_webhook.rb +112 -0
- data/lib/instant_quote/version.rb +1 -1
- data/lib/instant_quote/webhooks/iwoca.rb +18 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b94c442934e40507587cd652e9ec9683419ce66c75d2166e7ac8c5aef42fc52
|
4
|
+
data.tar.gz: 3f58db1c317c52cf60ab2b8ab18b7f70964621698eb867484c5cc9bca9270c63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e8d155b93561766d13ff661689591bdd6e76da37b3843e7e46bc800e7adfe6c662c6bd2cbe268b62d917e0bb8e150df9fede107d6252060bce2a860553a1fb5
|
7
|
+
data.tar.gz: 1d703f56473a6c3b3b851725ca36494c0e5c6fb1185d2460fcbd4f45f07403eb894c6807a97d9b474d553499d7b864f68726c7241859985a33b2504e1c9878bf
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
instant_quote (1.7.
|
4
|
+
instant_quote (1.7.19)
|
5
5
|
activesupport
|
6
6
|
capital_on_tap (~> 1.0.1)
|
7
7
|
iwoca (~> 1.1.0)
|
@@ -19,8 +19,8 @@ GEM
|
|
19
19
|
minitest (>= 5.1)
|
20
20
|
tzinfo (~> 2.0)
|
21
21
|
zeitwerk (~> 2.3)
|
22
|
-
addressable (2.
|
23
|
-
public_suffix (>= 2.0.2, <
|
22
|
+
addressable (2.8.5)
|
23
|
+
public_suffix (>= 2.0.2, < 6.0)
|
24
24
|
ast (2.4.2)
|
25
25
|
byebug (11.1.3)
|
26
26
|
capital_on_tap (1.0.1)
|
@@ -35,20 +35,20 @@ GEM
|
|
35
35
|
diff-lcs (1.4.4)
|
36
36
|
docile (1.3.5)
|
37
37
|
dotenv (2.7.6)
|
38
|
-
faraday (2.7.
|
38
|
+
faraday (2.7.10)
|
39
39
|
faraday-net_http (>= 2.0, < 3.1)
|
40
40
|
ruby2_keywords (>= 0.0.4)
|
41
41
|
faraday-net_http (3.0.2)
|
42
42
|
hashdiff (1.0.1)
|
43
43
|
i18n (1.10.0)
|
44
44
|
concurrent-ruby (~> 1.0)
|
45
|
-
iwoca (1.1.
|
45
|
+
iwoca (1.1.1)
|
46
46
|
addressable
|
47
47
|
faraday (~> 2.7)
|
48
48
|
json-schema
|
49
49
|
rainbow
|
50
|
-
json-schema (
|
51
|
-
addressable (>= 2.
|
50
|
+
json-schema (4.0.0)
|
51
|
+
addressable (>= 2.8)
|
52
52
|
method_source (1.0.0)
|
53
53
|
minitest (5.15.0)
|
54
54
|
money (6.16.0)
|
@@ -68,8 +68,8 @@ GEM
|
|
68
68
|
pry-byebug (3.9.0)
|
69
69
|
byebug (~> 11.0)
|
70
70
|
pry (~> 0.13.0)
|
71
|
-
public_suffix (
|
72
|
-
rainbow (3.
|
71
|
+
public_suffix (5.0.3)
|
72
|
+
rainbow (3.1.1)
|
73
73
|
rake (10.5.0)
|
74
74
|
regexp_parser (2.1.1)
|
75
75
|
rexml (3.2.4)
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module InstantQuote
|
4
|
+
module DecisionParsers
|
5
|
+
# Example response:
|
6
|
+
#
|
7
|
+
# { data:
|
8
|
+
# {
|
9
|
+
# balance: {
|
10
|
+
# principal: 0.0, interest: 0.0, product_fees: 0.0, other_fees: 0.0, total: 0.0
|
11
|
+
# },
|
12
|
+
# latest_approval_request: { status: "no_decision_possible" },
|
13
|
+
# approval_requirements: [
|
14
|
+
# { type: "cc", status: "required" },
|
15
|
+
# { type: "bus_cc", status: "required" },
|
16
|
+
# { type: "dir_guarantor", status: "required" },
|
17
|
+
# { type: "enhanced_security_check", status: "pending" }
|
18
|
+
# ],
|
19
|
+
# funding_requirements: [
|
20
|
+
# { status: "required", type: "fraud" },
|
21
|
+
# { type: "docs", status: "required" },
|
22
|
+
# { type: "enhanced_security_check", status: "pending" }
|
23
|
+
# ]
|
24
|
+
# }
|
25
|
+
# }
|
26
|
+
class IwocaWebhook < DecisionParser
|
27
|
+
STATUSES = {
|
28
|
+
pending: 'pending',
|
29
|
+
approved: 'approved',
|
30
|
+
declined: 'declined',
|
31
|
+
no_decision: 'no_decision_possible',
|
32
|
+
not_defined: 'not_defined'
|
33
|
+
}.freeze
|
34
|
+
|
35
|
+
LOAN_STATES = {
|
36
|
+
ongoing: 'ongoing',
|
37
|
+
ended: 'ended',
|
38
|
+
topup: 'topup',
|
39
|
+
pending: 'pending',
|
40
|
+
overdue: 'overdue',
|
41
|
+
duetoday: 'duetoday'
|
42
|
+
}.freeze
|
43
|
+
|
44
|
+
# iwoca sends an extra "data" key, that is removed here, to avoid having to do data[:data]
|
45
|
+
# because it's silly :)
|
46
|
+
def initialize(data = {})
|
47
|
+
@data = super
|
48
|
+
@data = @data[:data] if @data.key?(:data)
|
49
|
+
end
|
50
|
+
|
51
|
+
def pending?
|
52
|
+
status == STATUSES[:not_defined]
|
53
|
+
end
|
54
|
+
|
55
|
+
def approved?
|
56
|
+
status == STATUSES[:approved]
|
57
|
+
end
|
58
|
+
|
59
|
+
def declined?
|
60
|
+
status == STATUSES[:declined]
|
61
|
+
end
|
62
|
+
|
63
|
+
def manual_review?
|
64
|
+
status == STATUSES[:pending]
|
65
|
+
end
|
66
|
+
|
67
|
+
def no_decision_possible?
|
68
|
+
status == STATUSES[:no_decision]
|
69
|
+
end
|
70
|
+
|
71
|
+
def loan_started?
|
72
|
+
data[:loan_status] == LOAN_STATES[:ongoing]
|
73
|
+
end
|
74
|
+
|
75
|
+
def amount
|
76
|
+
amount_approved = status_hash.dig(:approved, :max_credit) || 0
|
77
|
+
|
78
|
+
Money.new(amount_approved * 100).format
|
79
|
+
end
|
80
|
+
|
81
|
+
def credit_duration
|
82
|
+
status_hash.dig(:approved, :duration)
|
83
|
+
end
|
84
|
+
|
85
|
+
def credit_interval
|
86
|
+
status_hash.dig(:approved, :interval)
|
87
|
+
end
|
88
|
+
|
89
|
+
def monthly_interest_rate
|
90
|
+
rates = status_hash.dig(:approved, :rate_structures)
|
91
|
+
|
92
|
+
return 0 unless rates&.any?
|
93
|
+
|
94
|
+
rate_info = rates.first[:rates]&.first
|
95
|
+
|
96
|
+
return 0 unless rate_info
|
97
|
+
|
98
|
+
rate_info[:rate]
|
99
|
+
end
|
100
|
+
|
101
|
+
def status
|
102
|
+
status_hash[:status] || STATUSES[:not_defined]
|
103
|
+
end
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
def status_hash
|
108
|
+
data[:approval_status] || data[:latest_approval_request] || {}
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -42,6 +42,24 @@ module InstantQuote
|
|
42
42
|
request.headers[SIGNATURE_HEADER]
|
43
43
|
end
|
44
44
|
|
45
|
+
# The list of possible event types is:
|
46
|
+
# approval_status_changed
|
47
|
+
# customer_funded
|
48
|
+
# application_offered
|
49
|
+
# application_declined
|
50
|
+
# application_deferred
|
51
|
+
# cashflow_added
|
52
|
+
# mca_context_changed
|
53
|
+
# bank_account_setup
|
54
|
+
# application_status_changed
|
55
|
+
# application_attributed
|
56
|
+
# indicative_offer_created
|
57
|
+
# shopify_payment_resolve
|
58
|
+
# shopify_payment_reject
|
59
|
+
# shopify_refund_resolve
|
60
|
+
#
|
61
|
+
# More info:
|
62
|
+
# https://iwoca.stoplight.io/docs/lapi-notifications/b59ca8c181611-get-available-webhook-event-types
|
45
63
|
def iwoca_event_type
|
46
64
|
# Allowed Values: approval_status_changed, instruct_payments, customer_funded
|
47
65
|
request.headers[EVENT_TYPE_HEADER]
|
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.
|
4
|
+
version: 1.7.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rikas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/instant_quote/decision_parsers/iwoca_flexi24.rb
|
159
159
|
- lib/instant_quote/decision_parsers/iwoca_recovery_loans.rb
|
160
160
|
- lib/instant_quote/decision_parsers/iwoca_revenue_based_loans.rb
|
161
|
+
- lib/instant_quote/decision_parsers/iwoca_webhook.rb
|
161
162
|
- lib/instant_quote/decision_parsers/optimum.rb
|
162
163
|
- lib/instant_quote/decision_parsers/youlend.rb
|
163
164
|
- lib/instant_quote/version.rb
|