unit_ruby_sdk 1.4.1 → 2.0.0
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/.rubocop.yml +3 -0
- data/README.md +113 -93
- data/lib/unit/api_resources/cash_deposit_resource.rb +47 -0
- data/lib/unit/api_resources/check_payment_resource.rb +17 -0
- data/lib/unit/api_resources/stop_payment_resource.rb +48 -0
- data/lib/unit/api_resources/tax_form_resource.rb +39 -0
- data/lib/unit/models/application/application.rb +5 -38
- 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/cash_deposit/cash_deposit.rb +53 -0
- data/lib/unit/models/cash_deposit/generate_barcode_request.rb +37 -0
- data/lib/unit/models/cash_deposit/list_by_coordinates_params.rb +33 -0
- data/lib/unit/models/cash_deposit/list_by_postal_code_params.rb +33 -0
- data/lib/unit/models/check_deposit/create_check_deposit_request.rb +1 -1
- data/lib/unit/models/check_payment/check_payment.rb +25 -0
- data/lib/unit/models/check_payment/originate_check_payment_request.rb +57 -0
- 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/tax_form/list_tax_form_params.rb +37 -0
- data/lib/unit/models/tax_form/tax_form.rb +39 -0
- data/lib/unit/models/webhook/patch_webhook_request.rb +3 -3
- data/lib/unit/models/webhook/webhook.rb +6 -6
- data/lib/unit/types/check_payment_counterparty.rb +28 -0
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +7 -7
- data/tax_form_1.pdf +0 -0
- metadata +17 -8
- data/lib/unit/models/application/create_trust_application_request.rb +0 -67
- data/lib/unit/models/application/patch_trust_application_request.rb +0 -31
- data/lib/unit/types/beneficiary.rb +0 -25
- data/lib/unit/types/grantor.rb +0 -37
- data/lib/unit/types/trust_contact.rb +0 -34
- data/lib/unit/types/trustee.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f637ade0b91b546e19ba9dfcc469869673505646fd991e395c4693ec79ba9a7d
|
4
|
+
data.tar.gz: 5cde210d03a1e829bb1daa89b15ac35d6f80d1ff2e58a702d28de9736818bf82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03e714af1bd2b100d9f9188cf86f0ac5d85dd6280c354f0b2b8a85ed4db1d3f7668c1f851a93b88c29c2fda25e00c5f7ff2d76bda284d4e4921815f3ea638bc0
|
7
|
+
data.tar.gz: 3adb4378919434296c6a106ad05efc6d77aa2e1940b18c436f6f2b14de008ad8aa024db50d302cebafc5910cfc7658a807f8b7d4d8d972f14ba65fead350f2a6
|
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,73 +54,41 @@ 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"]
|
63
64
|
```
|
64
65
|
|
65
|
-
### Creating a trust application
|
66
|
-
|
67
|
-
```ruby
|
68
|
-
full_name = Unit::Types::FullName.new('John', 'Doe')
|
69
|
-
date_of_birth = '1980-08-10'
|
70
|
-
address = Unit::Types::Address.new('123 Main St', 'San Francisco', 'CA', '94205', 'US')
|
71
|
-
phone = Unit::Types::Phone.new('380', '555123222')
|
72
|
-
email = 'jone.doe@unit-finance.com'
|
73
|
-
ssn = '123456789'
|
74
|
-
trust_contact = Unit::Types::TrustContact.new(full_name, email, phone, address)
|
75
|
-
beneficiaries = [Unit::Types::Beneficiary.new(full_name, date_of_birth).represent]
|
76
|
-
grantor = Unit::Types::Grantor.new(full_name, ssn, email, phone, address, date_of_birth)
|
77
|
-
trustees = [Unit::Types::Trustee.new(full_name, ssn, email, phone, address, date_of_birth).represent]
|
78
|
-
|
79
|
-
|
80
|
-
response = Unit::Application.create_trust_application(
|
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
|
-
|
96
|
-
trust_application = response.data
|
97
|
-
puts trust_application["id"]
|
98
|
-
```
|
99
|
-
|
100
66
|
### Creating a deposit account request
|
67
|
+
|
101
68
|
```ruby
|
102
69
|
relationships = { "customer": Unit::Types::Relationship.new("customer", "111009").to_hash }
|
103
70
|
response = Unit::Account::Deposit.create_deposit_account(
|
104
|
-
deposit_product: "checking",
|
105
|
-
tags: { "purpose": "checking" },
|
71
|
+
deposit_product: "checking",
|
72
|
+
tags: { "purpose": "checking" },
|
106
73
|
relationships: relationships)
|
107
74
|
deposit_account = response.data
|
108
75
|
puts deposit_account["id"]
|
109
76
|
```
|
110
77
|
|
111
78
|
### Creating a credit account request
|
79
|
+
|
112
80
|
```ruby
|
113
81
|
response = Unit::Account::Credit.create_credit_account(
|
114
|
-
credit_terms: "credit_terms_test",
|
115
|
-
credit_limit: 20_000,
|
116
|
-
customer_id: "851228",
|
82
|
+
credit_terms: "credit_terms_test",
|
83
|
+
credit_limit: 20_000,
|
84
|
+
customer_id: "851228",
|
117
85
|
tags: { "purpose": "tax" })
|
118
86
|
credit_account = response.data
|
119
87
|
puts credit_account["id"]
|
120
88
|
```
|
121
89
|
|
122
90
|
### Creating a batch release request
|
91
|
+
|
123
92
|
```ruby
|
124
93
|
requests =
|
125
94
|
[
|
@@ -128,10 +97,9 @@ requests =
|
|
128
97
|
]
|
129
98
|
response = Unit::Payment.create_batch_release(requests)
|
130
99
|
batch_release = response.data
|
131
|
-
puts batch_release[0]
|
100
|
+
puts batch_release[0]["id"]
|
132
101
|
```
|
133
102
|
|
134
|
-
|
135
103
|
### Fetching a Customer
|
136
104
|
|
137
105
|
```ruby
|
@@ -144,14 +112,14 @@ puts customer["id"]
|
|
144
112
|
```
|
145
113
|
|
146
114
|
### Creating a Payment
|
147
|
-
|
115
|
+
|
148
116
|
```ruby
|
149
117
|
require 'unit_ruby_sdk'
|
150
118
|
|
151
119
|
response = Unit::Payment.create_book_payment(
|
152
|
-
amount: 1000,
|
153
|
-
description: "test payment",
|
154
|
-
account_id: "27573",
|
120
|
+
amount: 1000,
|
121
|
+
description: "test payment",
|
122
|
+
account_id: "27573",
|
155
123
|
counterparty_account_id: "36981"
|
156
124
|
)
|
157
125
|
payment = response.data
|
@@ -174,11 +142,11 @@ response = Unit::Authorization.get_authorization(
|
|
174
142
|
include_non_authorized: true
|
175
143
|
)
|
176
144
|
authorization = response.data
|
177
|
-
puts authorization
|
145
|
+
puts authorization["id"]
|
178
146
|
```
|
179
147
|
|
180
|
-
|
181
148
|
### Creating an individual debit card
|
149
|
+
|
182
150
|
```ruby
|
183
151
|
response = Unit::Card.create_individual_debit_card(
|
184
152
|
account_id: '1234',
|
@@ -193,14 +161,17 @@ puts card["id"]
|
|
193
161
|
```
|
194
162
|
|
195
163
|
### Updating a received payment
|
164
|
+
|
196
165
|
```ruby
|
197
166
|
response = Unit::ReceivedPayment.update_payment(
|
198
|
-
payment_id: "1232",
|
167
|
+
payment_id: "1232",
|
199
168
|
tags: { purpose: "test" })
|
200
169
|
received_payment = response.data
|
201
170
|
puts received_payment["id"]
|
171
|
+
```
|
202
172
|
|
203
173
|
### Creating a business credit card
|
174
|
+
|
204
175
|
```ruby
|
205
176
|
full_name = Unit::Types::FullName.new('John', 'Doe')
|
206
177
|
date_of_birth = '1980-08-10'
|
@@ -208,18 +179,19 @@ address = Unit::Types::Address.new('123 Main St', 'San Francisco', 'CA', '94205'
|
|
208
179
|
phone = Unit::Types::Phone.new('380', '555123222')
|
209
180
|
email = 'jone.doe@unit-finance.com'
|
210
181
|
response = Unit::Card.create_business_credit_card(
|
211
|
-
account_id: "1234",
|
182
|
+
account_id: "1234",
|
212
183
|
full_name: full_name,
|
213
|
-
date_of_birth: date_of_birth,
|
214
|
-
address: address,
|
215
|
-
phone: phone,
|
184
|
+
date_of_birth: date_of_birth,
|
185
|
+
address: address,
|
186
|
+
phone: phone,
|
216
187
|
email: email
|
217
188
|
)
|
218
189
|
charge_card = response.data
|
219
|
-
puts charge_card
|
190
|
+
puts charge_card["id"]
|
220
191
|
```
|
221
192
|
|
222
193
|
### Creating a check deposit
|
194
|
+
|
223
195
|
```ruby
|
224
196
|
response = Unit::CheckDeposit.create_deposit(
|
225
197
|
account_id: account_id,
|
@@ -231,29 +203,40 @@ puts deposit["id"]
|
|
231
203
|
```
|
232
204
|
|
233
205
|
### Creating a counterparty with a plaid token
|
206
|
+
|
234
207
|
```ruby
|
235
208
|
response = Unit::Counterparty.create_with_plaid_token(
|
236
|
-
customer_id: "823139",
|
237
|
-
type: "Business",
|
238
|
-
name: "Jo Joel",
|
209
|
+
customer_id: "823139",
|
210
|
+
type: "Business",
|
211
|
+
name: "Jo Joel",
|
239
212
|
plaid_processor_token: "processor-sandbox-plaid-token")
|
240
213
|
|
241
214
|
counterparty = response.data
|
242
215
|
puts counterparty["id"]
|
243
216
|
```
|
244
217
|
|
245
|
-
|
246
218
|
### Creating a Payment to linked counterparty
|
219
|
+
|
247
220
|
```ruby
|
248
221
|
response = Unit::Payment.create_ach_payment_linked(
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
222
|
+
account_id: "123456",
|
223
|
+
counterparty_id: "56784",
|
224
|
+
amount: 1000,
|
225
|
+
direction: "Credit",
|
226
|
+
description: "test payment"
|
227
|
+
)
|
228
|
+
ach_payment = response.data
|
229
|
+
puts ach_payment["id"]
|
230
|
+
```
|
231
|
+
|
232
|
+
### Creating a recurring payment
|
233
|
+
|
234
|
+
```ruby
|
235
|
+
schedule = Unit::Types::CreateSchedule.new("Monthly", 3)
|
236
|
+
response = Unit::RecurringPayment.create_recurring_credit_book_payment(account_id: "27573", counterparty_id: "36099", amount: 1000,
|
237
|
+
description: "test payme", schedule: schedule)
|
238
|
+
recurring_payment = response.data
|
239
|
+
puts recurring_payment["id"]
|
257
240
|
```
|
258
241
|
|
259
242
|
### Creating a recurring payment
|
@@ -262,23 +245,25 @@ puts counterparty["id"]
|
|
262
245
|
response = Unit::RecurringPayment.create_recurring_credit_book_payment(account_id: "27573", counterparty_id: "36099", amount: 1000,
|
263
246
|
description: "test payme", schedule: schedule)
|
264
247
|
recurring_payment = response.data
|
265
|
-
puts recurring_payment
|
248
|
+
puts recurring_payment.id
|
266
249
|
```
|
267
250
|
|
268
251
|
|
269
252
|
### Creating a wire payment
|
253
|
+
|
270
254
|
```ruby
|
271
255
|
address = Unit::Types::Address.new('123 Main St', 'San Francisco', 'CA', '94205', 'US')
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
256
|
+
response = Unit::Payment.create_wire_payment(
|
257
|
+
account_id: "1234",
|
258
|
+
amount: 1000,
|
259
|
+
description: "test payment",
|
260
|
+
counterparty: Unit::Types::WireCounterparty.new("Jane Doe", "27573", "812345678", address))
|
261
|
+
wire_payment = response.data
|
262
|
+
puts wire_payment["id"]
|
279
263
|
```
|
280
264
|
|
281
265
|
### Get an event by id
|
266
|
+
|
282
267
|
```ruby
|
283
268
|
response = Unit::Event.get_event(event_id: "12605774")
|
284
269
|
event = response.data
|
@@ -286,6 +271,7 @@ puts event.id
|
|
286
271
|
```
|
287
272
|
|
288
273
|
### Creating a bulk payment
|
274
|
+
|
289
275
|
```ruby
|
290
276
|
address = Unit::Types::Address.new('123 Main St', 'San Francisco', 'CA', '94205', 'US')
|
291
277
|
wire_counterparty = Unit::Types::WireCounterparty.new("Jane Doe", "27573", "812345678", address)
|
@@ -302,44 +288,75 @@ bulk_payment = response.data
|
|
302
288
|
puts bulk_payment["id"]
|
303
289
|
```
|
304
290
|
|
291
|
+
### Creating a stop payment
|
292
|
+
|
293
|
+
```ruby
|
294
|
+
response = Unit::StopPayment.create_stop_payment(
|
295
|
+
account_id: "165432",
|
296
|
+
amount: 10_345,
|
297
|
+
check_number: "123456",
|
298
|
+
tags: { "test": "122" }
|
299
|
+
)
|
300
|
+
stop_payment = response.data
|
301
|
+
puts stop_payment["id"]
|
302
|
+
```
|
303
|
+
|
305
304
|
### Creating a book repayment
|
305
|
+
|
306
306
|
```ruby
|
307
307
|
response = Unit::Repayment.create_book_repayment(
|
308
308
|
account_id: "10001",
|
309
309
|
credit_account_id: "10002",
|
310
|
-
counterparty_account_id: "10003",
|
310
|
+
counterparty_account_id: "10003",
|
311
311
|
description: "test", amount: 100,
|
312
|
-
transaction_summary_override: "override",
|
313
|
-
tags: { purpose: "test" },
|
312
|
+
transaction_summary_override: "override",
|
313
|
+
tags: { purpose: "test" },
|
314
314
|
idempotency_key: "3a1a33be-4e12-4603-9ed0-820922389fb8")
|
315
315
|
book_repayment = response.data
|
316
316
|
puts book_repayment["id"]
|
317
317
|
```
|
318
318
|
|
319
319
|
### Creating a control agreement
|
320
|
+
|
320
321
|
```ruby
|
321
322
|
response = Unit::Account::DACA.activate_control_agreement(account_id: "1234")
|
322
323
|
control_agreement = response.data
|
323
324
|
puts control_agreement["id"]
|
324
325
|
```
|
325
326
|
|
327
|
+
### Originate a check payment
|
328
|
+
|
329
|
+
```ruby
|
330
|
+
address = Unit::Types::Address.new('123 Main St', 'San Francisco', 'CA', '94205', 'US')
|
331
|
+
check_payment_counterparty = Unit::Types::CheckPaymentCounterparty.new("Jane Doe", address)
|
332
|
+
response = Unit::CheckPayment.originate_check_payment(
|
333
|
+
account_id: "123",
|
334
|
+
customer_id: "123",
|
335
|
+
customer_type: "individualCustomer",
|
336
|
+
amount: 100,
|
337
|
+
counterparty: check_payment_counterparty,
|
338
|
+
description: "test",
|
339
|
+
idempotency_key: "test")
|
340
|
+
check_payment = response.data
|
341
|
+
puts check_payment["id"]
|
342
|
+
```
|
343
|
+
|
326
344
|
### Get a check payment by id
|
345
|
+
|
327
346
|
```ruby
|
328
347
|
response = Unit::CheckPayment.get_payment(payment_id: "199")
|
329
348
|
check_payment = response.data
|
330
349
|
puts check_payment["id"]
|
331
350
|
```
|
332
|
-
### Logging Errors
|
333
|
-
|
334
|
-
### Handling Response
|
335
351
|
|
336
352
|
### Creating a webhook
|
353
|
+
|
337
354
|
```ruby
|
338
355
|
response = Unit::Webhook.create_webhook(
|
339
|
-
label: "some label",
|
356
|
+
label: "some label",
|
340
357
|
url: "https://webhook.site/81ee6b53-fde4-4b7d-85a0-0b6249a4488d",
|
341
|
-
token: "MyToken",
|
342
|
-
content_type: "Json",
|
358
|
+
token: "MyToken",
|
359
|
+
content_type: "Json",
|
343
360
|
delivery_mode: "AtLeastOnce",
|
344
361
|
include_resources: false,
|
345
362
|
subscription_type: "OnlyAuthorizationRequest")
|
@@ -348,20 +365,23 @@ puts webhook["id"]
|
|
348
365
|
```
|
349
366
|
|
350
367
|
### Creating a fee
|
368
|
+
|
351
369
|
```ruby
|
352
370
|
response = Unit::Fee.create_fee(
|
353
|
-
account_id: "27573",
|
354
|
-
amount: 12_345,
|
355
|
-
description: "test",
|
356
|
-
tags: { purpose: "test" },
|
371
|
+
account_id: "27573",
|
372
|
+
amount: 12_345,
|
373
|
+
description: "test",
|
374
|
+
tags: { purpose: "test" },
|
357
375
|
idempotency_key: "123"
|
358
376
|
)
|
359
377
|
fee = response.data
|
360
378
|
puts fee["id"]
|
361
379
|
```
|
362
380
|
|
381
|
+
### Logging Errors
|
363
382
|
|
364
383
|
### Handling Response
|
384
|
+
|
365
385
|
```ruby
|
366
386
|
require 'unit_ruby_sdk'
|
367
387
|
|
@@ -375,6 +395,6 @@ if response.instance_of?(Unit::UnitResponse)
|
|
375
395
|
# handle response
|
376
396
|
else
|
377
397
|
# handle error
|
378
|
-
response.errors.each{|error| puts error.title}
|
398
|
+
response.errors.each { |error| puts error.title }
|
379
399
|
end
|
380
400
|
```
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./base_resource"
|
4
|
+
require_relative "../utils/http_helper"
|
5
|
+
require "json"
|
6
|
+
# class for creating requests for cash deposits to Unit API and parsing responses
|
7
|
+
# @see https://unit.co/docs/api/payments/cash-deposits/
|
8
|
+
module Unit
|
9
|
+
module Resource
|
10
|
+
class CashDepositResource < Unit::Resource::BaseResource
|
11
|
+
class << self
|
12
|
+
# Generate a barcode for cash deposit
|
13
|
+
# @param request [GenerateBarcodeRequest]
|
14
|
+
# @return [UnitResponse, UnitError]
|
15
|
+
def generate_barcode(request)
|
16
|
+
payload = request.to_json_api
|
17
|
+
response = HttpHelper.post("#{api_url}/cash-deposits/barcodes", body: payload, headers: headers)
|
18
|
+
response_handler(response)
|
19
|
+
end
|
20
|
+
|
21
|
+
# List cash deposit store locations by coordinates
|
22
|
+
# @param request [ListByCoordinatesParams]
|
23
|
+
# @return [UnitResponse, UnitError]
|
24
|
+
def list_by_coordinates(params = nil)
|
25
|
+
response = HttpHelper.get("#{api_url}/store-locations", params: params&.to_hash, headers: headers)
|
26
|
+
response_handler(response)
|
27
|
+
end
|
28
|
+
|
29
|
+
# List cash deposit store locations by postal code
|
30
|
+
# @param request [ListByPostalCodeParams]
|
31
|
+
# @return [UnitResponse, UnitError]
|
32
|
+
def list_by_postal_code(params = nil)
|
33
|
+
response = HttpHelper.get("#{api_url}/store-locations", params: params.to_hash, headers: headers)
|
34
|
+
response_handler(response)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Get cash deposit image by barcode number
|
38
|
+
# @param barcode_number [String]
|
39
|
+
# @return [UnitResponse, UnitError]
|
40
|
+
def get_image_by_barcode_number(barcode_number)
|
41
|
+
response = HttpHelper.get("#{api_url}/cash-deposits/barcodes/#{barcode_number}/image", headers: headers, response_type: "image")
|
42
|
+
file_response_handler(response)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -10,6 +10,15 @@ module Unit
|
|
10
10
|
module Resource
|
11
11
|
class CheckPaymentResource < Unit::Resource::BaseResource
|
12
12
|
class << self
|
13
|
+
# Originate a check payment by calling Unit's API
|
14
|
+
# @param request [OriginateCheckPaymentRequest]
|
15
|
+
# @return [UnitResponse, UnitError]
|
16
|
+
def originate_payment(request)
|
17
|
+
payload = request.to_json_api
|
18
|
+
response = HttpHelper.post("#{api_url}/check-payments", body: payload, headers: headers)
|
19
|
+
response_handler(response)
|
20
|
+
end
|
21
|
+
|
13
22
|
# Get a check payment by id by calling Unit's API
|
14
23
|
# @param params [GetRequest]
|
15
24
|
# @return [UnitResponse, UnitError]
|
@@ -53,6 +62,14 @@ module Unit
|
|
53
62
|
response = HttpHelper.post("#{api_url}/check-payments/#{payment_id}/approve", body: payload, headers: headers)
|
54
63
|
response_handler(response)
|
55
64
|
end
|
65
|
+
|
66
|
+
# Cancel check payment
|
67
|
+
# @param payment_id [String]
|
68
|
+
# @return [UnitResponse, UnitError]
|
69
|
+
def cancel_payment(payment_id)
|
70
|
+
response = HttpHelper.post("#{api_url}/check-payments/#{payment_id}/cancel", headers: headers)
|
71
|
+
response_handler(response)
|
72
|
+
end
|
56
73
|
end
|
57
74
|
end
|
58
75
|
end
|
@@ -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
|
@@ -0,0 +1,39 @@
|
|
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 requests for statements to Unit API and parsing responses
|
8
|
+
# @see https://unit.co/docs/api/tax-forms/
|
9
|
+
module Unit
|
10
|
+
module Resource
|
11
|
+
class TaxFormResource < Unit::Resource::BaseResource
|
12
|
+
class << self
|
13
|
+
# Get tax_forms by calling Unit's API
|
14
|
+
# @param params [ListTaxFormParams]
|
15
|
+
# @return [UnitResponse, UnitError]
|
16
|
+
def list(params = nil)
|
17
|
+
response = HttpHelper.get("#{api_url}/tax-forms", params: params&.to_hash, headers: headers)
|
18
|
+
response_handler(response)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Get a tax form by id by calling Unit's API
|
22
|
+
# @param tax_form_id [String]
|
23
|
+
# @return [UnitResponse, UnitError]
|
24
|
+
def get_tax_form_by_id(tax_form_id)
|
25
|
+
response = HttpHelper.get("#{api_url}/tax-forms/#{tax_form_id}", headers: headers)
|
26
|
+
response_handler(response)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get a tax form pdf by id by calling Unit's API
|
30
|
+
# @param tax_form_id [String]
|
31
|
+
# @return [UnitResponse, UnitError]
|
32
|
+
def get_tax_form_pdf_by_id(tax_form_id)
|
33
|
+
response = HttpHelper.get("#{api_url}/tax-forms/#{tax_form_id}/pdf", headers: headers)
|
34
|
+
file_response_handler(response)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -10,8 +10,7 @@ module Unit
|
|
10
10
|
autoload :ListApplicationParams, "unit/models/application/list_application_params"
|
11
11
|
autoload :PatchApplicationRequest, "unit/models/application/patch_application_request"
|
12
12
|
autoload :UploadDocumentRequest, "unit/models/application/upload_document_request"
|
13
|
-
|
14
|
-
autoload :PatchTrustApplicationRequest, "unit/models/application/patch_trust_application_request"
|
13
|
+
|
15
14
|
class << self
|
16
15
|
# Create a new business application by calling Unit's API
|
17
16
|
# @see https://docs.unit.co/applications#create-business-application
|
@@ -99,16 +98,12 @@ module Unit
|
|
99
98
|
# @param phone [Phone]
|
100
99
|
# @param email [String]
|
101
100
|
# @param sole_proprietorship [Boolean]
|
102
|
-
# @param industry [String]
|
103
101
|
# @param ssn [String] - optional
|
104
102
|
# @param passport [String] - optional
|
105
103
|
# @param ein [String] - optional
|
106
104
|
# @param dba [String] - optional
|
107
105
|
# @param power_of_attorney_agent [PowerOfAttorneyAgent] - optional
|
108
106
|
# @param evaluation_params [EvaluationParams] - optional
|
109
|
-
# @param occupation [String] - optional
|
110
|
-
# @param annual_income [String] - optional
|
111
|
-
# @param source_of_income [String] - optional
|
112
107
|
# @param annual_revenue [String] - optional
|
113
108
|
# @param number_of_employees [String] - optional
|
114
109
|
# @param business_vertical [String] - optional
|
@@ -120,13 +115,12 @@ module Unit
|
|
120
115
|
# @param jwt_subject [String] - optional
|
121
116
|
# @return [UnitResponse, UnitError]
|
122
117
|
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,
|
118
|
+
email:, ssn: nil, passport: nil, ein: nil, dba: nil, power_of_attorney_agent: nil, evaluation_params: nil,
|
119
|
+
annual_revenue: nil, number_of_employees: nil, business_vertical: nil, website: nil, ip: nil, tags: nil,
|
126
120
|
idempotency_key: nil, device_fingerprints: nil, jwt_subject: nil, sole_proprietorship: true)
|
127
121
|
request = CreateSoleProprietorApplicationRequest.new(nationality, full_name, date_of_birth, address, phone,
|
128
|
-
email,
|
129
|
-
|
122
|
+
email, ssn, passport, ein, dba, power_of_attorney_agent, evaluation_params,
|
123
|
+
annual_revenue, number_of_employees,
|
130
124
|
business_vertical, website, ip, tags, idempotency_key,
|
131
125
|
device_fingerprints, jwt_subject, sole_proprietorship: sole_proprietorship)
|
132
126
|
Unit::Resource::ApplicationResource.create_application(request)
|
@@ -180,33 +174,6 @@ module Unit
|
|
180
174
|
request = UploadDocumentRequest.new(application_id, document_id, file, file_type, is_back_side: is_back_side)
|
181
175
|
Unit::Resource::ApplicationResource.upload(request)
|
182
176
|
end
|
183
|
-
|
184
|
-
# Create a trust application
|
185
|
-
# @see https://docs.unit.co/applications/#create-trust-application
|
186
|
-
# @param name [String]
|
187
|
-
# @param state_of_incorporation [String]
|
188
|
-
# @param revocability [String]
|
189
|
-
# @param source_of_funds [String]
|
190
|
-
# @param tax_id [String]
|
191
|
-
# @param grantor [Grantor]
|
192
|
-
# @param trustees [Array<Trustee>]
|
193
|
-
# @param beneficiaries [Array<Beneficiary>]
|
194
|
-
# @param contact [TrustContact]
|
195
|
-
# @param ip [String] - optional
|
196
|
-
# @param tags [Hash] - optional
|
197
|
-
# @param idempotency_key [String] - optional
|
198
|
-
# @param device_fingerprints [Array<DeviceFingerprint>] - optional
|
199
|
-
def create_trust_application(name:, state_of_incorporation:, revocability:, source_of_funds:, tax_id:,
|
200
|
-
grantor:, trustees:, beneficiaries:, contact:, ip: nil, tags: nil, idempotency_key: nil, device_fingerprints: nil)
|
201
|
-
request = CreateTrustApplicationRequest.new(name, state_of_incorporation, revocability, source_of_funds, tax_id,
|
202
|
-
grantor, trustees, beneficiaries, contact, ip, tags, idempotency_key, device_fingerprints)
|
203
|
-
Unit::Resource::ApplicationResource.create_application(request)
|
204
|
-
end
|
205
|
-
|
206
|
-
def update_trust_application(application_id:, tags: nil)
|
207
|
-
request = PatchTrustApplicationRequest.new(application_id, tags)
|
208
|
-
Unit::Resource::ApplicationResource.update(request)
|
209
|
-
end
|
210
177
|
end
|
211
178
|
end
|
212
179
|
end
|
@@ -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(","),
|