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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unit
|
|
4
|
+
module Fee
|
|
5
|
+
autoload :CreateFeeRequest, "unit/models/fee/create_fee_request"
|
|
6
|
+
autoload :ReverseFeeRequest, "unit/models/fee/reverse_fee_request"
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
# Request to create fee
|
|
10
|
+
# @see https://docs.unit.co/fees/#create-fee
|
|
11
|
+
# @param account_id [String]
|
|
12
|
+
# @param amount [Integer]
|
|
13
|
+
# @param description [String]
|
|
14
|
+
# @param tags [Hash] - optional
|
|
15
|
+
# @param idempotency_key [String] - optional
|
|
16
|
+
def create_fee(account_id:, amount:, description:, tags: nil, idempotency_key: nil)
|
|
17
|
+
request = CreateFeeRequest.new(account_id, amount, description, tags, idempotency_key)
|
|
18
|
+
Unit::Resource::FeeResource.create_fee(request)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Request to reverse a fee
|
|
22
|
+
# @see https://docs.unit.co/fees/#reverse-fee
|
|
23
|
+
# @param account_id [String]
|
|
24
|
+
# @param transaction_id [Integer]
|
|
25
|
+
# @param description [String]
|
|
26
|
+
# @param tags [Hash] - optional
|
|
27
|
+
# @param idempotency_key [String] - optional
|
|
28
|
+
def reverse_fee(account_id:, transaction_id:, description:, tags: nil, idempotency_key: nil)
|
|
29
|
+
request = ReverseFeeRequest.new(account_id, transaction_id, description, tags, idempotency_key)
|
|
30
|
+
Unit::Resource::FeeResource.reverse_fee(request)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to reverse a fee
|
|
4
|
+
# @see https://docs.unit.co/fees/#reverse-fee
|
|
5
|
+
module Unit
|
|
6
|
+
module Fee
|
|
7
|
+
class ReverseFeeRequest
|
|
8
|
+
attr_reader :account_id, :transaction_id, :description, :tags, :idempotency_key
|
|
9
|
+
|
|
10
|
+
# @param account_id [String]
|
|
11
|
+
# @param transaction_id [Integer]
|
|
12
|
+
# @param description [String]
|
|
13
|
+
# @param tags [Hash] - optional
|
|
14
|
+
# @param idempotency_key [String] - optional
|
|
15
|
+
def initialize(account_id, transaction_id, description, tags = nil, idempotency_key = nil)
|
|
16
|
+
@account_id = account_id
|
|
17
|
+
@transaction_id = transaction_id
|
|
18
|
+
@description = description
|
|
19
|
+
@tags = tags
|
|
20
|
+
@idempotency_key = idempotency_key
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def to_json_api
|
|
24
|
+
payload = {
|
|
25
|
+
"data": {
|
|
26
|
+
"type": "feeReversal",
|
|
27
|
+
"attributes": {
|
|
28
|
+
"description": description,
|
|
29
|
+
"tags": tags,
|
|
30
|
+
"idempotencyKey": idempotency_key
|
|
31
|
+
},
|
|
32
|
+
"relationships": {
|
|
33
|
+
"account": Unit::Types::Relationship.new("depositAccount", account_id).to_hash,
|
|
34
|
+
"transaction": Unit::Types::Relationship.new("transaction", transaction_id).to_hash
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
payload[:data][:attributes].compact!
|
|
39
|
+
payload.to_json
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unit
|
|
4
|
+
module Institution
|
|
5
|
+
class << self
|
|
6
|
+
# Get institution by routing number
|
|
7
|
+
# @see https://docs.unit.co/institutions/#get-institution-by-routingNumber
|
|
8
|
+
# @param routing_number [String]
|
|
9
|
+
def get_institution(routing_number:)
|
|
10
|
+
Unit::Resource::InstitutionResource.get_institution(routing_number)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# class to create a batch release using
|
|
4
|
+
module Unit
|
|
5
|
+
module Payment
|
|
6
|
+
class BatchReleaseRequestBuilder
|
|
7
|
+
def initialize
|
|
8
|
+
@requests = []
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def add_request(account_id, batch_account_id, amount, description, sender_name, sender_address, sender_account_number, tags = nil, idempotency_key = nil)
|
|
12
|
+
request = Unit::Payment::CreateBatchReleaseRequest.new(account_id, batch_account_id, amount, description, sender_name, sender_address, sender_account_number, tags, idempotency_key)
|
|
13
|
+
@requests << request.to_hash
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def to_hash
|
|
17
|
+
{ "data": @requests }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to create a batch release
|
|
4
|
+
# @see https://docs.unit.co/batch-payments/#create-batch-releases
|
|
5
|
+
module Unit
|
|
6
|
+
module Payment
|
|
7
|
+
class CreateBatchReleaseRequest
|
|
8
|
+
attr_reader :account_id, :batch_account_id, :amount, :description, :sender_name, :sender_address,
|
|
9
|
+
:sender_account_number, :tags, :idempotency_key
|
|
10
|
+
|
|
11
|
+
# @param account_id [String]
|
|
12
|
+
# @param batch_account_id [String]
|
|
13
|
+
# @param amount [Integer]
|
|
14
|
+
# @param description [String]
|
|
15
|
+
# @param sender_name [String]
|
|
16
|
+
# @param sender_address [Address]
|
|
17
|
+
# @param sender_account_number [String]
|
|
18
|
+
# @param tags [Hash] - optional
|
|
19
|
+
# @param idempotency_key [String] - optional
|
|
20
|
+
def initialize(account_id, batch_account_id, amount, description, sender_name, sender_address, sender_account_number, tags = nil, idempotency_key = nil)
|
|
21
|
+
@account_id = account_id
|
|
22
|
+
@batch_account_id = batch_account_id
|
|
23
|
+
@amount = amount
|
|
24
|
+
@description = description
|
|
25
|
+
@sender_name = sender_name
|
|
26
|
+
@sender_address = sender_address
|
|
27
|
+
@sender_account_number = sender_account_number
|
|
28
|
+
@tags = tags
|
|
29
|
+
@idempotency_key = idempotency_key
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def to_hash
|
|
33
|
+
payload = {
|
|
34
|
+
"type": "batchRelease",
|
|
35
|
+
"attributes": {
|
|
36
|
+
"amount": amount,
|
|
37
|
+
"description": description,
|
|
38
|
+
"senderName": sender_name,
|
|
39
|
+
"senderAddress": sender_address&.represent,
|
|
40
|
+
"senderAccountNumber": sender_account_number,
|
|
41
|
+
"tags": tags,
|
|
42
|
+
"idempotencyKey": idempotency_key
|
|
43
|
+
},
|
|
44
|
+
"relationships": {
|
|
45
|
+
"batchAccount": Unit::Types::Relationship.new("batchAccount", batch_account_id).to_hash,
|
|
46
|
+
"receiver": Unit::Types::Relationship.new("depositAccount", account_id).to_hash
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
payload[:attributes].compact!
|
|
50
|
+
payload
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -14,6 +14,8 @@ module Unit
|
|
|
14
14
|
autoload :ListPaymentParams, "unit/models/payment/list_payment_params"
|
|
15
15
|
autoload :GetRequest, "unit/models/payment/get_request"
|
|
16
16
|
autoload :BulkPaymentRequest, "unit/models/payment/bulk_payment_request"
|
|
17
|
+
autoload :CreateBatchReleaseRequest, "unit/models/payment/create_batch_release_request"
|
|
18
|
+
autoload :BatchReleaseRequestBuilder, "unit/models/payment/batch_release_request_builder"
|
|
17
19
|
class << self
|
|
18
20
|
# Create a new book payment by calling Unit's API
|
|
19
21
|
# @see https://docs.unit.co/book-payments#book-payments
|
|
@@ -181,6 +183,24 @@ module Unit
|
|
|
181
183
|
request = Unit::Payment::BulkPaymentRequest.serialize(requests)
|
|
182
184
|
Unit::Resource::PaymentResource.create_bulk_payment(request)
|
|
183
185
|
end
|
|
184
|
-
|
|
186
|
+
|
|
187
|
+
# Create a batch release
|
|
188
|
+
# @see https://docs.unit.co/batch-payments/#create-batch-releases
|
|
189
|
+
# @param account_id [String]
|
|
190
|
+
# @param amount [Integer]
|
|
191
|
+
# @param description [String]
|
|
192
|
+
# @param sender_name [String]
|
|
193
|
+
# @param sender_address [Address]
|
|
194
|
+
# @param sender_account_number [String]
|
|
195
|
+
# @param tags [Hash] - optional
|
|
196
|
+
# @param idempotency_key [String] - optional
|
|
197
|
+
def create_batch_release(requests)
|
|
198
|
+
payload = BatchReleaseRequestBuilder.new
|
|
199
|
+
requests.each do |req|
|
|
200
|
+
payload.add_request(req[:account_id], req[:batch_account_id], req[:amount], req[:description], req[:sender_name], req[:sender_address], req[:sender_account_number], req[:tags], req[:idempotency_key])
|
|
201
|
+
end
|
|
202
|
+
Unit::Resource::PaymentResource.create_batch_release(payload.to_hash)
|
|
203
|
+
end
|
|
204
|
+
end
|
|
185
205
|
end
|
|
186
206
|
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to list ach received payments by calling Unit's API
|
|
4
|
+
# @see https://docs.unit.co/received-ach#list-received-payments
|
|
5
|
+
module Unit
|
|
6
|
+
module ReceivedPayment
|
|
7
|
+
class ListPaymentParams
|
|
8
|
+
attr_reader :limit, :offset, :account_id, :customer_id, :status,
|
|
9
|
+
:include_completed, :tags, :sort, :include
|
|
10
|
+
|
|
11
|
+
# @param limit [Integer] - optional
|
|
12
|
+
# @param offset [Integer] - optional
|
|
13
|
+
# @param account_id [String] - optional
|
|
14
|
+
# @param customer_id [String] - optional
|
|
15
|
+
# @param status [Array<String>] - optional
|
|
16
|
+
# @param include_completed [Boolean] - optional
|
|
17
|
+
# @param tags [Hash] - optional
|
|
18
|
+
# @param sort [String] - optional
|
|
19
|
+
# @param include [Array<String>] - optional
|
|
20
|
+
def initialize(limit = RECEIVED_PAYMENT_LIMIT, offset = ACH_PAYMENT_OFFSET, account_id = nil, customer_id = nil, status = nil,
|
|
21
|
+
include_completed = nil, tags = nil, sort = nil, include = nil)
|
|
22
|
+
@limit = limit
|
|
23
|
+
@offset = offset
|
|
24
|
+
@account_id = account_id
|
|
25
|
+
@customer_id = customer_id
|
|
26
|
+
@status = status
|
|
27
|
+
@include_completed = include_completed
|
|
28
|
+
@tags = tags
|
|
29
|
+
@sort = sort
|
|
30
|
+
@include = include
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def to_hash
|
|
34
|
+
params = {
|
|
35
|
+
"page[limit]": limit,
|
|
36
|
+
"page[offset]": offset,
|
|
37
|
+
"filter[accountId]": account_id,
|
|
38
|
+
"filter[customerId]": customer_id,
|
|
39
|
+
"filter[includeCompleted]": include_completed,
|
|
40
|
+
"filter[tags]": tags,
|
|
41
|
+
"sort": sort,
|
|
42
|
+
"include": include&.join(",")
|
|
43
|
+
}
|
|
44
|
+
status&.each_with_index&.map do |val, index|
|
|
45
|
+
params.merge!({ "filter[status][#{index}]": val })
|
|
46
|
+
end
|
|
47
|
+
params.compact
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to update a received ACH payment
|
|
4
|
+
# @see https://docs.unit.co/received-ach#update-received-payment
|
|
5
|
+
module Unit
|
|
6
|
+
module ReceivedPayment
|
|
7
|
+
class PatchPaymentRequest
|
|
8
|
+
attr_reader :payment_id, :tags
|
|
9
|
+
|
|
10
|
+
# @param payment_id [String]
|
|
11
|
+
# @param tags [Hash] - optional
|
|
12
|
+
def initialize(payment_id, tags = nil)
|
|
13
|
+
@payment_id = payment_id
|
|
14
|
+
@tags = tags
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def to_json_api
|
|
18
|
+
payload = {
|
|
19
|
+
"data": {
|
|
20
|
+
"type": "achReceivedPayment",
|
|
21
|
+
"attributes": {
|
|
22
|
+
tags: tags
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
payload[:data][:attributes].compact!
|
|
27
|
+
payload.to_json
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unit
|
|
4
|
+
module ReceivedPayment
|
|
5
|
+
RECEIVED_PAYMENT_LIMIT = 100
|
|
6
|
+
RECEIVED_PAYMENT_OFFSET = 0
|
|
7
|
+
|
|
8
|
+
autoload :PatchPaymentRequest, "unit/models/received_payment/patch_payment_request"
|
|
9
|
+
autoload :ListPaymentParams, "unit/models/received_payment/list_payment_params"
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
# Get received ach payment by calling Unit's API
|
|
13
|
+
# @see https://docs.unit.co/received-ach#get-specific-received-payment
|
|
14
|
+
# @param payment_id [String]
|
|
15
|
+
def get_payment(payment_id:)
|
|
16
|
+
Unit::Resource::ReceivedPaymentResource.get_payment(payment_id)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Update a received ACH payment by calling Unit's API
|
|
20
|
+
# @see https://docs.unit.co/received-ach#update-received-payment
|
|
21
|
+
# @param payment_id [String]
|
|
22
|
+
# @param tags [Hash] - optional
|
|
23
|
+
def update_payment(payment_id:, tags: nil)
|
|
24
|
+
request = Unit::ReceivedPayment::PatchPaymentRequest.new(payment_id, tags)
|
|
25
|
+
Unit::Resource::ReceivedPaymentResource.update_payment(request)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# List ach payments by calling Unit's API
|
|
29
|
+
# @see https://docs.unit.co/received-ach#list-received-payments
|
|
30
|
+
# @param limit [Integer] - optional
|
|
31
|
+
# @param offset [Integer] - optional
|
|
32
|
+
# @param account_id [String] - optional
|
|
33
|
+
# @param customer_id [String] - optional
|
|
34
|
+
# @param status [Array<String>] - optional
|
|
35
|
+
# @param include_completed [Boolean] - optional
|
|
36
|
+
# @param tags [Hash] - optional
|
|
37
|
+
# @param sort [String] - optional
|
|
38
|
+
# @param include [Array<String>] - optional
|
|
39
|
+
def list_payments(limit: RECEIVED_PAYMENT_LIMIT, offset: RECEIVED_PAYMENT_OFFSET, account_id: nil, customer_id: nil, status: nil,
|
|
40
|
+
include_completed: nil, tags: nil, sort: nil, include: nil)
|
|
41
|
+
request = Unit::ReceivedPayment::ListPaymentParams.new(limit, offset, account_id, customer_id, status,
|
|
42
|
+
include_completed, tags, sort, include)
|
|
43
|
+
Unit::Resource::ReceivedPaymentResource.list_payments(request)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Advance a received payment by calling Unit's API
|
|
47
|
+
# @see https://docs.unit.co/received-ach#advance-received-payment
|
|
48
|
+
# @param payment_id [String]
|
|
49
|
+
def advance_payment(payment_id:)
|
|
50
|
+
Unit::Resource::ReceivedPaymentResource.advance_payment(payment_id)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to create a recurring credit ach payment
|
|
4
|
+
# @see https://docs.unit.co/recurring-payments/#recurring-payment-credit-ach-payment
|
|
5
|
+
module Unit
|
|
6
|
+
module RecurringPayment
|
|
7
|
+
class CreateRecurringCreditAchPaymentRequest
|
|
8
|
+
attr_reader :account_id, :counterparty_id, :amount, :description, :addenda, :schedule, :idempotency_key, :tags
|
|
9
|
+
|
|
10
|
+
# @param account_id [String]
|
|
11
|
+
# @param counterparty_id [String]
|
|
12
|
+
# @param amount [Integer]
|
|
13
|
+
# @param description [String]
|
|
14
|
+
# @param schedule [CreateSchedule]
|
|
15
|
+
# @param addenda [String] - optional
|
|
16
|
+
# @param idempotency_key [String] - optional
|
|
17
|
+
# @param tags [Hash] - optional
|
|
18
|
+
def initialize(account_id, counterparty_id, amount, description, schedule, addenda = nil, idempotency_key = nil, tags = nil)
|
|
19
|
+
@account_id = account_id
|
|
20
|
+
@counterparty_id = counterparty_id
|
|
21
|
+
@amount = amount
|
|
22
|
+
@description = description
|
|
23
|
+
@addenda = addenda
|
|
24
|
+
@schedule = schedule
|
|
25
|
+
@idempotency_key = idempotency_key
|
|
26
|
+
@tags = tags
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def to_json_api
|
|
30
|
+
payload = {
|
|
31
|
+
"data": {
|
|
32
|
+
"type": "recurringCreditAchPayment",
|
|
33
|
+
"attributes": {
|
|
34
|
+
"amount": amount,
|
|
35
|
+
"description": description,
|
|
36
|
+
"addenda": addenda,
|
|
37
|
+
"schedule": schedule&.represent,
|
|
38
|
+
"idempotencyKey": idempotency_key,
|
|
39
|
+
"tags": tags
|
|
40
|
+
},
|
|
41
|
+
"relationships": {
|
|
42
|
+
account: Unit::Types::Relationship.new("depositAccount", account_id).to_hash,
|
|
43
|
+
counterparty: Unit::Types::Relationship.new("counterparty", counterparty_id).to_hash
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
payload[:data][:attributes].compact!
|
|
48
|
+
payload.to_json
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to create a recurring credit book payment
|
|
4
|
+
# @see https://docs.unit.co/recurring-payments/#recurring-credit-book-payment
|
|
5
|
+
module Unit
|
|
6
|
+
module RecurringPayment
|
|
7
|
+
class CreateRecurringCreditBookPaymentRequest
|
|
8
|
+
attr_reader :account_id, :counterparty_id, :amount, :description, :schedule, :transaction_summary_override, :idempotency_key, :tags
|
|
9
|
+
|
|
10
|
+
# @param account_id [String]
|
|
11
|
+
# @param counterparty_id [String]
|
|
12
|
+
# @param amount [Integer]
|
|
13
|
+
# @param description [String]
|
|
14
|
+
# @param schedule [CreateSchedule]
|
|
15
|
+
# @param transaction_summary_override [String] - optional
|
|
16
|
+
# @param idempotency_key [String] - optional
|
|
17
|
+
# @param tags [Hash] - optional
|
|
18
|
+
def initialize(account_id, counterparty_id, amount, description, schedule,
|
|
19
|
+
transaction_summary_override = nil, idempotency_key = nil, tags = nil)
|
|
20
|
+
@account_id = account_id
|
|
21
|
+
@counterparty_id = counterparty_id
|
|
22
|
+
@amount = amount
|
|
23
|
+
@description = description
|
|
24
|
+
@transaction_summary_override = transaction_summary_override
|
|
25
|
+
@schedule = schedule
|
|
26
|
+
@idempotency_key = idempotency_key
|
|
27
|
+
@tags = tags
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def to_json_api
|
|
31
|
+
payload = {
|
|
32
|
+
"data": {
|
|
33
|
+
"type": "recurringCreditBookPayment",
|
|
34
|
+
"attributes": {
|
|
35
|
+
"amount": amount,
|
|
36
|
+
"description": description,
|
|
37
|
+
"schedule": schedule&.represent,
|
|
38
|
+
"transaction_summary_override": transaction_summary_override,
|
|
39
|
+
"idempotencyKey": idempotency_key,
|
|
40
|
+
"tags": tags
|
|
41
|
+
},
|
|
42
|
+
"relationships":
|
|
43
|
+
{
|
|
44
|
+
account: Unit::Types::Relationship.new("depositAccount", account_id).to_hash,
|
|
45
|
+
counterpartyAccount: Unit::Types::Relationship.new("depositAccount", counterparty_id).to_hash
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
payload[:data][:attributes].compact!
|
|
50
|
+
payload.to_json
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Create a recurring debit ACH payment request
|
|
4
|
+
# @see https://docs.unit.co/recurring-payments/#recurring-payment-debit-ach-payment
|
|
5
|
+
module Unit
|
|
6
|
+
module RecurringPayment
|
|
7
|
+
class CreateRecurringDebitAchPaymentRequest
|
|
8
|
+
attr_reader :account_id, :counterparty_id, :amount, :description, :addenda, :schedule, :idempotency_key, :tags,
|
|
9
|
+
:verify_counterparty_balance, :same_day
|
|
10
|
+
|
|
11
|
+
# @param account_id [String]
|
|
12
|
+
# @param counterparty_id [String]
|
|
13
|
+
# @param amount [Integer]
|
|
14
|
+
# @param description [String]
|
|
15
|
+
# @param schedule [CreateSchedule]
|
|
16
|
+
# @param addenda [String] - optional
|
|
17
|
+
# @param idempotency_key [String] - optional
|
|
18
|
+
# @param tags [Hash] - optional
|
|
19
|
+
# @param verify_counterparty_balance [Boolean] - optional
|
|
20
|
+
# @param same_day [Boolean] - optional
|
|
21
|
+
def initialize(account_id, counterparty_id, amount, description, schedule, addenda = nil, idempotency_key = nil, tags = nil,
|
|
22
|
+
verify_counterparty_balance = nil, same_day = nil)
|
|
23
|
+
@account_id = account_id
|
|
24
|
+
@counterparty_id = counterparty_id
|
|
25
|
+
@amount = amount
|
|
26
|
+
@description = description
|
|
27
|
+
@addenda = addenda
|
|
28
|
+
@schedule = schedule
|
|
29
|
+
@idempotency_key = idempotency_key
|
|
30
|
+
@tags = tags
|
|
31
|
+
@verify_counterparty_balance = verify_counterparty_balance
|
|
32
|
+
@same_day = same_day
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def to_json_api
|
|
36
|
+
payload = {
|
|
37
|
+
"data": {
|
|
38
|
+
"type": "recurringDebitAchPayment",
|
|
39
|
+
"attributes": {
|
|
40
|
+
"amount": amount,
|
|
41
|
+
"description": description,
|
|
42
|
+
"addenda": addenda,
|
|
43
|
+
"schedule": schedule&.represent,
|
|
44
|
+
"idempotencyKey": idempotency_key,
|
|
45
|
+
"tags": tags,
|
|
46
|
+
"verifyCounterpartyBalance": verify_counterparty_balance,
|
|
47
|
+
"sameDay": same_day
|
|
48
|
+
},
|
|
49
|
+
"relationships": {
|
|
50
|
+
account: Unit::Types::Relationship.new("depositAccount", account_id).to_hash,
|
|
51
|
+
counterparty: Unit::Types::Relationship.new("counterparty", counterparty_id).to_hash
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
payload[:data][:attributes].compact!
|
|
56
|
+
payload.to_json
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Params for listing recurring payments
|
|
4
|
+
# @see https://docs.unit.co/recurring-payments/#list-recurring-payments
|
|
5
|
+
module Unit
|
|
6
|
+
module RecurringPayment
|
|
7
|
+
class ListRecurringPaymentParams
|
|
8
|
+
attr_reader :limit, :offset, :account_id, :customer_id, :status, :type,
|
|
9
|
+
:from_start_time, :to_start_time, :from_end_time, :to_end_time, :sort
|
|
10
|
+
|
|
11
|
+
# @param limit [Integer] - optional
|
|
12
|
+
# @param offset [Integer] - optional
|
|
13
|
+
# @param account_id [String] - optional
|
|
14
|
+
# @param customer_id [String] - optional
|
|
15
|
+
# @param status [Array] - optional
|
|
16
|
+
# @param type [Array] - optional
|
|
17
|
+
# @param from_start_time [String] - optional
|
|
18
|
+
# @param to_start_time [String] - optional
|
|
19
|
+
# @param from_end_time [String] - optional
|
|
20
|
+
# @param to_end_time [String] - optional
|
|
21
|
+
# @param sort [String] - optional
|
|
22
|
+
def initialize(limit = RECURRING_PAYMENT_LIMIT, offset = RECURRING_PAYMENT_OFFSET, account_id = nil, customer_id = nil, status = nil, type = nil,
|
|
23
|
+
from_start_time = nil, to_start_time = nil, from_end_time = nil, to_end_time = nil, sort = nil)
|
|
24
|
+
@limit = limit
|
|
25
|
+
@offset = offset
|
|
26
|
+
@account_id = account_id
|
|
27
|
+
@customer_id = customer_id
|
|
28
|
+
@status = status
|
|
29
|
+
@type = type
|
|
30
|
+
@from_start_date = from_start_time
|
|
31
|
+
@to_start_date = to_start_time
|
|
32
|
+
@from_end_date = from_end_time
|
|
33
|
+
@to_end_date = to_end_time
|
|
34
|
+
@sort = sort
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def to_hash
|
|
38
|
+
payload = {
|
|
39
|
+
"page[limit]": limit,
|
|
40
|
+
"page[offset]": offset,
|
|
41
|
+
"filter[accountId]": account_id,
|
|
42
|
+
"filter[customerId]": customer_id,
|
|
43
|
+
"filter[fromStartTime]": from_start_time,
|
|
44
|
+
"filter[toStartTime]": to_start_time,
|
|
45
|
+
"filter[fromEndTime]": from_end_time,
|
|
46
|
+
"filter[toEndTime]": to_end_time,
|
|
47
|
+
"sort": sort
|
|
48
|
+
}
|
|
49
|
+
filters = %i[status type]
|
|
50
|
+
filters.each do |filter|
|
|
51
|
+
values = send(filter)
|
|
52
|
+
values&.each_with_index&.map do |val, index|
|
|
53
|
+
params.merge!({ "filter[#{filter}][#{index}]": val })
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
payload.compact!
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|