unit_ruby_sdk 1.0.5 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +190 -19
- 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/payment_resource.rb +17 -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/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/payment/batch_release_request_builder.rb +21 -0
- data/lib/unit/models/payment/bulk_payment_request.rb +15 -0
- data/lib/unit/models/payment/create_ach_payment_inline_request.rb +29 -19
- data/lib/unit/models/payment/create_batch_release_request.rb +54 -0
- data/lib/unit/models/payment/create_book_payment_request.rb +24 -14
- data/lib/unit/models/payment/create_payment_linked_request.rb +31 -21
- data/lib/unit/models/payment/create_wire_payment_request.rb +22 -12
- data/lib/unit/models/payment/create_with_plaid_token_request.rb +32 -22
- data/lib/unit/models/payment/payment.rb +40 -12
- 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 +28 -0
- metadata +67 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6886c703f37b77fbd4ccc6e174cf0c79b83c588c53f0cfaaa6a1503598fc1fbd
|
4
|
+
data.tar.gz: 0371acc6dc064fb9bf8969d10839cbe915e23772bb088493bf889abfeee50244
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11d43e7bdaa9d8af5b2f3ac73823576773a784e9bf098d6fb232c08cbb5d76ac7de441da062ed33645c7804c2f19a897a4f0e8cdc1309f6b2b146c249c8edd0c
|
7
|
+
data.tar.gz: b8077c7600d42b3396a2f0b5437edde30b1e3d09899df5e0d5ebec0761822a3a8bbcd3b83cc9706245f3a02c26d3b4e0c0481ef19410874eed952292584464c7
|
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,11 +275,80 @@ 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
|
286
|
+
```
|
287
|
+
|
288
|
+
### Creating a bulk payment
|
289
|
+
```ruby
|
290
|
+
address = Unit::Types::Address.new('123 Main St', 'San Francisco', 'CA', '94205', 'US')
|
291
|
+
wire_counterparty = Unit::Types::WireCounterparty.new("Jane Doe", "27573", "812345678", address)
|
292
|
+
counterparty = Unit::Types::Counterparty.new("Jane Doe", "27573", "812345678", "Checking")
|
293
|
+
book_payment_request = Unit::Payment::CreateBookPaymentRequest.new(amount: 1000, description: "test payment", account_id: "27573", counterparty_account_id: "36981", tags: { "test": "test-tag" })
|
294
|
+
wire_payment_request = Unit::Payment::CreateWirePaymentRequest.new(amount: 1000, description: "test payment", account_id: "27573", counterparty: wire_counterparty, tags: { "test": "test-tag" })
|
295
|
+
ach_payment_inline_request = Unit::Payment::CreateAchPaymentInlineRequest.new(amount: 1000, direction: "Credit", counterparty: counterparty, description: "test payment", account_id: "27573", tags: { "test": "test-tag" })
|
296
|
+
ach_payment_linked_request = Unit::Payment::CreatePaymentLinkedRequest.new(amount: 1000, direction: "Credit", description: "test payment", account_id: "27573", counterparty_id: "313118", tags: { "test": "test-tag" })
|
297
|
+
ach_payment_plaid_token_request = Unit::Payment::CreateWithPlaidTokenRequest.new(amount: 1000, direction: "Credit", description: "test payment", account_id: "27573", plaid_processor_token: "processor-sandbox-fc8b9c23-b400-40f9-8ee8-c2cabd719721", tags: { "test": "test-tag" })
|
298
|
+
|
299
|
+
response = Unit::Payment.create_bulk_payment(
|
300
|
+
requests: [book_payment_request, wire_payment_request, ach_payment_inline_request, ach_payment_linked_request, ach_payment_plaid_token_request])
|
301
|
+
bulk_payment = response.data
|
302
|
+
puts bulk_payment["id"]
|
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
|
182
317
|
```
|
183
318
|
|
184
319
|
### Logging Errors
|
185
320
|
|
321
|
+
### Handling Response
|
322
|
+
|
323
|
+
### Creating a webhook
|
324
|
+
```ruby
|
325
|
+
response = Unit::Webhook.create_webhook(
|
326
|
+
label: "some label",
|
327
|
+
url: "https://webhook.site/81ee6b53-fde4-4b7d-85a0-0b6249a4488d",
|
328
|
+
token: "MyToken",
|
329
|
+
content_type: "Json",
|
330
|
+
delivery_mode: "AtLeastOnce",
|
331
|
+
include_resources: false,
|
332
|
+
subscription_type: "OnlyAuthorizationRequest")
|
333
|
+
webhook = response.data
|
334
|
+
puts webhook["id"]
|
335
|
+
```
|
336
|
+
|
337
|
+
### Creating a fee
|
338
|
+
```ruby
|
339
|
+
response = Unit::Fee.create_fee(
|
340
|
+
account_id: "27573",
|
341
|
+
amount: 12_345,
|
342
|
+
description: "test",
|
343
|
+
tags: { purpose: "test" },
|
344
|
+
idempotency_key: "123"
|
345
|
+
)
|
346
|
+
fee = response.data
|
347
|
+
puts fee["id"]
|
348
|
+
```
|
349
|
+
|
350
|
+
|
351
|
+
### Handling Response
|
186
352
|
```ruby
|
187
353
|
require 'unit_ruby_sdk'
|
188
354
|
|
@@ -191,6 +357,11 @@ Unit.config(api_url: ENV['API_URL'], token: "missing token")
|
|
191
357
|
# response is a Unit::UnitError
|
192
358
|
response = Unit::Application.get_application('123')
|
193
359
|
|
194
|
-
#
|
195
|
-
response.
|
360
|
+
# Checks the response to be an instance of UnitResponse
|
361
|
+
if response.instance_of?(Unit::UnitResponse)
|
362
|
+
# handle response
|
363
|
+
else
|
364
|
+
# handle error
|
365
|
+
response.errors.each{|error| puts error.title}
|
366
|
+
end
|
196
367
|
```
|
@@ -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
|
@@ -19,6 +19,14 @@ module Unit
|
|
19
19
|
response_handler(response)
|
20
20
|
end
|
21
21
|
|
22
|
+
# Create a new bulk payment by calling Unit's API
|
23
|
+
# @param request [BulkPaymentRequest]
|
24
|
+
# @return [UnitResponse, UnitError]
|
25
|
+
def create_bulk_payment(request)
|
26
|
+
response = HttpHelper.post("#{api_url}/payments/bulk", body: request, headers: headers)
|
27
|
+
response_handler(response)
|
28
|
+
end
|
29
|
+
|
22
30
|
# Update a payment by calling Unit's API
|
23
31
|
# @param request [PatchBookPaymentRequest, PatchAchPaymentRequest]
|
24
32
|
# @return [UnitResponse, UnitError]
|
@@ -45,6 +53,15 @@ module Unit
|
|
45
53
|
response = HttpHelper.get("#{api_url}/payments", params: payload, headers: headers)
|
46
54
|
response_handler(response)
|
47
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
|
48
65
|
end
|
49
66
|
end
|
50
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
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./base_resource"
|
4
|
+
require_relative "../utils/http_helper"
|
5
|
+
|
6
|
+
# class for creating requests for payments to Unit API and parsing responses
|
7
|
+
# @see https://docs.unit.co/recurring-payments
|
8
|
+
module Unit
|
9
|
+
module Resource
|
10
|
+
class RecurringPaymentResource < Unit::Resource::BaseResource
|
11
|
+
class << self
|
12
|
+
# Create a new recurring payment by calling Unit's API
|
13
|
+
# @param request [CreateRecurringCreditAchPaymentRequest, CreateRecurringDebitAchPaymentRequest, CreateRecurringCreditBookPaymentRequest]
|
14
|
+
# @return [UnitResponse, UnitError]
|
15
|
+
def create_recurring_payment(request)
|
16
|
+
payload = request.to_json_api
|
17
|
+
response = HttpHelper.post("#{api_url}/recurring-payments", body: payload, headers: headers)
|
18
|
+
response_handler(response)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Disable a new recurring payment by calling Unit's API
|
22
|
+
# @param recurring_payment_id [String]
|
23
|
+
# @return [UnitResponse, UnitError]
|
24
|
+
def disable_recurring_payment(recurring_payment_id)
|
25
|
+
response = HttpHelper.post("#{api_url}/recurring-payments/#{recurring_payment_id}/disable", headers: headers)
|
26
|
+
response_handler(response)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Enable a new recurring payment by calling Unit's API
|
30
|
+
# @param recurring_payment_id [String]
|
31
|
+
# @return [UnitResponse, UnitError]
|
32
|
+
def enable_recurring_payment(recurring_payment_id)
|
33
|
+
response = HttpHelper.post("#{api_url}/recurring-payments/#{recurring_payment_id}/enable", headers: headers)
|
34
|
+
response_handler(response)
|
35
|
+
end
|
36
|
+
|
37
|
+
# List a new recurring payment by calling Unit's API
|
38
|
+
# @param request [ListRecurringPaymentParams]
|
39
|
+
# @return [UnitResponse, UnitError]
|
40
|
+
def list_recurring_payment(params = {})
|
41
|
+
response = HttpHelper.get("#{api_url}/recurring-payments", params: params.to_hash, headers: headers)
|
42
|
+
response_handler(response)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Get a new recurring payment by calling Unit's API
|
46
|
+
# @param recurring_payment_id [String]
|
47
|
+
# @return [UnitResponse, UnitError]
|
48
|
+
def get_recurring_payment(recurring_payment_id)
|
49
|
+
response = HttpHelper.get("#{api_url}/recurring-payments/#{recurring_payment_id}", headers: headers)
|
50
|
+
response_handler(response)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|