iwoca 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ {
2
+ "description": "Estimated revenue over the last 12 months. For a young business without a full year of revenue, revenue to date should be given.",
3
+ "properties": {
4
+ "amount": {
5
+ "description": "Amount submitted by customer in local currency or other estimate.",
6
+ "type": "number"
7
+ },
8
+ "valid_from": {
9
+ "description": "Datetime when user submitted data, with expected ISO 8601 format.",
10
+ "format": "date-time",
11
+ "type": "string"
12
+ },
13
+ "type": "object"
14
+ }
15
+ }
@@ -0,0 +1,80 @@
1
+ {
2
+ "description": "",
3
+ "properties": {
4
+ "amount": {
5
+ "format": "float",
6
+ "type": "number",
7
+ "x-nullable": true
8
+ },
9
+ "detailed_purpose": {
10
+ "description": "detailed_purpose is usually submitted if a purpose of other has been set.",
11
+ "type": "string",
12
+ "x-nullable": true
13
+ },
14
+ "duration": {
15
+ "properties": {
16
+ "amount": {
17
+ "format": "float",
18
+ "type": "number"
19
+ },
20
+ "unit": {
21
+ "enum": ["days", "months", "years"],
22
+ "type": "string"
23
+ }
24
+ },
25
+ "required": ["amount", "unit"],
26
+ "type": "object",
27
+ "x-nullable": true
28
+ },
29
+ "product_type": {
30
+ "$ref": "#/definitions/product_types"
31
+ },
32
+ "purpose": {
33
+ "$ref": "#/definitions/loan_purposes"
34
+ },
35
+ "urgency": {
36
+ "description": "Describes whether the customer needs the funding immediately (asap), over the next few weeks (weeks) or is simply looking to get approved for future use (future).",
37
+ "enum": ["asap", "weeks", "future_use", null],
38
+ "type": "string",
39
+ "x-nullable": true
40
+ }
41
+ },
42
+ "type": "object",
43
+ "definitions": {
44
+ "product_types": {
45
+ "enum": [
46
+ "flexi_loan",
47
+ "business_loan",
48
+ "iwocapay",
49
+ "cbils",
50
+ "flexi24",
51
+ "recovery_loan",
52
+ "revenue_based_loan",
53
+ null
54
+ ],
55
+ "type": "string",
56
+ "x-nullable": true
57
+ },
58
+ "loan_purposes": {
59
+ "description": "A purpose may not be submitted if the customer is simply looking to get approved for the future, rather than a specific need.",
60
+ "enum": [
61
+ "stock_purchase",
62
+ "bridging_loan",
63
+ "marketing",
64
+ "equipment_purchase",
65
+ "pay_bill",
66
+ "pay_staff",
67
+ "refinancing_debt",
68
+ "financing_client_order",
69
+ "pay_tax_bill",
70
+ "other",
71
+ null,
72
+ "recovery_loan_working_capital",
73
+ "recovery_loan_expansion_or_growth",
74
+ "recovery_loan_replacing_external_finance"
75
+ ],
76
+ "type": "string",
77
+ "x-nullable": true
78
+ }
79
+ }
80
+ }
data/lib/iwoca/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Iwoca
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
@@ -0,0 +1,102 @@
1
+ module Iwoca
2
+ # For more information about webhooks, see:
3
+ # https://iwoca.stoplight.io/docs/lapi-notifications/branches/2.0.0/ZG9jOjI4NzI5MTI5-webhooks-configuration
4
+ class Webhooks
5
+ def self.connection
6
+ @connection ||= Connection.new('notifications')
7
+ end
8
+
9
+ # Will return a payload that looks like this:
10
+ #
11
+ # {
12
+ # "data": {
13
+ # "webhook_url": "https://app.finpoint.co.uk/fast_lender_webhooks/iwoca_event",
14
+ # "webhook_secret_token": "cddafc72e1bca9b33d7ee922a95ae3fdcdf4f37c",
15
+ # "encryption_method": "sha256"
16
+ # }
17
+ # }
18
+ def self.configuration
19
+ connection.get('configuration/')
20
+ end
21
+
22
+ # Setup a webhook, the params is a payload that looks like this:
23
+ #
24
+ # {
25
+ # "data": {
26
+ # "regenerate_webhook_secret_token": true,
27
+ # "webhook_url": "string"
28
+ # }
29
+ # }
30
+ def self.update(config:)
31
+ connection.put('configuration/', config)
32
+ end
33
+
34
+ # Get a list of the possible event types
35
+ #
36
+ # {
37
+ # "data": {
38
+ # "webhook_event_types": [
39
+ # "approval_status_changed",
40
+ # "customer_funded",
41
+ # "application_offered",
42
+ # "application_declined",
43
+ # "application_deferred",
44
+ # "cashflow_added",
45
+ # "mca_context_changed",
46
+ # "bank_account_setup",
47
+ # "application_status_changed",
48
+ # "application_attributed"
49
+ # ]
50
+ # }
51
+ # }
52
+ def self.event_types
53
+ connection.get('webhook_event_types/')
54
+ end
55
+
56
+ def self.subscribe(event_types:)
57
+ json = { data: { subscriptions: [] }}
58
+
59
+ subscriptions = event_types.map do |event_type|
60
+ { webhook_event_type: event_type }
61
+ end
62
+
63
+ json[:data][:subscriptions] = subscriptions
64
+
65
+ connection.post('subscriptions/', json)
66
+ end
67
+
68
+ {
69
+ "data": {
70
+ "webhook_event_types": [
71
+ "approval_status_changed"
72
+ ]
73
+ }
74
+ }
75
+
76
+ def self.unsubscribe(event_types:)
77
+ json = {}
78
+ connection.delete('subscriptions/', json)
79
+ end
80
+
81
+ # Returns the active subscriptions in a payload like this:
82
+ # {
83
+ # "data": {
84
+ # "subscriptions": [
85
+ # { "webhook_event_type": "approval_status_changed", "url": null, "subscribed": true },
86
+ # { "webhook_event_type": "customer_funded", "url": null, "subscribed": true },
87
+ # { "webhook_event_type": "application_offered", "url": null, "subscribed": true },
88
+ # { "webhook_event_type": "application_declined", "url": null, "subscribed": true },
89
+ # { "webhook_event_type": "application_deferred", "url": null, "subscribed": true },
90
+ # { "webhook_event_type": "cashflow_added", "url": null, "subscribed": true },
91
+ # { "webhook_event_type": "mca_context_changed", "url": null, "subscribed": true },
92
+ # { "webhook_event_type": "bank_account_setup", "url": null, "subscribed": true },
93
+ # { "webhook_event_type": "application_status_changed", "url": null, "subscribed": true },
94
+ # { "webhook_event_type": "application_attributed", "url": null, "subscribed": true }
95
+ # ]
96
+ # }
97
+ # }
98
+ def self.subscriptions
99
+ connection.get('subscriptions/')
100
+ end
101
+ end
102
+ end
data/lib/iwoca.rb CHANGED
@@ -4,7 +4,10 @@ require 'iwoca/version'
4
4
  require 'iwoca/path_sanitizer'
5
5
  require 'iwoca/configuration'
6
6
  require 'iwoca/connection'
7
- require 'iwoca/quote'
7
+ require 'iwoca/customer'
8
+ require 'iwoca/application'
9
+ require 'iwoca/webhooks'
10
+ require 'rainbow'
8
11
 
9
12
  module Iwoca
10
13
  module_function
@@ -17,6 +20,18 @@ module Iwoca
17
20
  @connection ||= Connection.new
18
21
  end
19
22
 
23
+ def authentication_check
24
+ response = connection.get('/authentication_check/')
25
+
26
+ if response.success?
27
+ puts Rainbow("Authentication check successful: #{response.body.to_json}").green.bright
28
+ else
29
+ puts Rainbow("Authentication check failed: #{response.body.to_json}").red.bright
30
+ end
31
+
32
+ response.success?
33
+ end
34
+
20
35
  def configure
21
36
  yield(configuration)
22
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iwoca
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rikas
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-04 00:00:00.000000000 Z
11
+ date: 2023-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -28,44 +28,16 @@ dependencies:
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: faraday_middleware
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: multi_json
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
31
+ - - "~>"
60
32
  - !ruby/object:Gem::Version
61
- version: '0'
33
+ version: '2.7'
62
34
  type: :runtime
63
35
  prerelease: false
64
36
  version_requirements: !ruby/object:Gem::Requirement
65
37
  requirements:
66
- - - ">="
38
+ - - "~>"
67
39
  - !ruby/object:Gem::Version
68
- version: '0'
40
+ version: '2.7'
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: rainbow
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -81,153 +53,13 @@ dependencies:
81
53
  - !ruby/object:Gem::Version
82
54
  version: '0'
83
55
  - !ruby/object:Gem::Dependency
84
- name: bundler
56
+ name: json-schema
85
57
  requirement: !ruby/object:Gem::Requirement
86
58
  requirements:
87
59
  - - ">="
88
60
  - !ruby/object:Gem::Version
89
61
  version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: dotenv
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: faker
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'
125
- - !ruby/object:Gem::Dependency
126
- name: pry-byebug
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: rake
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '10.0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '10.0'
153
- - !ruby/object:Gem::Dependency
154
- name: rspec
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '3.0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '3.0'
167
- - !ruby/object:Gem::Dependency
168
- name: rubocop
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: rubocop-rspec
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- - !ruby/object:Gem::Dependency
196
- name: simplecov
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
- - !ruby/object:Gem::Dependency
210
- name: vcr
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - ">="
214
- - !ruby/object:Gem::Version
215
- version: '0'
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - ">="
221
- - !ruby/object:Gem::Version
222
- version: '0'
223
- - !ruby/object:Gem::Dependency
224
- name: webmock
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - ">="
228
- - !ruby/object:Gem::Version
229
- version: '0'
230
- type: :development
62
+ type: :runtime
231
63
  prerelease: false
232
64
  version_requirements: !ruby/object:Gem::Requirement
233
65
  requirements:
@@ -254,13 +86,19 @@ files:
254
86
  - bin/setup
255
87
  - iwoca.gemspec
256
88
  - lib/iwoca.rb
89
+ - lib/iwoca/application.rb
90
+ - lib/iwoca/application_generator.rb
257
91
  - lib/iwoca/configuration.rb
258
92
  - lib/iwoca/connection.rb
93
+ - lib/iwoca/customer.rb
259
94
  - lib/iwoca/customer_generator.rb
260
95
  - lib/iwoca/path_sanitizer.rb
261
- - lib/iwoca/quote.rb
262
96
  - lib/iwoca/response.rb
97
+ - lib/iwoca/schemas/customer_payload.json
98
+ - lib/iwoca/schemas/last_12_months_turnover.json
99
+ - lib/iwoca/schemas/requested_product.json
263
100
  - lib/iwoca/version.rb
101
+ - lib/iwoca/webhooks.rb
264
102
  - vcr_cassettes/approval_invalid.yml
265
103
  - vcr_cassettes/approval_valid.yml
266
104
  - vcr_cassettes/create_customer_invalid.yml
@@ -277,7 +115,7 @@ homepage: https://www.iwoca.com
277
115
  licenses: []
278
116
  metadata:
279
117
  homepage_uri: https://www.iwoca.com
280
- post_install_message:
118
+ post_install_message:
281
119
  rdoc_options: []
282
120
  require_paths:
283
121
  - lib
@@ -292,8 +130,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
292
130
  - !ruby/object:Gem::Version
293
131
  version: '0'
294
132
  requirements: []
295
- rubygems_version: 3.0.3
296
- signing_key:
133
+ rubygems_version: 3.3.7
134
+ signing_key:
297
135
  specification_version: 4
298
136
  summary: Iwoca API wrapper
299
137
  test_files: []
data/lib/iwoca/quote.rb DELETED
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Iwoca
4
- class Quote
5
- # The POST request should be used to create an iwoca account for the customer. It's always the
6
- # first endpoint and method you should call when submitting a new customer. It returns a
7
- # state_key used to identify the customer in all future requests. Almost all fields in the
8
- # State are optional since you can submit a partial application initially, then add or update
9
- # data over time (through the PUT method). Your iwoca contact will be able to give you details
10
- # on which fields are recommended to help us make a lending decision.
11
- def self.create_customer(params)
12
- Iwoca.connection.post('state/', params)
13
- end
14
-
15
- # The PUT request should be used to add or update data for a customer. Note that the entire
16
- # State should be submitted each time you use this endpoint, even if you are just updating a
17
- # few fields.
18
- def self.update_customer(state_key, params)
19
- Iwoca.connection.put("state/#{state_key}/", params)
20
- end
21
-
22
- # This method should be used when a decision needs to be made for a customer. It doesn't expect
23
- # any payload, all needed information should have been provided in the state of the customer.
24
- def self.approval(state_key)
25
- Iwoca.connection.post("approval_request/#{state_key}/")
26
- end
27
-
28
- # The GET request will return a one-time login link that the user can follow to get into
29
- # their iwoca account (on iwoca.co.uk) without entering a password.
30
- # You can generate multiple login links which will be active simultaneously. However, all
31
- # links will expire when the user next logs into their iwoca account (either by following one
32
- # of the links or by entering their username and password).
33
- def self.login_link(state_key)
34
- Iwoca.connection.get("login_link/#{state_key}/")
35
- end
36
-
37
- # The data returned contains information like approval status, loan status, repayments,
38
- # cashflows, ...
39
- def self.credit_facility_status(state_key)
40
- Iwoca.connection.get("credit_facility_status/#{state_key}")
41
- end
42
- end
43
- end