unit_ruby_sdk 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/README.md +106 -79
- data/lib/unit/api_resources/stop_payment_resource.rb +48 -0
- data/lib/unit/models/application/application.rb +4 -9
- data/lib/unit/models/application/create_business_application_request.rb +3 -3
- data/lib/unit/models/application/create_sole_proprietor_application_request.rb +5 -18
- data/lib/unit/models/check_deposit/create_check_deposit_request.rb +1 -1
- data/lib/unit/models/customer/patch_business_customer_request.rb +1 -1
- data/lib/unit/models/customer/patch_individual_customer_request.rb +1 -1
- data/lib/unit/models/payment/payment.rb +2 -1
- data/lib/unit/models/recurring_payment/create_recurring_credit_book_payment_request.rb +1 -1
- data/lib/unit/models/stop_payment/create_stop_payment_request.rb +43 -0
- data/lib/unit/models/stop_payment/list_stop_payment_params.rb +63 -0
- data/lib/unit/models/stop_payment/stop_payment.rb +61 -0
- data/lib/unit/models/webhook/patch_webhook_request.rb +3 -3
- data/lib/unit/models/webhook/webhook.rb +6 -6
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +2 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dffd0552f07ada33b8cf7784a77ed1920c614648fd98279ec5df4a0556ea3c2
|
4
|
+
data.tar.gz: c825b344c162333143e63902e68b4c5bbdae064c6578d077de9b70b927699403
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fbb567aac32e7fa8e30673fef006bdb02584ebab67a414798ebcd027cf477e652ece5366a0c672317f0a9fd69389349640c160b237d4539f7b0f35c8c36ef41
|
7
|
+
data.tar.gz: affbc56b24a3182ddaf5f060a9dedc68f7c49b51213e683a6854a9a78a88e5e7f1a8e515cd250a031f6c8c6b00435b46833744f94b7b44d8ce12dbbab8e458ce
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -14,7 +14,8 @@ gem install unit_ruby_sdk
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
-
Bellow are a few usage examples of Unit's Ruby SDK. For full documentation of Unit's API please refer to the full
|
17
|
+
Bellow are a few usage examples of Unit's Ruby SDK. For full documentation of Unit's API please refer to the full
|
18
|
+
documentation at https://docs.unit.co/
|
18
19
|
|
19
20
|
### Creating a Business Application
|
20
21
|
|
@@ -53,10 +54,10 @@ contents = file.read
|
|
53
54
|
file.close
|
54
55
|
|
55
56
|
upload_document_request = Unit::Application.upload_document(
|
56
|
-
application_id: "836683",
|
57
|
-
document_id: "125214",
|
58
|
-
file: contents,
|
59
|
-
file_type: Unit::Types::DocumentFileType::PDF,
|
57
|
+
application_id: "836683",
|
58
|
+
document_id: "125214",
|
59
|
+
file: contents,
|
60
|
+
file_type: Unit::Types::DocumentFileType::PDF,
|
60
61
|
is_back_side: true)
|
61
62
|
|
62
63
|
puts upload_document_request.data["id"]
|
@@ -72,54 +73,56 @@ phone = Unit::Types::Phone.new('380', '555123222')
|
|
72
73
|
email = 'jone.doe@unit-finance.com'
|
73
74
|
ssn = '123456789'
|
74
75
|
trust_contact = Unit::Types::TrustContact.new(full_name, email, phone, address)
|
75
|
-
beneficiaries =
|
76
|
-
grantor =
|
76
|
+
beneficiaries = [Unit::Types::Beneficiary.new(full_name, date_of_birth).represent]
|
77
|
+
grantor = Unit::Types::Grantor.new(full_name, ssn, email, phone, address, date_of_birth)
|
77
78
|
trustees = [Unit::Types::Trustee.new(full_name, ssn, email, phone, address, date_of_birth).represent]
|
78
79
|
|
79
|
-
|
80
80
|
response = Unit::Application.create_trust_application(
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
81
|
+
name: "Trust me Inc.",
|
82
|
+
state_of_incorporation: "CA",
|
83
|
+
revocability: "Revocable",
|
84
|
+
source_of_funds: "Salary",
|
85
|
+
tax_id: "123456789",
|
86
|
+
grantor: grantor,
|
87
|
+
trustees: trustees,
|
88
|
+
beneficiaries: beneficiaries,
|
89
|
+
contact: trust_contact,
|
90
|
+
ip: "127.0.0.2",
|
91
|
+
tags: {
|
92
|
+
"userId": "106a75e9-de77-4e25-9561-faffe59d7814"
|
93
|
+
},
|
94
|
+
idempotency_key: "3a1a33be-4e12-4603-9ed0-820922389fb8")
|
95
95
|
|
96
96
|
trust_application = response.data
|
97
97
|
puts trust_application["id"]
|
98
98
|
```
|
99
99
|
|
100
100
|
### Creating a deposit account request
|
101
|
+
|
101
102
|
```ruby
|
102
103
|
relationships = { "customer": Unit::Types::Relationship.new("customer", "111009").to_hash }
|
103
104
|
response = Unit::Account::Deposit.create_deposit_account(
|
104
|
-
deposit_product: "checking",
|
105
|
-
tags: { "purpose": "checking" },
|
105
|
+
deposit_product: "checking",
|
106
|
+
tags: { "purpose": "checking" },
|
106
107
|
relationships: relationships)
|
107
108
|
deposit_account = response.data
|
108
109
|
puts deposit_account["id"]
|
109
110
|
```
|
110
111
|
|
111
112
|
### Creating a credit account request
|
113
|
+
|
112
114
|
```ruby
|
113
115
|
response = Unit::Account::Credit.create_credit_account(
|
114
|
-
credit_terms: "credit_terms_test",
|
115
|
-
credit_limit: 20_000,
|
116
|
-
customer_id: "851228",
|
116
|
+
credit_terms: "credit_terms_test",
|
117
|
+
credit_limit: 20_000,
|
118
|
+
customer_id: "851228",
|
117
119
|
tags: { "purpose": "tax" })
|
118
120
|
credit_account = response.data
|
119
121
|
puts credit_account["id"]
|
120
122
|
```
|
121
123
|
|
122
124
|
### Creating a batch release request
|
125
|
+
|
123
126
|
```ruby
|
124
127
|
requests =
|
125
128
|
[
|
@@ -128,10 +131,9 @@ requests =
|
|
128
131
|
]
|
129
132
|
response = Unit::Payment.create_batch_release(requests)
|
130
133
|
batch_release = response.data
|
131
|
-
puts batch_release[0]
|
134
|
+
puts batch_release[0]["id"]
|
132
135
|
```
|
133
136
|
|
134
|
-
|
135
137
|
### Fetching a Customer
|
136
138
|
|
137
139
|
```ruby
|
@@ -144,14 +146,14 @@ puts customer["id"]
|
|
144
146
|
```
|
145
147
|
|
146
148
|
### Creating a Payment
|
147
|
-
|
149
|
+
|
148
150
|
```ruby
|
149
151
|
require 'unit_ruby_sdk'
|
150
152
|
|
151
153
|
response = Unit::Payment.create_book_payment(
|
152
|
-
amount: 1000,
|
153
|
-
description: "test payment",
|
154
|
-
account_id: "27573",
|
154
|
+
amount: 1000,
|
155
|
+
description: "test payment",
|
156
|
+
account_id: "27573",
|
155
157
|
counterparty_account_id: "36981"
|
156
158
|
)
|
157
159
|
payment = response.data
|
@@ -174,11 +176,11 @@ response = Unit::Authorization.get_authorization(
|
|
174
176
|
include_non_authorized: true
|
175
177
|
)
|
176
178
|
authorization = response.data
|
177
|
-
puts authorization
|
179
|
+
puts authorization["id"]
|
178
180
|
```
|
179
181
|
|
180
|
-
|
181
182
|
### Creating an individual debit card
|
183
|
+
|
182
184
|
```ruby
|
183
185
|
response = Unit::Card.create_individual_debit_card(
|
184
186
|
account_id: '1234',
|
@@ -193,14 +195,17 @@ puts card["id"]
|
|
193
195
|
```
|
194
196
|
|
195
197
|
### Updating a received payment
|
198
|
+
|
196
199
|
```ruby
|
197
200
|
response = Unit::ReceivedPayment.update_payment(
|
198
|
-
payment_id: "1232",
|
201
|
+
payment_id: "1232",
|
199
202
|
tags: { purpose: "test" })
|
200
203
|
received_payment = response.data
|
201
204
|
puts received_payment["id"]
|
205
|
+
```
|
202
206
|
|
203
207
|
### Creating a business credit card
|
208
|
+
|
204
209
|
```ruby
|
205
210
|
full_name = Unit::Types::FullName.new('John', 'Doe')
|
206
211
|
date_of_birth = '1980-08-10'
|
@@ -208,18 +213,19 @@ address = Unit::Types::Address.new('123 Main St', 'San Francisco', 'CA', '94205'
|
|
208
213
|
phone = Unit::Types::Phone.new('380', '555123222')
|
209
214
|
email = 'jone.doe@unit-finance.com'
|
210
215
|
response = Unit::Card.create_business_credit_card(
|
211
|
-
account_id: "1234",
|
216
|
+
account_id: "1234",
|
212
217
|
full_name: full_name,
|
213
|
-
date_of_birth: date_of_birth,
|
214
|
-
address: address,
|
215
|
-
phone: phone,
|
218
|
+
date_of_birth: date_of_birth,
|
219
|
+
address: address,
|
220
|
+
phone: phone,
|
216
221
|
email: email
|
217
222
|
)
|
218
223
|
charge_card = response.data
|
219
|
-
puts charge_card
|
224
|
+
puts charge_card["id"]
|
220
225
|
```
|
221
226
|
|
222
227
|
### Creating a check deposit
|
228
|
+
|
223
229
|
```ruby
|
224
230
|
response = Unit::CheckDeposit.create_deposit(
|
225
231
|
account_id: account_id,
|
@@ -231,54 +237,57 @@ puts deposit["id"]
|
|
231
237
|
```
|
232
238
|
|
233
239
|
### Creating a counterparty with a plaid token
|
240
|
+
|
234
241
|
```ruby
|
235
242
|
response = Unit::Counterparty.create_with_plaid_token(
|
236
|
-
customer_id: "823139",
|
237
|
-
type: "Business",
|
238
|
-
name: "Jo Joel",
|
243
|
+
customer_id: "823139",
|
244
|
+
type: "Business",
|
245
|
+
name: "Jo Joel",
|
239
246
|
plaid_processor_token: "processor-sandbox-plaid-token")
|
240
247
|
|
241
248
|
counterparty = response.data
|
242
249
|
puts counterparty["id"]
|
243
250
|
```
|
244
251
|
|
245
|
-
|
246
252
|
### Creating a Payment to linked counterparty
|
253
|
+
|
247
254
|
```ruby
|
248
255
|
response = Unit::Payment.create_ach_payment_linked(
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
256
|
+
account_id: "123456",
|
257
|
+
counterparty_id: "56784",
|
258
|
+
amount: 1000,
|
259
|
+
direction: "Credit",
|
260
|
+
description: "test payment"
|
261
|
+
)
|
262
|
+
ach_payment = response.data
|
263
|
+
puts ach_payment["id"]
|
257
264
|
```
|
258
265
|
|
259
266
|
### Creating a recurring payment
|
267
|
+
|
260
268
|
```ruby
|
261
269
|
schedule = Unit::Types::CreateSchedule.new("Monthly", 3)
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
270
|
+
response = Unit::RecurringPayment.create_recurring_credit_book_payment(account_id: "27573", counterparty_id: "36099", amount: 1000,
|
271
|
+
description: "test payme", schedule: schedule)
|
272
|
+
recurring_payment = response.data
|
273
|
+
puts recurring_payment["id"]
|
266
274
|
```
|
267
275
|
|
268
|
-
|
269
276
|
### Creating a wire payment
|
277
|
+
|
270
278
|
```ruby
|
271
279
|
address = Unit::Types::Address.new('123 Main St', 'San Francisco', 'CA', '94205', 'US')
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
280
|
+
response = Unit::Payment.create_wire_payment(
|
281
|
+
account_id: "1234",
|
282
|
+
amount: 1000,
|
283
|
+
description: "test payment",
|
284
|
+
counterparty: Unit::Types::WireCounterparty.new("Jane Doe", "27573", "812345678", address))
|
285
|
+
wire_payment = response.data
|
286
|
+
puts wire_payment["id"]
|
279
287
|
```
|
280
288
|
|
281
289
|
### Get an event by id
|
290
|
+
|
282
291
|
```ruby
|
283
292
|
response = Unit::Event.get_event(event_id: "12605774")
|
284
293
|
event = response.data
|
@@ -286,6 +295,7 @@ puts event.id
|
|
286
295
|
```
|
287
296
|
|
288
297
|
### Creating a bulk payment
|
298
|
+
|
289
299
|
```ruby
|
290
300
|
address = Unit::Types::Address.new('123 Main St', 'San Francisco', 'CA', '94205', 'US')
|
291
301
|
wire_counterparty = Unit::Types::WireCounterparty.new("Jane Doe", "27573", "812345678", address)
|
@@ -302,21 +312,36 @@ bulk_payment = response.data
|
|
302
312
|
puts bulk_payment["id"]
|
303
313
|
```
|
304
314
|
|
315
|
+
### Creating a stop payment
|
316
|
+
|
317
|
+
```ruby
|
318
|
+
response = Unit::StopPayment.create_stop_payment(
|
319
|
+
account_id: "165432",
|
320
|
+
amount: 10_345,
|
321
|
+
check_number: "123456",
|
322
|
+
tags: { "test": "122" }
|
323
|
+
)
|
324
|
+
stop_payment = response.data
|
325
|
+
puts stop_payment["id"]
|
326
|
+
```
|
327
|
+
|
305
328
|
### Creating a book repayment
|
329
|
+
|
306
330
|
```ruby
|
307
331
|
response = Unit::Repayment.create_book_repayment(
|
308
332
|
account_id: "10001",
|
309
333
|
credit_account_id: "10002",
|
310
|
-
counterparty_account_id: "10003",
|
334
|
+
counterparty_account_id: "10003",
|
311
335
|
description: "test", amount: 100,
|
312
|
-
transaction_summary_override: "override",
|
313
|
-
tags: { purpose: "test" },
|
336
|
+
transaction_summary_override: "override",
|
337
|
+
tags: { purpose: "test" },
|
314
338
|
idempotency_key: "3a1a33be-4e12-4603-9ed0-820922389fb8")
|
315
339
|
book_repayment = response.data
|
316
340
|
puts book_repayment["id"]
|
317
341
|
```
|
318
342
|
|
319
343
|
### Creating a control agreement
|
344
|
+
|
320
345
|
```ruby
|
321
346
|
response = Unit::Account::DACA.activate_control_agreement(account_id: "1234")
|
322
347
|
control_agreement = response.data
|
@@ -324,22 +349,21 @@ puts control_agreement["id"]
|
|
324
349
|
```
|
325
350
|
|
326
351
|
### Get a check payment by id
|
352
|
+
|
327
353
|
```ruby
|
328
354
|
response = Unit::CheckPayment.get_payment(payment_id: "199")
|
329
355
|
check_payment = response.data
|
330
356
|
puts check_payment["id"]
|
331
357
|
```
|
332
|
-
### Logging Errors
|
333
|
-
|
334
|
-
### Handling Response
|
335
358
|
|
336
359
|
### Creating a webhook
|
360
|
+
|
337
361
|
```ruby
|
338
362
|
response = Unit::Webhook.create_webhook(
|
339
|
-
label: "some label",
|
363
|
+
label: "some label",
|
340
364
|
url: "https://webhook.site/81ee6b53-fde4-4b7d-85a0-0b6249a4488d",
|
341
|
-
token: "MyToken",
|
342
|
-
content_type: "Json",
|
365
|
+
token: "MyToken",
|
366
|
+
content_type: "Json",
|
343
367
|
delivery_mode: "AtLeastOnce",
|
344
368
|
include_resources: false,
|
345
369
|
subscription_type: "OnlyAuthorizationRequest")
|
@@ -348,20 +372,23 @@ puts webhook["id"]
|
|
348
372
|
```
|
349
373
|
|
350
374
|
### Creating a fee
|
375
|
+
|
351
376
|
```ruby
|
352
377
|
response = Unit::Fee.create_fee(
|
353
|
-
account_id: "27573",
|
354
|
-
amount: 12_345,
|
355
|
-
description: "test",
|
356
|
-
tags: { purpose: "test" },
|
378
|
+
account_id: "27573",
|
379
|
+
amount: 12_345,
|
380
|
+
description: "test",
|
381
|
+
tags: { purpose: "test" },
|
357
382
|
idempotency_key: "123"
|
358
383
|
)
|
359
384
|
fee = response.data
|
360
385
|
puts fee["id"]
|
361
386
|
```
|
362
387
|
|
388
|
+
### Logging Errors
|
363
389
|
|
364
390
|
### Handling Response
|
391
|
+
|
365
392
|
```ruby
|
366
393
|
require 'unit_ruby_sdk'
|
367
394
|
|
@@ -375,6 +402,6 @@ if response.instance_of?(Unit::UnitResponse)
|
|
375
402
|
# handle response
|
376
403
|
else
|
377
404
|
# handle error
|
378
|
-
response.errors.each{|error| puts error.title}
|
405
|
+
response.errors.each { |error| puts error.title }
|
379
406
|
end
|
380
407
|
```
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./base_resource"
|
4
|
+
require_relative "../utils/http_helper"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
# class for creating request for stop payments to Unit API and parsing responses
|
8
|
+
# @see https://docs.unit.co/stop-payments
|
9
|
+
module Unit
|
10
|
+
module Resource
|
11
|
+
class StopPaymentResource < Unit::Resource::BaseResource
|
12
|
+
class << self
|
13
|
+
# Create a stop payment by calling Unit's API
|
14
|
+
# @param request [CreateStopPaymentRequest]
|
15
|
+
# @return [UnitResponse, UnitError]
|
16
|
+
def create_payment(request)
|
17
|
+
payload = request.to_json_api
|
18
|
+
response = HttpHelper.post("#{api_url}/stop-payments", body: payload, headers: headers)
|
19
|
+
response_handler(response)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Get a stop payment by calling Unit's API
|
23
|
+
# @param payment_id [String]
|
24
|
+
# @return [UnitResponse, UnitError]
|
25
|
+
def get(payment_id)
|
26
|
+
response = HttpHelper.get("#{api_url}/stop-payments/#{payment_id}", headers: headers)
|
27
|
+
response_handler(response)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Get a list of stop payments by calling Unit's API
|
31
|
+
# @param params [ListStopPaymentParams]
|
32
|
+
# @return [UnitResponse, UnitError]
|
33
|
+
def list(params = nil)
|
34
|
+
response = HttpHelper.get("#{api_url}/stop-payments", params: params.to_hash, headers: headers)
|
35
|
+
response_handler(response)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Disable a stop payment by calling Unit's API
|
39
|
+
# @param payment_id [String]
|
40
|
+
# @return [UnitResponse, UnitError]
|
41
|
+
def disable_payment(payment_id)
|
42
|
+
response = HttpHelper.post("#{api_url}/stop-payments/#{payment_id}/disable", headers: headers)
|
43
|
+
response_handler(response)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -99,16 +99,12 @@ module Unit
|
|
99
99
|
# @param phone [Phone]
|
100
100
|
# @param email [String]
|
101
101
|
# @param sole_proprietorship [Boolean]
|
102
|
-
# @param industry [String]
|
103
102
|
# @param ssn [String] - optional
|
104
103
|
# @param passport [String] - optional
|
105
104
|
# @param ein [String] - optional
|
106
105
|
# @param dba [String] - optional
|
107
106
|
# @param power_of_attorney_agent [PowerOfAttorneyAgent] - optional
|
108
107
|
# @param evaluation_params [EvaluationParams] - optional
|
109
|
-
# @param occupation [String] - optional
|
110
|
-
# @param annual_income [String] - optional
|
111
|
-
# @param source_of_income [String] - optional
|
112
108
|
# @param annual_revenue [String] - optional
|
113
109
|
# @param number_of_employees [String] - optional
|
114
110
|
# @param business_vertical [String] - optional
|
@@ -120,13 +116,12 @@ module Unit
|
|
120
116
|
# @param jwt_subject [String] - optional
|
121
117
|
# @return [UnitResponse, UnitError]
|
122
118
|
def create_sole_proprietor_application(nationality:, full_name:, date_of_birth:, address:, phone:,
|
123
|
-
email:,
|
124
|
-
|
125
|
-
number_of_employees: nil, business_vertical: nil, website: nil, ip: nil, tags: nil,
|
119
|
+
email:, ssn: nil, passport: nil, ein: nil, dba: nil, power_of_attorney_agent: nil, evaluation_params: nil,
|
120
|
+
annual_revenue: nil, number_of_employees: nil, business_vertical: nil, website: nil, ip: nil, tags: nil,
|
126
121
|
idempotency_key: nil, device_fingerprints: nil, jwt_subject: nil, sole_proprietorship: true)
|
127
122
|
request = CreateSoleProprietorApplicationRequest.new(nationality, full_name, date_of_birth, address, phone,
|
128
|
-
email,
|
129
|
-
|
123
|
+
email, ssn, passport, ein, dba, power_of_attorney_agent, evaluation_params,
|
124
|
+
annual_revenue, number_of_employees,
|
130
125
|
business_vertical, website, ip, tags, idempotency_key,
|
131
126
|
device_fingerprints, jwt_subject, sole_proprietorship: sole_proprietorship)
|
132
127
|
Unit::Resource::ApplicationResource.create_application(request)
|
@@ -83,10 +83,10 @@ module Unit
|
|
83
83
|
ip: ip,
|
84
84
|
website: website,
|
85
85
|
tags: tags,
|
86
|
-
|
86
|
+
idempotencyKey: idempotency_key,
|
87
87
|
deviceFingerprints: device_fingerprints,
|
88
|
-
|
89
|
-
|
88
|
+
annualRevenue: annual_revenue,
|
89
|
+
numberOfEmployees: number_of_employees,
|
90
90
|
cashFlow: cash_flow,
|
91
91
|
yearOfIncorporation: year_of_incorporation,
|
92
92
|
countriesOfOperation: countries_of_operation&.join(","),
|
@@ -6,9 +6,9 @@ module Unit
|
|
6
6
|
module Application
|
7
7
|
class CreateSoleProprietorApplicationRequest
|
8
8
|
attr_reader :ssn, :passport, :nationality, :full_name, :date_of_birth,
|
9
|
-
:address, :phone, :email, :sole_proprietorship, :ein,
|
10
|
-
:dba, :power_of_attorney_agent, :evaluation_params,
|
11
|
-
:
|
9
|
+
:address, :phone, :email, :sole_proprietorship, :ein,
|
10
|
+
:dba, :power_of_attorney_agent, :evaluation_params,
|
11
|
+
:annual_revenue, :number_of_employees,
|
12
12
|
:business_vertical, :website, :ip, :tags, :idempotency_key,
|
13
13
|
:device_fingerprints, :jwt_subject
|
14
14
|
|
@@ -19,16 +19,12 @@ module Unit
|
|
19
19
|
# @param phone [Phone]
|
20
20
|
# @param email [String]
|
21
21
|
# @param sole_proprietorship [Boolean]
|
22
|
-
# @param industry [String]
|
23
22
|
# @param ssn [String] - optional
|
24
23
|
# @param passport [String] - optional
|
25
24
|
# @param ein [String] - optional
|
26
25
|
# @param dba [String] - optional
|
27
26
|
# @param power_of_attorney_agent [PowerOfAttorneyAgent] - optional
|
28
27
|
# @param evaluation_params [EvaluationParams] - optional
|
29
|
-
# @param occupation [String] - optional
|
30
|
-
# @param annual_income [String] - optional
|
31
|
-
# @param source_of_income [String] - optional
|
32
28
|
# @param annual_revenue [String] - optional
|
33
29
|
# @param number_of_employees [String] - optional
|
34
30
|
# @param business_vertical [String] - optional
|
@@ -39,9 +35,8 @@ module Unit
|
|
39
35
|
# @param device_fingerprints [Array<DeviceFingerprint>] - optional
|
40
36
|
# @param jwt_subject [String] - optional
|
41
37
|
def initialize(nationality, full_name, date_of_birth, address, phone,
|
42
|
-
email,
|
43
|
-
|
44
|
-
number_of_employees = nil, business_vertical = nil, website = nil, ip = nil, tags = nil,
|
38
|
+
email, ssn = nil, passport = nil, ein = nil, dba = nil, power_of_attorney_agent = nil, evaluation_params = nil,
|
39
|
+
annual_revenue = nil, number_of_employees = nil, business_vertical = nil, website = nil, ip = nil, tags = nil,
|
45
40
|
idempotency_key = nil, device_fingerprints = nil, jwt_subject = nil, sole_proprietorship: true)
|
46
41
|
@ssn = ssn
|
47
42
|
@passport = passport
|
@@ -53,13 +48,9 @@ module Unit
|
|
53
48
|
@email = email
|
54
49
|
@sole_proprietorship = sole_proprietorship
|
55
50
|
@ein = ein
|
56
|
-
@industry = industry
|
57
51
|
@dba = dba
|
58
52
|
@power_of_attorney_agent = power_of_attorney_agent
|
59
53
|
@evaluation_params = evaluation_params
|
60
|
-
@occupation = occupation
|
61
|
-
@annual_income = annual_income
|
62
|
-
@source_of_income = source_of_income
|
63
54
|
@annual_revenue = annual_revenue
|
64
55
|
@number_of_employees = number_of_employees
|
65
56
|
@business_vertical = business_vertical
|
@@ -86,13 +77,9 @@ module Unit
|
|
86
77
|
email: email,
|
87
78
|
soleProprietorship: sole_proprietorship,
|
88
79
|
ein: ein,
|
89
|
-
industry: industry,
|
90
80
|
dba: dba,
|
91
81
|
powerOfAttorneyAgent: power_of_attorney_agent&.represent,
|
92
82
|
evaluationParams: evaluation_params&.represent,
|
93
|
-
occupation: occupation,
|
94
|
-
annualIncome: annual_income,
|
95
|
-
sourceOfIncome: source_of_income,
|
96
83
|
annualRevenue: annual_revenue,
|
97
84
|
numberOfEmployees: number_of_employees,
|
98
85
|
businessVertical: business_vertical,
|
@@ -16,6 +16,7 @@ module Unit
|
|
16
16
|
autoload :BulkPaymentRequest, "unit/models/payment/bulk_payment_request"
|
17
17
|
autoload :CreateBatchReleaseRequest, "unit/models/payment/create_batch_release_request"
|
18
18
|
autoload :BatchReleaseRequestBuilder, "unit/models/payment/batch_release_request_builder"
|
19
|
+
|
19
20
|
class << self
|
20
21
|
# Create a new book payment by calling Unit's API
|
21
22
|
# @see https://docs.unit.co/book-payments#book-payments
|
@@ -201,6 +202,6 @@ module Unit
|
|
201
202
|
end
|
202
203
|
Unit::Resource::PaymentResource.create_batch_release(payload.to_hash)
|
203
204
|
end
|
204
|
-
|
205
|
+
end
|
205
206
|
end
|
206
207
|
end
|
@@ -35,7 +35,7 @@ module Unit
|
|
35
35
|
"amount": amount,
|
36
36
|
"description": description,
|
37
37
|
"schedule": schedule&.represent,
|
38
|
-
"
|
38
|
+
"transactionSummaryOverride": transaction_summary_override,
|
39
39
|
"idempotencyKey": idempotency_key,
|
40
40
|
"tags": tags
|
41
41
|
},
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create a stop payment
|
4
|
+
# @see https://docs.unit.co/stop-payments#create-stop-payment
|
5
|
+
module Unit
|
6
|
+
module StopPayment
|
7
|
+
class CreateStopPaymentRequest
|
8
|
+
attr_reader :account_id, :amount, :check_number, :tags, :idempotency_key
|
9
|
+
|
10
|
+
# @param account_id [String]
|
11
|
+
# @param amount [Integer]
|
12
|
+
# @param check_number [String]
|
13
|
+
# @param tags [Hash] - optional
|
14
|
+
# @param idempotency_key [String] - optional
|
15
|
+
def initialize(account_id, amount, check_number, tags = nil, idempotency_key = nil)
|
16
|
+
@account_id = account_id
|
17
|
+
@amount = amount
|
18
|
+
@check_number = check_number
|
19
|
+
@tags = tags
|
20
|
+
@idempotency_key = idempotency_key
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_json_api
|
24
|
+
payload = {
|
25
|
+
data: {
|
26
|
+
type: "stopPayment",
|
27
|
+
attributes: {
|
28
|
+
amount: amount,
|
29
|
+
checkNumber: check_number,
|
30
|
+
tags: tags,
|
31
|
+
idempotencyKey: idempotency_key
|
32
|
+
},
|
33
|
+
"relationships": {
|
34
|
+
"account": Unit::Types::Relationship.new("depositAccount", account_id).to_hash
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
payload[:data][:attributes].compact!
|
39
|
+
payload.to_json
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to list stop payments
|
4
|
+
# @see https://docs.unit.co/stop-payments#list-stop-payments
|
5
|
+
module Unit
|
6
|
+
module StopPayment
|
7
|
+
class ListStopPaymentParams
|
8
|
+
attr_reader :limit, :offset, :account_id, :customer_id, :tags, :sort,
|
9
|
+
:since, :_until, :status, :from_amount, :to_amount, :check_number, :include
|
10
|
+
|
11
|
+
# @param limit [Integer] - optional
|
12
|
+
# @param offset [Integer] - optional
|
13
|
+
# @param account_id [String] - optional
|
14
|
+
# @param customer_id [String] - optional
|
15
|
+
# @param tags [Hash] - optional
|
16
|
+
# @param sort [String] - optional
|
17
|
+
# @param since [String] - optional
|
18
|
+
# @param _until [String] - optional
|
19
|
+
# @param status [Array<String>] - optional
|
20
|
+
# @param from_amount [String] - optional
|
21
|
+
# @param to_amount [String] - optional
|
22
|
+
# @param check_number [String] - optional
|
23
|
+
# @param include [Array<String>] - optional
|
24
|
+
def initialize(limit = STOP_PAYMENT_LIMIT, offset = STOP_PAYMENT_OFFSET, account_id = nil,
|
25
|
+
customer_id = nil, tags = nil, sort = nil, since = nil, _until = nil, status = nil, from_amount = nil,
|
26
|
+
to_amount = nil, check_number = nil, include = nil)
|
27
|
+
@limit = limit
|
28
|
+
@offset = offset
|
29
|
+
@account_id = account_id
|
30
|
+
@customer_id = customer_id
|
31
|
+
@tags = tags
|
32
|
+
@sort = sort
|
33
|
+
@since = since
|
34
|
+
@until = _until
|
35
|
+
@status = status
|
36
|
+
@from_amount = from_amount
|
37
|
+
@to_amount = to_amount
|
38
|
+
@check_number = check_number
|
39
|
+
@include = include
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_hash
|
43
|
+
params = {
|
44
|
+
"page[limit]": limit,
|
45
|
+
"page[offset]": offset,
|
46
|
+
"filter[accountId]": account_id,
|
47
|
+
"filter[customerId]": customer_id,
|
48
|
+
"filter[tags]": tags,
|
49
|
+
"sort": sort,
|
50
|
+
"filter[since]": since,
|
51
|
+
"filter[until]": _until,
|
52
|
+
"filter[fromAmount]": from_amount,
|
53
|
+
"filter[toAmount]": to_amount,
|
54
|
+
"filter[checkNumber]": check_number,
|
55
|
+
"include": include&.join(",")
|
56
|
+
}
|
57
|
+
status&.each_with_index&.map do |val, index|
|
58
|
+
params.merge!({ "filter[status][#{index}]": val })
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module StopPayment
|
5
|
+
STOP_PAYMENT_LIMIT = 100
|
6
|
+
STOP_PAYMENT_OFFSET = 0
|
7
|
+
|
8
|
+
autoload :CreateStopPaymentRequest, "unit/models/stop_payment/create_stop_payment_request"
|
9
|
+
autoload :ListStopPaymentParams, "unit/models/stop_payment/list_stop_payment_params"
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# Create a stop payment
|
13
|
+
# @see https://docs.unit.co/stop-payments#create-stop-payment
|
14
|
+
# @param amount [Integer]
|
15
|
+
# @param check_number [String]
|
16
|
+
# @param tags [Hash] - optional
|
17
|
+
# @param idempotency_key [String] - optional
|
18
|
+
def create_stop_payment(account_id:, amount:, check_number:, tags: nil, idempotency_key: nil)
|
19
|
+
request = CreateStopPaymentRequest.new(account_id, amount, check_number, tags, idempotency_key)
|
20
|
+
Unit::Resource::StopPaymentResource.create_payment(request)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get a stop payment
|
24
|
+
# @see https://docs.unit.co/stop-payments#get-specific-stop-payment
|
25
|
+
# @param payment_id [String]
|
26
|
+
def get_payment(payment_id:)
|
27
|
+
Unit::Resource::StopPaymentResource.get(payment_id)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Request to list stop payments
|
31
|
+
# @see https://docs.unit.co/stop-payments#list-stop-payments
|
32
|
+
# @param limit [Integer] - optional
|
33
|
+
# @param offset [Integer] - optional
|
34
|
+
# @param account_id [String] - optional
|
35
|
+
# @param customer_id [String] - optional
|
36
|
+
# @param tags [Hash] - optional
|
37
|
+
# @param sort [String] - optional
|
38
|
+
# @param since [String] - optional
|
39
|
+
# @param _until [String] - optional
|
40
|
+
# @param status [Array<String>] - optional
|
41
|
+
# @param from_amount [String] - optional
|
42
|
+
# @param to_amount [String] - optional
|
43
|
+
# @param check_number [String] - optional
|
44
|
+
# @param include [Array<String>] - optional
|
45
|
+
def list_stop_payment(limit: STOP_PAYMENT_LIMIT, offset: STOP_PAYMENT_OFFSET, account_id: nil,
|
46
|
+
customer_id: nil, tags: nil, sort: nil, since: nil, _until: nil, status: nil,
|
47
|
+
from_amount: nil, to_amount: nil, check_number: nil, include: nil)
|
48
|
+
request = ListStopPaymentParams.new(limit, offset, account_id, customer_id, tags, sort, since, _until,
|
49
|
+
status, from_amount, to_amount, check_number, include)
|
50
|
+
Unit::Resource::StopPaymentResource.list(request)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Disable a stop payment
|
54
|
+
# @see https://docs.unit.co/stop-payments#disable-stop-payment
|
55
|
+
# @param payment_id [String]
|
56
|
+
def disable_stop_payment(payment_id:)
|
57
|
+
Unit::Resource::StopPaymentResource.disable_payment(payment_id)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -32,10 +32,10 @@ module Unit
|
|
32
32
|
attributes: {
|
33
33
|
label: label,
|
34
34
|
url: url,
|
35
|
-
|
35
|
+
contentType: content_type,
|
36
36
|
token: token,
|
37
|
-
|
38
|
-
|
37
|
+
includeResources: include_resources,
|
38
|
+
subscriptionType: subscription_type
|
39
39
|
}
|
40
40
|
}
|
41
41
|
}
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
module Unit
|
4
4
|
module Webhook
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
autoload :PatchWebhookRequest, "unit/models/webhook/patch_webhook_request"
|
5
|
+
WEBHOOK_LIMIT = 100
|
6
|
+
WEBHOOK_OFFSET = 0
|
7
|
+
autoload :CreateWebhookRequest, "unit/models/webhook/create_webhook_request"
|
8
|
+
autoload :ListWebhookParams, "unit/models/webhook/list_webhook_params"
|
9
|
+
autoload :PatchWebhookRequest, "unit/models/webhook/patch_webhook_request"
|
11
10
|
|
11
|
+
class << self
|
12
12
|
# Create a webhook
|
13
13
|
# @see https://docs.unit.co/webhooks#create-webhook
|
14
14
|
# @param label [String]
|
data/lib/unit/version.rb
CHANGED
data/lib/unit_ruby_sdk.rb
CHANGED
@@ -11,6 +11,7 @@ module Unit
|
|
11
11
|
autoload :Payment, "unit/models/payment/payment"
|
12
12
|
autoload :ReceivedPayment, "unit/models/received_payment/received_payment"
|
13
13
|
autoload :CheckPayment, "unit/models/check_payment/check_payment"
|
14
|
+
autoload :StopPayment, "unit/models/stop_payment/stop_payment"
|
14
15
|
autoload :Transaction, "unit/models/transaction/transaction"
|
15
16
|
autoload :Card, "unit/models/card/card"
|
16
17
|
autoload :Statement, "unit/models/statement/statement"
|
@@ -35,6 +36,7 @@ module Unit
|
|
35
36
|
autoload :AccountResource, "unit/api_resources/account_resource"
|
36
37
|
autoload :ApiTokenResource, "unit/api_resources/api_token_resource"
|
37
38
|
autoload :PaymentResource, "unit/api_resources/payment_resource"
|
39
|
+
autoload :StopPaymentResource, "unit/api_resources/stop_payment_resource"
|
38
40
|
autoload :ReceivedPaymentResource, "unit/api_resources/received_payment_resource"
|
39
41
|
autoload :CheckPaymentResource, "unit/api_resources/check_payment_resource"
|
40
42
|
autoload :TransactionResource, "unit/api_resources/transaction_resource"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unit_ruby_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Unit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot_rails
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/unit/api_resources/repayment_resource.rb
|
117
117
|
- lib/unit/api_resources/reward_resource.rb
|
118
118
|
- lib/unit/api_resources/statement_resource.rb
|
119
|
+
- lib/unit/api_resources/stop_payment_resource.rb
|
119
120
|
- lib/unit/api_resources/transaction_resource.rb
|
120
121
|
- lib/unit/api_resources/webhook_resource.rb
|
121
122
|
- lib/unit/errors/unit_error.rb
|
@@ -239,6 +240,9 @@ files:
|
|
239
240
|
- lib/unit/models/statement/get_pdf_by_id_request.rb
|
240
241
|
- lib/unit/models/statement/list_statement_params.rb
|
241
242
|
- lib/unit/models/statement/statement.rb
|
243
|
+
- lib/unit/models/stop_payment/create_stop_payment_request.rb
|
244
|
+
- lib/unit/models/stop_payment/list_stop_payment_params.rb
|
245
|
+
- lib/unit/models/stop_payment/stop_payment.rb
|
242
246
|
- lib/unit/models/transaction/get_transaction_params.rb
|
243
247
|
- lib/unit/models/transaction/list_transaction_params.rb
|
244
248
|
- lib/unit/models/transaction/patch_book_transaction_request.rb
|