unit_ruby_sdk 1.1.0 → 1.3.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/README.md +182 -20
- data/lib/unit/api_resources/account_resource.rb +24 -0
- data/lib/unit/api_resources/application_form_resource.rb +40 -0
- data/lib/unit/api_resources/authorization_request_resource.rb +49 -0
- data/lib/unit/api_resources/authorization_resource.rb +31 -0
- data/lib/unit/api_resources/card_resource.rb +8 -0
- data/lib/unit/api_resources/event_resource.rb +40 -0
- data/lib/unit/api_resources/fee_resource.rb +32 -0
- data/lib/unit/api_resources/institution_resource.rb +23 -0
- data/lib/unit/api_resources/payment_resource.rb +9 -0
- data/lib/unit/api_resources/received_payment_resource.rb +47 -0
- data/lib/unit/api_resources/recurring_payment_resource.rb +55 -0
- data/lib/unit/api_resources/repayment_resource.rb +41 -0
- data/lib/unit/api_resources/reward_resource.rb +41 -0
- data/lib/unit/api_resources/webhook_resource.rb +65 -0
- data/lib/unit/models/account/account.rb +25 -0
- data/lib/unit/models/account/deposit/create_deposit_account_request.rb +2 -1
- data/lib/unit/models/application/application.rb +98 -10
- data/lib/unit/models/application/create_business_application_request.rb +34 -13
- data/lib/unit/models/application/create_individual_application_request.rb +12 -8
- data/lib/unit/models/application/create_sole_proprietor_application_request.rb +113 -0
- data/lib/unit/models/application/create_trust_application_request.rb +67 -0
- data/lib/unit/models/application/patch_trust_application_request.rb +31 -0
- data/lib/unit/models/application_form/application_form.rb +43 -0
- data/lib/unit/models/application_form/create_application_form_request.rb +48 -0
- data/lib/unit/models/application_form/list_application_form_params.rb +30 -0
- data/lib/unit/models/authorization/authorization.rb +42 -0
- data/lib/unit/models/authorization/get_request.rb +22 -0
- data/lib/unit/models/authorization/list_request.rb +67 -0
- data/lib/unit/models/authorization_request/approve_request.rb +37 -0
- data/lib/unit/models/authorization_request/authorization_request.rb +55 -0
- data/lib/unit/models/authorization_request/decline_request.rb +31 -0
- data/lib/unit/models/authorization_request/list_authorization_params.rb +44 -0
- data/lib/unit/models/card/card.rb +102 -4
- data/lib/unit/models/card/create_business_credit_card_request.rb +29 -0
- data/lib/unit/models/card/create_business_debit_card_request.rb +10 -6
- data/lib/unit/models/card/create_business_virtual_credit_card_request.rb +25 -0
- data/lib/unit/models/card/create_business_virtual_debit_card_request.rb +10 -6
- data/lib/unit/models/card/create_individual_debit_card_request.rb +7 -3
- data/lib/unit/models/card/create_individual_virtual_card_request.rb +6 -3
- data/lib/unit/models/card/patch_business_card_request.rb +50 -0
- data/lib/unit/models/card/patch_business_credit_card_request.rb +22 -0
- data/lib/unit/models/card/patch_business_virtual_card_request.rb +43 -0
- data/lib/unit/models/card/patch_business_virtual_credit_card_request.rb +20 -0
- data/lib/unit/models/customer/list_customer_params.rb +4 -2
- data/lib/unit/models/event/event.rb +37 -0
- data/lib/unit/models/event/list_event_params.rb +37 -0
- data/lib/unit/models/fee/create_fee_request.rb +43 -0
- data/lib/unit/models/fee/fee.rb +34 -0
- data/lib/unit/models/fee/reverse_fee_request.rb +43 -0
- data/lib/unit/models/institution/institution.rb +14 -0
- data/lib/unit/models/payment/batch_release_request_builder.rb +21 -0
- data/lib/unit/models/payment/create_batch_release_request.rb +54 -0
- data/lib/unit/models/payment/payment.rb +21 -1
- data/lib/unit/models/received_payment/list_payment_params.rb +51 -0
- data/lib/unit/models/received_payment/patch_payment_request.rb +31 -0
- data/lib/unit/models/received_payment/received_payment.rb +54 -0
- data/lib/unit/models/recurring_payment/create_recurring_credit_ach_payment_request.rb +52 -0
- data/lib/unit/models/recurring_payment/create_recurring_credit_book_payment_request.rb +54 -0
- data/lib/unit/models/recurring_payment/create_recurring_debit_ach_payment_request.rb +60 -0
- data/lib/unit/models/recurring_payment/list_recurring_payment_params.rb +60 -0
- data/lib/unit/models/recurring_payment/recurring_payment.rb +106 -0
- data/lib/unit/models/repayment/create_ach_repayment_request.rb +57 -0
- data/lib/unit/models/repayment/create_book_repayment_request.rb +53 -0
- data/lib/unit/models/repayment/list_repayment_params.rb +48 -0
- data/lib/unit/models/repayment/repayment.rb +67 -0
- data/lib/unit/models/reward/create_reward_request.rb +49 -0
- data/lib/unit/models/reward/get_request.rb +22 -0
- data/lib/unit/models/reward/list_reward_params.rb +65 -0
- data/lib/unit/models/reward/reward.rb +55 -0
- data/lib/unit/models/unit_response.rb +1 -1
- data/lib/unit/models/webhook/create_webhook_request.rb +49 -0
- data/lib/unit/models/webhook/list_webhook_params.rb +39 -0
- data/lib/unit/models/webhook/patch_webhook_request.rb +47 -0
- data/lib/unit/models/webhook/webhook.rb +80 -0
- data/lib/unit/types/application_form_prefill.rb +84 -0
- data/lib/unit/types/application_form_settings_override.rb +51 -0
- data/lib/unit/types/beneficial_owner.rb +15 -10
- data/lib/unit/types/beneficiary.rb +25 -0
- data/lib/unit/types/create_schedule.rb +38 -0
- data/lib/unit/types/evaluation_params.rb +4 -4
- data/lib/unit/types/grantor.rb +37 -0
- data/lib/unit/types/officer.rb +26 -13
- data/lib/unit/types/power_of_attorney_agent.rb +5 -12
- data/lib/unit/types/require_id_verification.rb +29 -0
- data/lib/unit/types/trust_contact.rb +34 -0
- data/lib/unit/types/trustee.rb +37 -0
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +33 -0
- metadata +68 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 19b63ebda9542149ccda54951cd38604a8c3175879f3377893f3cd9e2d0acb02
|
|
4
|
+
data.tar.gz: ce345af67e8bd02d4f7970096600d5b694a052366a65ebf067afe4e343bd6818
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 14689b03dd416d25d6f97767429188301240645ea51dfda65e203051aa357c01f3c7181fe3436cea9fef4fc231c8fca71944f94b51726b581bb1d967152755a3
|
|
7
|
+
data.tar.gz: f93ecf9f33ece644fe9343ed583f34366db4437b1c2e1866718f4be7526c5546b85561915960352c803f33f170270a5ab08aa2df844f33647ac474039b3f5f0f
|
data/README.md
CHANGED
|
@@ -14,7 +14,7 @@ gem install unit_ruby_sdk
|
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Bellow are a few usage examples of Unit's Ruby SDK. For full documentation of Unit's API please refer to the full documentation at https://docs.unit.co/
|
|
18
18
|
|
|
19
19
|
### Creating a Business Application
|
|
20
20
|
|
|
@@ -40,13 +40,13 @@ response = Unit::Application.create_business_application(
|
|
|
40
40
|
industry: "Retail",
|
|
41
41
|
contact: Unit::Types::BusinessContact.new(full_name, email, phone),
|
|
42
42
|
officer: Unit::Types::Officer.new(full_name, date_of_birth, address, phone, email, ssn),
|
|
43
|
-
beneficial_owners: [beneficial_owner
|
|
43
|
+
beneficial_owners: [beneficial_owner],
|
|
44
44
|
entity_type: 'LLC'
|
|
45
45
|
)
|
|
46
46
|
|
|
47
47
|
application = response.data
|
|
48
48
|
|
|
49
|
-
puts application
|
|
49
|
+
puts application["id"]
|
|
50
50
|
|
|
51
51
|
file = File.open("./spec/test.pdf", "rb")
|
|
52
52
|
contents = file.read
|
|
@@ -59,7 +59,42 @@ upload_document_request = Unit::Application.upload_document(
|
|
|
59
59
|
file_type: Unit::Types::DocumentFileType::PDF,
|
|
60
60
|
is_back_side: true)
|
|
61
61
|
|
|
62
|
-
puts upload_document_request.data
|
|
62
|
+
puts upload_document_request.data["id"]
|
|
63
|
+
```
|
|
64
|
+
|
|
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"]
|
|
63
98
|
```
|
|
64
99
|
|
|
65
100
|
### Creating a deposit account request
|
|
@@ -70,7 +105,7 @@ response = Unit::Account::Deposit.create_deposit_account(
|
|
|
70
105
|
tags: { "purpose": "checking" },
|
|
71
106
|
relationships: relationships)
|
|
72
107
|
deposit_account = response.data
|
|
73
|
-
puts deposit_account
|
|
108
|
+
puts deposit_account["id"]
|
|
74
109
|
```
|
|
75
110
|
|
|
76
111
|
### Creating a credit account request
|
|
@@ -81,9 +116,22 @@ response = Unit::Account::Credit.create_credit_account(
|
|
|
81
116
|
customer_id: "851228",
|
|
82
117
|
tags: { "purpose": "tax" })
|
|
83
118
|
credit_account = response.data
|
|
84
|
-
puts credit_account
|
|
119
|
+
puts credit_account["id"]
|
|
85
120
|
```
|
|
86
121
|
|
|
122
|
+
### Creating a batch release request
|
|
123
|
+
```ruby
|
|
124
|
+
requests =
|
|
125
|
+
[
|
|
126
|
+
{ account_id: "49230", batch_account_id: "1296383", amount: 100, description: "Description 1", sender_name: "Sender Name 1", sender_address: ADDRESS, sender_account_number: "1234" },
|
|
127
|
+
{ account_id: "49230", batch_account_id: "1296383", amount: 100, description: "Description 1", sender_name: "Sender Name 1", sender_address: ADDRESS, sender_account_number: "12324" }
|
|
128
|
+
]
|
|
129
|
+
response = Unit::Payment.create_batch_release(requests)
|
|
130
|
+
batch_release = response.data
|
|
131
|
+
puts batch_release[0].id
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
|
|
87
135
|
### Fetching a Customer
|
|
88
136
|
|
|
89
137
|
```ruby
|
|
@@ -91,11 +139,10 @@ require 'unit_ruby_sdk'
|
|
|
91
139
|
|
|
92
140
|
Unit.config(api_url: ENV['API_URL'], token: ENV['TOKEN'])
|
|
93
141
|
|
|
94
|
-
customer = Unit::Customer.list_customers.first
|
|
95
|
-
puts customer
|
|
142
|
+
customer = Unit::Customer.list_customers(limit: 20, offset: 10).data.first
|
|
143
|
+
puts customer["id"]
|
|
96
144
|
```
|
|
97
145
|
|
|
98
|
-
###
|
|
99
146
|
### Creating a Payment
|
|
100
147
|
|
|
101
148
|
```ruby
|
|
@@ -108,7 +155,7 @@ response = Unit::Payment.create_book_payment(
|
|
|
108
155
|
counterparty_account_id: "36981"
|
|
109
156
|
)
|
|
110
157
|
payment = response.data
|
|
111
|
-
puts payment
|
|
158
|
+
puts payment["id"]
|
|
112
159
|
```
|
|
113
160
|
|
|
114
161
|
### Get a transaction by id
|
|
@@ -116,9 +163,21 @@ puts payment.id
|
|
|
116
163
|
```ruby
|
|
117
164
|
response = Unit::Transaction.get_transaction(transaction_id: '12345', account_id: '72345')
|
|
118
165
|
transaction = response.data
|
|
119
|
-
puts transaction
|
|
166
|
+
puts transaction["id"]
|
|
120
167
|
```
|
|
121
168
|
|
|
169
|
+
### Get an authorization by id
|
|
170
|
+
|
|
171
|
+
```ruby
|
|
172
|
+
response = Unit::Authorization.get_authorization(
|
|
173
|
+
authorization_id: '12345',
|
|
174
|
+
include_non_authorized: true
|
|
175
|
+
)
|
|
176
|
+
authorization = response.data
|
|
177
|
+
puts authorization.id
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
|
|
122
181
|
### Creating an individual debit card
|
|
123
182
|
```ruby
|
|
124
183
|
response = Unit::Card.create_individual_debit_card(
|
|
@@ -126,10 +185,38 @@ response = Unit::Card.create_individual_debit_card(
|
|
|
126
185
|
type: "depositAccount",
|
|
127
186
|
shipping_address: address,
|
|
128
187
|
design: "default",
|
|
129
|
-
additional_embossed_text: "Second Cardholder"
|
|
188
|
+
additional_embossed_text: "Second Cardholder",
|
|
189
|
+
expiry_date: "03/27"
|
|
130
190
|
)
|
|
131
191
|
card = response.data
|
|
132
|
-
puts card
|
|
192
|
+
puts card["id"]
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Updating a received payment
|
|
196
|
+
```ruby
|
|
197
|
+
response = Unit::ReceivedPayment.update_payment(
|
|
198
|
+
payment_id: "1232",
|
|
199
|
+
tags: { purpose: "test" })
|
|
200
|
+
received_payment = response.data
|
|
201
|
+
puts received_payment["id"]
|
|
202
|
+
|
|
203
|
+
### Creating a business credit card
|
|
204
|
+
```ruby
|
|
205
|
+
full_name = Unit::Types::FullName.new('John', 'Doe')
|
|
206
|
+
date_of_birth = '1980-08-10'
|
|
207
|
+
address = Unit::Types::Address.new('123 Main St', 'San Francisco', 'CA', '94205', 'US')
|
|
208
|
+
phone = Unit::Types::Phone.new('380', '555123222')
|
|
209
|
+
email = 'jone.doe@unit-finance.com'
|
|
210
|
+
response = Unit::Card.create_business_credit_card(
|
|
211
|
+
account_id: "1234",
|
|
212
|
+
full_name: full_name,
|
|
213
|
+
date_of_birth: date_of_birth,
|
|
214
|
+
address: address,
|
|
215
|
+
phone: phone,
|
|
216
|
+
email: email
|
|
217
|
+
)
|
|
218
|
+
charge_card = response.data
|
|
219
|
+
puts charge_card.id
|
|
133
220
|
```
|
|
134
221
|
|
|
135
222
|
### Creating a check deposit
|
|
@@ -140,7 +227,7 @@ response = Unit::CheckDeposit.create_deposit(
|
|
|
140
227
|
description: "test check deposit"
|
|
141
228
|
)
|
|
142
229
|
deposit = response.data
|
|
143
|
-
puts deposit
|
|
230
|
+
puts deposit["id"]
|
|
144
231
|
```
|
|
145
232
|
|
|
146
233
|
### Creating a counterparty with a plaid token
|
|
@@ -152,7 +239,7 @@ response = Unit::Counterparty.create_with_plaid_token(
|
|
|
152
239
|
plaid_processor_token: "processor-sandbox-plaid-token")
|
|
153
240
|
|
|
154
241
|
counterparty = response.data
|
|
155
|
-
puts counterparty
|
|
242
|
+
puts counterparty["id"]
|
|
156
243
|
```
|
|
157
244
|
|
|
158
245
|
|
|
@@ -166,9 +253,19 @@ puts counterparty.id
|
|
|
166
253
|
description: "test payment"
|
|
167
254
|
)
|
|
168
255
|
ach_payment = response.data
|
|
169
|
-
puts ach_payment
|
|
256
|
+
puts ach_payment["id"]
|
|
170
257
|
```
|
|
171
258
|
|
|
259
|
+
### Creating a recurring payment
|
|
260
|
+
```ruby
|
|
261
|
+
schedule = Unit::Types::CreateSchedule.new("Monthly", 3)
|
|
262
|
+
response = Unit::RecurringPayment.create_recurring_credit_book_payment(account_id: "27573", counterparty_id: "36099", amount: 1000,
|
|
263
|
+
description: "test payme", schedule: schedule)
|
|
264
|
+
recurring_payment = response.data
|
|
265
|
+
puts recurring_payment.id
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
|
|
172
269
|
### Creating a wire payment
|
|
173
270
|
```ruby
|
|
174
271
|
address = Unit::Types::Address.new('123 Main St', 'San Francisco', 'CA', '94205', 'US')
|
|
@@ -178,7 +275,14 @@ puts counterparty.id
|
|
|
178
275
|
description: "test payment",
|
|
179
276
|
counterparty: Unit::Types::WireCounterparty.new("Jane Doe", "27573", "812345678", address))
|
|
180
277
|
wire_payment = response.data
|
|
181
|
-
puts wire_payment
|
|
278
|
+
puts wire_payment["id"]
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Get an event by id
|
|
282
|
+
```ruby
|
|
283
|
+
response = Unit::Event.get_event(event_id: "12605774")
|
|
284
|
+
event = response.data
|
|
285
|
+
puts event.id
|
|
182
286
|
```
|
|
183
287
|
|
|
184
288
|
### Creating a bulk payment
|
|
@@ -195,10 +299,63 @@ ach_payment_plaid_token_request = Unit::Payment::CreateWithPlaidTokenRequest.new
|
|
|
195
299
|
response = Unit::Payment.create_bulk_payment(
|
|
196
300
|
requests: [book_payment_request, wire_payment_request, ach_payment_inline_request, ach_payment_linked_request, ach_payment_plaid_token_request])
|
|
197
301
|
bulk_payment = response.data
|
|
198
|
-
puts bulk_payment
|
|
302
|
+
puts bulk_payment["id"]
|
|
199
303
|
```
|
|
304
|
+
|
|
305
|
+
### Creating a book repayment
|
|
306
|
+
```ruby
|
|
307
|
+
response = Unit::Repayment.create_book_repayment(
|
|
308
|
+
account_id: "10001",
|
|
309
|
+
credit_account_id: "10002",
|
|
310
|
+
counterparty_account_id: "10003",
|
|
311
|
+
description: "test", amount: 100,
|
|
312
|
+
transaction_summary_override: "override",
|
|
313
|
+
tags: { purpose: "test" },
|
|
314
|
+
idempotency_key: "3a1a33be-4e12-4603-9ed0-820922389fb8")
|
|
315
|
+
book_repayment = response.data
|
|
316
|
+
puts book_repayment["id"]
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Creating a control agreement
|
|
320
|
+
```ruby
|
|
321
|
+
response = Unit::Account::DACA.activate_control_agreement(account_id: "1234")
|
|
322
|
+
control_agreement = response.data
|
|
323
|
+
puts control_agreement["id"]
|
|
324
|
+
```
|
|
325
|
+
|
|
200
326
|
### Logging Errors
|
|
201
327
|
|
|
328
|
+
### Handling Response
|
|
329
|
+
|
|
330
|
+
### Creating a webhook
|
|
331
|
+
```ruby
|
|
332
|
+
response = Unit::Webhook.create_webhook(
|
|
333
|
+
label: "some label",
|
|
334
|
+
url: "https://webhook.site/81ee6b53-fde4-4b7d-85a0-0b6249a4488d",
|
|
335
|
+
token: "MyToken",
|
|
336
|
+
content_type: "Json",
|
|
337
|
+
delivery_mode: "AtLeastOnce",
|
|
338
|
+
include_resources: false,
|
|
339
|
+
subscription_type: "OnlyAuthorizationRequest")
|
|
340
|
+
webhook = response.data
|
|
341
|
+
puts webhook["id"]
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### Creating a fee
|
|
345
|
+
```ruby
|
|
346
|
+
response = Unit::Fee.create_fee(
|
|
347
|
+
account_id: "27573",
|
|
348
|
+
amount: 12_345,
|
|
349
|
+
description: "test",
|
|
350
|
+
tags: { purpose: "test" },
|
|
351
|
+
idempotency_key: "123"
|
|
352
|
+
)
|
|
353
|
+
fee = response.data
|
|
354
|
+
puts fee["id"]
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
### Handling Response
|
|
202
359
|
```ruby
|
|
203
360
|
require 'unit_ruby_sdk'
|
|
204
361
|
|
|
@@ -207,6 +364,11 @@ Unit.config(api_url: ENV['API_URL'], token: "missing token")
|
|
|
207
364
|
# response is a Unit::UnitError
|
|
208
365
|
response = Unit::Application.get_application('123')
|
|
209
366
|
|
|
210
|
-
#
|
|
211
|
-
response.
|
|
367
|
+
# Checks the response to be an instance of UnitResponse
|
|
368
|
+
if response.instance_of?(Unit::UnitResponse)
|
|
369
|
+
# handle response
|
|
370
|
+
else
|
|
371
|
+
# handle error
|
|
372
|
+
response.errors.each{|error| puts error.title}
|
|
373
|
+
end
|
|
212
374
|
```
|
|
@@ -10,6 +10,30 @@ module Unit
|
|
|
10
10
|
module Resource
|
|
11
11
|
class AccountResource < Unit::Resource::BaseResource
|
|
12
12
|
class << self
|
|
13
|
+
# Enter a control agreement by calling Unit's API
|
|
14
|
+
# @param account_id [String]
|
|
15
|
+
# @return [UnitResponse, UnitError]
|
|
16
|
+
def enter_control_agreement(account_id)
|
|
17
|
+
response = HttpHelper.post("#{api_url}/accounts/#{account_id}/enter-daca", headers: headers)
|
|
18
|
+
response_handler(response)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Activate a control agreement by calling Unit's API
|
|
22
|
+
# @param account_id [String]
|
|
23
|
+
# @return [UnitResponse, UnitError]
|
|
24
|
+
def activate_control_agreement(account_id)
|
|
25
|
+
response = HttpHelper.post("#{api_url}/accounts/#{account_id}/activate-daca", headers: headers)
|
|
26
|
+
response_handler(response)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Deactivate a control agreement by calling Unit's API
|
|
30
|
+
# @param account_id [String]
|
|
31
|
+
# @return [UnitResponse, UnitError]
|
|
32
|
+
def deactivate_control_agreement(account_id)
|
|
33
|
+
response = HttpHelper.post("#{api_url}/accounts/#{account_id}/deactivate-daca", headers: headers)
|
|
34
|
+
response_handler(response)
|
|
35
|
+
end
|
|
36
|
+
|
|
13
37
|
# Create a new account by calling Unit's API
|
|
14
38
|
# @param request [CreateDepositAccountRequest] request
|
|
15
39
|
# @return [UnitResponse, UnitError]
|
|
@@ -0,0 +1,40 @@
|
|
|
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 application forms to Unit API and parsing responses
|
|
8
|
+
# @see https://docs.unit.co/application-forms
|
|
9
|
+
module Unit
|
|
10
|
+
module Resource
|
|
11
|
+
class ApplicationFormResource < Unit::Resource::BaseResource
|
|
12
|
+
class << self
|
|
13
|
+
# Create a new application form by calling Unit's API
|
|
14
|
+
# @param request [CreateApplicationFormRequest] request
|
|
15
|
+
# @return [UnitResponse, UnitError]
|
|
16
|
+
def create_application_form(request)
|
|
17
|
+
payload = request.to_json_api
|
|
18
|
+
response = HttpHelper.post("#{api_url}/application-forms", body: payload, headers: headers)
|
|
19
|
+
response_handler(response)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Get application form by calling Unit's API
|
|
23
|
+
# @param application_form_id [String]
|
|
24
|
+
# @return [UnitResponse, UnitError]
|
|
25
|
+
def get_application_form(application_form_id)
|
|
26
|
+
response = HttpHelper.get("#{api_url}/application-forms/#{application_form_id}", headers: headers)
|
|
27
|
+
response_handler(response)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# List application forms by calling Unit's API
|
|
31
|
+
# @param params [ListApplicationFormParams]
|
|
32
|
+
# @return [UnitResponse, UnitError]
|
|
33
|
+
def list_application_forms(params = nil)
|
|
34
|
+
response = HttpHelper.get("#{api_url}/application-forms", headers: headers, params: params.to_hash)
|
|
35
|
+
response_handler(response)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "./base_resource"
|
|
4
|
+
require_relative "../utils/http_helper"
|
|
5
|
+
|
|
6
|
+
# class for creating cards authorization requests
|
|
7
|
+
# @see https://docs.unit.co/cards-authorization-requests
|
|
8
|
+
|
|
9
|
+
module Unit
|
|
10
|
+
module Resource
|
|
11
|
+
class AuthorizationRequestResource < Unit::Resource::BaseResource
|
|
12
|
+
class << self
|
|
13
|
+
# Get authorization request by calling Unit's API
|
|
14
|
+
# @param request_id [String]
|
|
15
|
+
# @return [UnitResponse, UnitError]
|
|
16
|
+
def get_authorization_request(request_id)
|
|
17
|
+
response = HttpHelper.get("#{api_url}/authorization-requests/#{request_id}", headers: headers)
|
|
18
|
+
response_handler(response)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# List authorization requests by calling Unit's API
|
|
22
|
+
# @param params [ListAuthorizationParams]
|
|
23
|
+
# @return [UnitResponse, UnitError]
|
|
24
|
+
def list(params = nil)
|
|
25
|
+
response = HttpHelper.get("#{api_url}/authorization-requests", params: params.to_hash, headers: headers)
|
|
26
|
+
response_handler(response)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Approve an authorization request by calling Unit's API
|
|
30
|
+
# @param request [ApproveRequest]
|
|
31
|
+
# @return [UnitResponse, UnitError]
|
|
32
|
+
def approve(request)
|
|
33
|
+
payload = request.to_json_api
|
|
34
|
+
response = HttpHelper.post("#{api_url}/authorization-requests/#{request.authorization_request_id}/approve", body: payload, headers: headers)
|
|
35
|
+
response_handler(response)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Decline an authorization request by calling Unit's API
|
|
39
|
+
# @param request [DeclineRequest]
|
|
40
|
+
# @return [UnitResponse, UnitError]
|
|
41
|
+
def decline(request)
|
|
42
|
+
payload = request.to_json_api
|
|
43
|
+
response = HttpHelper.post("#{api_url}/authorization-requests/#{request.authorization_request_id}/decline", body: payload, headers: headers)
|
|
44
|
+
response_handler(response)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
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 authorizations to Unit API and parsing responses
|
|
7
|
+
# @see https://docs.unit.co/cards-authorizations
|
|
8
|
+
module Unit
|
|
9
|
+
module Resource
|
|
10
|
+
class AuthorizationResource < Unit::Resource::BaseResource
|
|
11
|
+
class << self
|
|
12
|
+
# Get authorization by calling Unit's API
|
|
13
|
+
# @param params [GetRequest]
|
|
14
|
+
# @return [UnitResponse, UnitError]
|
|
15
|
+
def get(params)
|
|
16
|
+
payload = params.to_hash
|
|
17
|
+
response = HttpHelper.get("#{api_url}/authorizations/#{params.authorization_id}", params: payload, headers: headers)
|
|
18
|
+
response_handler(response)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Get authorization by calling Unit's API
|
|
22
|
+
# @param params [GetRequest]
|
|
23
|
+
# @return [UnitResponse, UnitError]
|
|
24
|
+
def list(params = nil)
|
|
25
|
+
response = HttpHelper.get("#{api_url}/authorizations", params: params&.to_hash, headers: headers)
|
|
26
|
+
response_handler(response)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -83,6 +83,14 @@ module Unit
|
|
|
83
83
|
response_handler(response)
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
+
# Update card by calling Unit's API
|
|
87
|
+
# @param request [PatchBusinessCardRequest, PatchBusinessCreditCardRequest, PatchBusinessVirtualCardRequest, PatchBusinessVirtualCreditCardRequest]
|
|
88
|
+
def update(request)
|
|
89
|
+
payload = request.to_json_api
|
|
90
|
+
response = HttpHelper.patch("#{api_url}/cards/#{request.card_id}", headers: headers, body: payload)
|
|
91
|
+
response_handler(response)
|
|
92
|
+
end
|
|
93
|
+
|
|
86
94
|
# List cards by calling Unit's API
|
|
87
95
|
# @param params [ListCardParams]
|
|
88
96
|
# @return [UnitResponse, UnitError]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../api_resources/base_resource"
|
|
4
|
+
require_relative "../models/unit_response"
|
|
5
|
+
require_relative "../errors/unit_error"
|
|
6
|
+
require_relative "../utils/http_helper"
|
|
7
|
+
|
|
8
|
+
# class for creating requests for events to Unit API and parsing responses
|
|
9
|
+
# @see https://docs.unit.co/events
|
|
10
|
+
module Unit
|
|
11
|
+
module Resource
|
|
12
|
+
class EventResource < Unit::Resource::BaseResource
|
|
13
|
+
class << self
|
|
14
|
+
# Get an event by id by calling Unit's API
|
|
15
|
+
# @param event_id [String]
|
|
16
|
+
# @return [UnitResponse, UnitError]
|
|
17
|
+
def get(event_id)
|
|
18
|
+
response = HttpHelper.get("#{api_url}/events/#{event_id}", headers: headers)
|
|
19
|
+
response_handler(response)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# List events by calling Unit's API
|
|
23
|
+
# @param params [ListEventParams]
|
|
24
|
+
# @return [UnitResponse, UnitError]
|
|
25
|
+
def list(params = nil)
|
|
26
|
+
response = HttpHelper.get("#{api_url}/events", params: params&.to_hash, headers: headers)
|
|
27
|
+
response_handler(response)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Fire an event by calling Unit's API
|
|
31
|
+
# @param event_id [String]
|
|
32
|
+
# @return [UnitResponse, UnitError]
|
|
33
|
+
def fire(event_id)
|
|
34
|
+
response = HttpHelper.post("#{api_url}/events/#{event_id}", headers: headers)
|
|
35
|
+
response_handler(response)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "./base_resource"
|
|
4
|
+
require_relative "../utils/http_helper"
|
|
5
|
+
|
|
6
|
+
# class for creating requests for fees to Unit API and parsing responses
|
|
7
|
+
# @see https://docs.unit.co/fees/
|
|
8
|
+
module Unit
|
|
9
|
+
module Resource
|
|
10
|
+
class FeeResource < Unit::Resource::BaseResource
|
|
11
|
+
class << self
|
|
12
|
+
# Create a new fee by calling Unit's API
|
|
13
|
+
# @param request [CreateFeeRequest]
|
|
14
|
+
# @return [UnitResponse, UnitError]
|
|
15
|
+
def create_fee(request)
|
|
16
|
+
payload = request.to_json_api
|
|
17
|
+
response = HttpHelper.post("#{api_url}/fees", body: payload, headers: headers)
|
|
18
|
+
response_handler(response)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Reverse a fee by calling Unit's API
|
|
22
|
+
# @param request [ReverseFeeRequest]
|
|
23
|
+
# @return [UnitResponse, UnitError]
|
|
24
|
+
def reverse_fee(request)
|
|
25
|
+
payload = request.to_json_api
|
|
26
|
+
response = HttpHelper.post("#{api_url}/fees/reverse", body: payload, headers: headers)
|
|
27
|
+
response_handler(response)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
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 institutions to Unit API and parsing responses
|
|
8
|
+
# @see https://docs.unit.co/institutions/
|
|
9
|
+
module Unit
|
|
10
|
+
module Resource
|
|
11
|
+
class InstitutionResource < Unit::Resource::BaseResource
|
|
12
|
+
class << self
|
|
13
|
+
# Get an institution by routing number by calling Unit's API
|
|
14
|
+
# @param routing_number [String]
|
|
15
|
+
# @return [UnitResponse, UnitError]
|
|
16
|
+
def get_institution(routing_number)
|
|
17
|
+
response = HttpHelper.get("#{api_url}/institutions/#{routing_number}", headers: headers)
|
|
18
|
+
response_handler(response)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -53,6 +53,15 @@ module Unit
|
|
|
53
53
|
response = HttpHelper.get("#{api_url}/payments", params: payload, headers: headers)
|
|
54
54
|
response_handler(response)
|
|
55
55
|
end
|
|
56
|
+
|
|
57
|
+
# Create a new batch release by calling Unit's API
|
|
58
|
+
# @param request [BatchReleaseRequestBuilder]
|
|
59
|
+
# @return [UnitResponse, UnitError]
|
|
60
|
+
def create_batch_release(request)
|
|
61
|
+
payload = request.to_hash.to_json
|
|
62
|
+
response = HttpHelper.post("#{api_url}/batch-releases", body: payload, headers: headers)
|
|
63
|
+
response_handler(response)
|
|
64
|
+
end
|
|
56
65
|
end
|
|
57
66
|
end
|
|
58
67
|
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "./base_resource"
|
|
4
|
+
require_relative "../utils/http_helper"
|
|
5
|
+
|
|
6
|
+
# class for creating requests for book payments to Unit API and parsing responses
|
|
7
|
+
# @see https://docs.unit.co/book-payments#book-payments
|
|
8
|
+
module Unit
|
|
9
|
+
module Resource
|
|
10
|
+
class ReceivedPaymentResource < Unit::Resource::BaseResource
|
|
11
|
+
class << self
|
|
12
|
+
# Get a received ach payment by calling Unit's API
|
|
13
|
+
# @param payment_id [String]
|
|
14
|
+
# @return [UnitResponse, UnitError]
|
|
15
|
+
def get_payment(payment_id)
|
|
16
|
+
response = HttpHelper.get("#{api_url}/received-payments/#{payment_id}", headers: headers)
|
|
17
|
+
response_handler(response)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# List received ach payments by calling Unit's API
|
|
21
|
+
# @param params [ListAchPaymentParams]
|
|
22
|
+
# @return [UnitResponse, UnitError]
|
|
23
|
+
def list_payments(params = nil)
|
|
24
|
+
response = HttpHelper.get("#{api_url}/received-payments", params: params&.to_hash, headers: headers)
|
|
25
|
+
response_handler(response)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Update a received ach payment by calling Unit's API
|
|
29
|
+
# @param request [PatchReceivedPaymentRequest]
|
|
30
|
+
# @return [UnitResponse, UnitError]
|
|
31
|
+
def update_payment(request)
|
|
32
|
+
payload = request.to_json_api
|
|
33
|
+
response = HttpHelper.patch("#{api_url}/received-payments/#{request.payment_id}", body: payload, headers: headers)
|
|
34
|
+
response_handler(response)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Advance an ach payment by calling Unit's API
|
|
38
|
+
# @param payment_id [String]
|
|
39
|
+
# @return [UnitResponse, UnitError]
|
|
40
|
+
def advance_received_payment(payment_id)
|
|
41
|
+
response = HttpHelper.post("#{api_url}/received-payments/#{payment_id}/advance", headers: headers)
|
|
42
|
+
response_handler(response)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|