unit_ruby_sdk 1.0.5 → 1.2.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 +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
@@ -5,7 +5,8 @@
|
|
5
5
|
module Unit
|
6
6
|
module Card
|
7
7
|
class CreateBusinessDebitCardRequest
|
8
|
-
attr_reader :account_id, :full_name, :date_of_birth, :address, :shipping_address, :phone, :email, :design, :additional_embossed_text,
|
8
|
+
attr_reader :account_id, :full_name, :date_of_birth, :address, :shipping_address, :phone, :email, :design, :additional_embossed_text,
|
9
|
+
:idempotency_key, :tags, :limits, :print_only_business_name, :expiry_date, :type
|
9
10
|
|
10
11
|
# @param account_id [String]
|
11
12
|
# @param full_name [FullName]
|
@@ -20,8 +21,9 @@ module Unit
|
|
20
21
|
# @param tags [Hash] - optional
|
21
22
|
# @param limits [Hash] - optional
|
22
23
|
# @param print_only_business_name [Boolean] - optional
|
24
|
+
# @param expiry_date [String] - optional
|
23
25
|
def initialize(account_id, full_name, date_of_birth, address, shipping_address = nil, phone = nil, email = nil, design = nil,
|
24
|
-
additional_embossed_text = nil, idempotency_key = nil, tags = nil, limits = nil, print_only_business_name = nil)
|
26
|
+
additional_embossed_text = nil, idempotency_key = nil, tags = nil, limits = nil, print_only_business_name = nil, expiry_date = nil)
|
25
27
|
@account_id = account_id
|
26
28
|
@full_name = full_name
|
27
29
|
@date_of_birth = date_of_birth
|
@@ -35,12 +37,14 @@ module Unit
|
|
35
37
|
@tags = tags
|
36
38
|
@limits = limits
|
37
39
|
@print_only_business_name = print_only_business_name
|
40
|
+
@expiry_date = expiry_date
|
41
|
+
@type = "businessDebitCard"
|
38
42
|
end
|
39
43
|
|
40
44
|
def to_json_api
|
41
45
|
payload = {
|
42
46
|
"data": {
|
43
|
-
"type":
|
47
|
+
"type": type,
|
44
48
|
"attributes": {
|
45
49
|
"fullName": full_name&.represent,
|
46
50
|
"dateOfBirth": date_of_birth,
|
@@ -53,14 +57,14 @@ module Unit
|
|
53
57
|
"idempotencyKey": idempotency_key,
|
54
58
|
"tags": tags,
|
55
59
|
"limits": limits,
|
56
|
-
"printOnlyBusinessName": print_only_business_name
|
57
|
-
|
60
|
+
"printOnlyBusinessName": print_only_business_name,
|
61
|
+
"expiryDate": expiry_date
|
62
|
+
}.compact!,
|
58
63
|
"relationships": {
|
59
64
|
"account": Unit::Types::Relationship.new("account", account_id).to_hash
|
60
65
|
}
|
61
66
|
}
|
62
67
|
}
|
63
|
-
payload[:data][:attributes].compact!
|
64
68
|
payload.to_json
|
65
69
|
end
|
66
70
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create business virtual credit card request
|
4
|
+
# @see https://guides.unit.co/business-charge-cards/
|
5
|
+
module Unit
|
6
|
+
module Card
|
7
|
+
# @param account_id [String]
|
8
|
+
# @param full_name [FullName]
|
9
|
+
# @param date_of_birth [Date]
|
10
|
+
# @param address [Address]
|
11
|
+
# @param phone [Phone] - optional
|
12
|
+
# @param email [String] - optional
|
13
|
+
# @param idempotency_key [String] - optional
|
14
|
+
# @param tags [Hash] - optional
|
15
|
+
# @param limits [Hash] - optional
|
16
|
+
# @param expiry_date [String] - optional
|
17
|
+
class CreateBusinessVirtualCreditCardRequest < CreateBusinessVirtualDebitCardRequest
|
18
|
+
def initialize(account_id, full_name, date_of_birth, address, phone = nil, email = nil,
|
19
|
+
idempotency_key = nil, tags = nil, limits = nil, expiry_date = nil)
|
20
|
+
super
|
21
|
+
@type = "businessVirtualCreditCard"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -5,7 +5,8 @@
|
|
5
5
|
module Unit
|
6
6
|
module Card
|
7
7
|
class CreateBusinessVirtualDebitCardRequest
|
8
|
-
attr_reader :account_id, :full_name, :date_of_birth, :address, :phone, :email,
|
8
|
+
attr_reader :account_id, :full_name, :date_of_birth, :address, :phone, :email,
|
9
|
+
:idempotency_key, :tags, :limits, :expiry_date, :type
|
9
10
|
|
10
11
|
# @param account_id [String]
|
11
12
|
# @param full_name [FullName]
|
@@ -16,8 +17,9 @@ module Unit
|
|
16
17
|
# @param idempotency_key [String] - optional
|
17
18
|
# @param tags [Hash] - optional
|
18
19
|
# @param limits [Hash] - optional
|
20
|
+
# @param expiry_date [String] - optional
|
19
21
|
def initialize(account_id, full_name, date_of_birth, address, phone, email,
|
20
|
-
idempotency_key, tags, limits)
|
22
|
+
idempotency_key = nil, tags = nil, limits = nil, expiry_date = nil)
|
21
23
|
@account_id = account_id
|
22
24
|
@full_name = full_name
|
23
25
|
@date_of_birth = date_of_birth
|
@@ -27,12 +29,14 @@ module Unit
|
|
27
29
|
@idempotency_key = idempotency_key
|
28
30
|
@tags = tags
|
29
31
|
@limits = limits
|
32
|
+
@expiry_date = expiry_date
|
33
|
+
@type = "businessVirtualDebitCard"
|
30
34
|
end
|
31
35
|
|
32
36
|
def to_json_api
|
33
37
|
payload = {
|
34
38
|
"data": {
|
35
|
-
"type":
|
39
|
+
"type": type,
|
36
40
|
"attributes": {
|
37
41
|
"fullName": full_name&.represent,
|
38
42
|
"dateOfBirth": date_of_birth,
|
@@ -41,14 +45,14 @@ module Unit
|
|
41
45
|
"email": email,
|
42
46
|
"idempotencyKey": idempotency_key,
|
43
47
|
"tags": tags,
|
44
|
-
"limits": limits
|
45
|
-
|
48
|
+
"limits": limits,
|
49
|
+
"expiryDate": expiry_date
|
50
|
+
}.compact!,
|
46
51
|
"relationships": {
|
47
52
|
"account": Unit::Types::Relationship.new("depositAccount", account_id).to_hash
|
48
53
|
}
|
49
54
|
}
|
50
55
|
}
|
51
|
-
payload[:data][:attributes].compact!
|
52
56
|
payload.to_json
|
53
57
|
end
|
54
58
|
end
|
@@ -5,7 +5,8 @@
|
|
5
5
|
module Unit
|
6
6
|
module Card
|
7
7
|
class CreateIndividualDebitCardRequest
|
8
|
-
attr_reader :account_id, :customer_id, :shipping_address, :design, :additional_embossed_text, :idempotency_key,
|
8
|
+
attr_reader :account_id, :customer_id, :shipping_address, :design, :additional_embossed_text, :idempotency_key,
|
9
|
+
:tags, :limits, :print_only_business_name, :expiry_date
|
9
10
|
|
10
11
|
# @param account_id [String]
|
11
12
|
# @param customer_id [String] - optional
|
@@ -16,8 +17,9 @@ module Unit
|
|
16
17
|
# @param tags [Hash] - optional
|
17
18
|
# @param limits [Hash] - optional
|
18
19
|
# @param print_only_business_name [Boolean] - optional
|
20
|
+
# @param expiry_date [String] - optional
|
19
21
|
def initialize(account_id, customer_id = nil, shipping_address = nil, design = nil, additional_embossed_text = nil,
|
20
|
-
idempotency_key = nil, tags = nil, limits = nil, print_only_business_name = nil)
|
22
|
+
idempotency_key = nil, tags = nil, limits = nil, print_only_business_name = nil, expiry_date = nil)
|
21
23
|
@account_id = account_id
|
22
24
|
@customer_id = customer_id
|
23
25
|
@shipping_address = shipping_address
|
@@ -27,6 +29,7 @@ module Unit
|
|
27
29
|
@tags = tags
|
28
30
|
@limits = limits
|
29
31
|
@print_only_business_name = print_only_business_name
|
32
|
+
@expiry_date = expiry_date
|
30
33
|
end
|
31
34
|
|
32
35
|
def to_json_api
|
@@ -40,7 +43,8 @@ module Unit
|
|
40
43
|
"idempotencyKey": idempotency_key,
|
41
44
|
"tags": tags,
|
42
45
|
"limits": limits,
|
43
|
-
"printOnlyBusinessName": print_only_business_name
|
46
|
+
"printOnlyBusinessName": print_only_business_name,
|
47
|
+
"expiryDate": expiry_date
|
44
48
|
},
|
45
49
|
"relationships": {
|
46
50
|
"account": Unit::Types::Relationship.new("depositAccount", account_id).to_hash
|
@@ -5,19 +5,21 @@
|
|
5
5
|
module Unit
|
6
6
|
module Card
|
7
7
|
class CreateIndividualVirtualCardRequest
|
8
|
-
attr_reader :account_id, :customer_id, :idempotency_key, :tags, :limits
|
8
|
+
attr_reader :account_id, :customer_id, :idempotency_key, :tags, :limits, :expiry_date
|
9
9
|
|
10
10
|
# @param account_id [String]
|
11
11
|
# @param customer_id [String] - optional
|
12
12
|
# @param idempotency_key [String] - optional
|
13
13
|
# @param tags [Hash] - optional
|
14
14
|
# @param limits [Hash] - optional
|
15
|
-
|
15
|
+
# @param expiry_date [String] - optional
|
16
|
+
def initialize(account_id, customer_id = nil, idempotency_key = nil, tags = nil, limits = nil, expiry_date = nil)
|
16
17
|
@account_id = account_id
|
17
18
|
@customer_id = customer_id
|
18
19
|
@idempotency_key = idempotency_key
|
19
20
|
@tags = tags
|
20
21
|
@limits = limits
|
22
|
+
@expiry_date = expiry_date
|
21
23
|
end
|
22
24
|
|
23
25
|
def to_json_api
|
@@ -27,7 +29,8 @@ module Unit
|
|
27
29
|
"attributes": {
|
28
30
|
"idempotencyKey": idempotency_key,
|
29
31
|
"tags": tags,
|
30
|
-
"limits": limits
|
32
|
+
"limits": limits,
|
33
|
+
"expiryDate": expiry_date
|
31
34
|
},
|
32
35
|
"relationships": {
|
33
36
|
"account": Unit::Types::Relationship.new("depositAccount", account_id).to_hash
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create business card request
|
4
|
+
# @see https://docs.unit.co/cards/#update-business-debit-card
|
5
|
+
module Unit
|
6
|
+
module Card
|
7
|
+
class PatchBusinessCardRequest
|
8
|
+
attr_reader :card_id, :shipping_address, :address, :phone, :email, :design, :tags, :limits, :type
|
9
|
+
|
10
|
+
# @param card_id [String]
|
11
|
+
# @param shipping_address [Address] - optional
|
12
|
+
# @param address [Address] - optional
|
13
|
+
# @param phone [Phone] - optional
|
14
|
+
# @param email [String] - optional
|
15
|
+
# @param design [String] - optional
|
16
|
+
# @param tags [Hash] - optional
|
17
|
+
# @param limits [Hash] - optional
|
18
|
+
def initialize(card_id, shipping_address = nil, address = nil, phone = nil, email = nil, design = nil, tags = nil, limits = nil)
|
19
|
+
@card_id = card_id
|
20
|
+
@shipping_address = shipping_address
|
21
|
+
@address = address
|
22
|
+
@phone = phone
|
23
|
+
@email = email
|
24
|
+
@design = design
|
25
|
+
@tags = tags
|
26
|
+
@limits = limits
|
27
|
+
@type = "businessDebitCard"
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_json_api
|
31
|
+
payload = {
|
32
|
+
"data": {
|
33
|
+
"type": type,
|
34
|
+
"attributes": {
|
35
|
+
"shippingAddress": shipping_address,
|
36
|
+
"address": address,
|
37
|
+
"phone": phone,
|
38
|
+
"email": email,
|
39
|
+
"design": design,
|
40
|
+
"tags": tags,
|
41
|
+
"limits": limits
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
payload[:data][:attributes].compact!
|
46
|
+
payload.to_json
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create business credit card request
|
4
|
+
# @see https://guides.unit.co/business-charge-cards/
|
5
|
+
module Unit
|
6
|
+
module Card
|
7
|
+
class PatchBusinessCreditCardRequest < PatchBusinessCardRequest
|
8
|
+
# @param card_id [String]
|
9
|
+
# @param shipping_address [Address] - optional
|
10
|
+
# @param address [Address] - optional
|
11
|
+
# @param phone [Phone] - optional
|
12
|
+
# @param email [String] - optional
|
13
|
+
# @param design [String] - optional
|
14
|
+
# @param tags [Hash] - optional
|
15
|
+
# @param limits [Hash] - optional
|
16
|
+
def initialize(card_id, shipping_address = nil, address = nil, phone = nil, email = nil, design = nil, tags = nil, limits = nil)
|
17
|
+
super
|
18
|
+
@type = "businessCreditCard"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to update a business virtual debit card
|
4
|
+
# @see https://docs.unit.co/cards/#update-business-virtual-debit-card
|
5
|
+
module Unit
|
6
|
+
module Card
|
7
|
+
class PatchBusinessVirtualCardRequest
|
8
|
+
attr_reader :card_id, :address, :phone, :email, :tags, :limits, :type
|
9
|
+
|
10
|
+
# @param card_id [String]
|
11
|
+
# @param address [Address] - optional
|
12
|
+
# @param phone [Phone] - optional
|
13
|
+
# @param email [String] - optional
|
14
|
+
# @param tags [Hash] - optional
|
15
|
+
# @param limits [Hash] - optional
|
16
|
+
def initialize(card_id, address = nil, phone = nil, email = nil, tags = nil, limits = nil)
|
17
|
+
@card_id = card_id
|
18
|
+
@address = address
|
19
|
+
@phone = phone
|
20
|
+
@email = email
|
21
|
+
@tags = tags
|
22
|
+
@limits = limits
|
23
|
+
@type = "businessVirtualDebitCard"
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_json_api
|
27
|
+
payload = {
|
28
|
+
"data": {
|
29
|
+
"type": type,
|
30
|
+
"attributes": {
|
31
|
+
"address": address,
|
32
|
+
"phone": phone,
|
33
|
+
"email": email,
|
34
|
+
"tags": tags,
|
35
|
+
"limits": limits
|
36
|
+
}.compact
|
37
|
+
}
|
38
|
+
}
|
39
|
+
payload.to_json
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to update a business virtual credit card
|
4
|
+
# @see https://guides.unit.co/business-charge-cards/
|
5
|
+
module Unit
|
6
|
+
module Card
|
7
|
+
class PatchBusinessVirtualCreditCardRequest < PatchBusinessVirtualCardRequest
|
8
|
+
# @param card_id [String]
|
9
|
+
# @param address [Address] - optional
|
10
|
+
# @param phone [Phone] - optional
|
11
|
+
# @param email [String] - optional
|
12
|
+
# @param tags [Hash] - optional
|
13
|
+
# @param limits [Hash] - optional
|
14
|
+
def initialize(card_id, address = nil, phone = nil, email = nil, tags = nil, limits = nil)
|
15
|
+
super
|
16
|
+
@type = "businessVirtualCreditCard"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -12,7 +12,7 @@ module Unit
|
|
12
12
|
# @param query [String] - optional
|
13
13
|
# @param email [String] - optional
|
14
14
|
# @param tags [Hash] - optional
|
15
|
-
# @param status [String] - optional
|
15
|
+
# @param status [Array<String>] - optional
|
16
16
|
# @param sort [String] - optional
|
17
17
|
def initialize(limit = CUSTOMER_LIST_LIMIT, offset = CUSTOMER_LIST_OFFSET, query = nil, email = nil, tags = nil, status = nil,
|
18
18
|
sort = nil)
|
@@ -31,8 +31,10 @@ module Unit
|
|
31
31
|
"filter[query]": query,
|
32
32
|
"filter[email]": email,
|
33
33
|
"filter[tags]": tags,
|
34
|
-
"filter[status]": status,
|
35
34
|
"sort": sort }
|
35
|
+
status&.each_with_index&.map do |val, index|
|
36
|
+
params.merge!({ "filter[status][#{index}]": val })
|
37
|
+
end
|
36
38
|
params.compact
|
37
39
|
end
|
38
40
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module Event
|
5
|
+
EVENT_LIST_LIMIT = 100
|
6
|
+
EVENT_LIST_OFFSET = 0
|
7
|
+
|
8
|
+
autoload :ListEventParams, "unit/models/event/list_event_params"
|
9
|
+
class << self
|
10
|
+
# Get event by id
|
11
|
+
# @see https://docs.unit.co/events#get-event
|
12
|
+
# @param event_id [String]
|
13
|
+
def get_event(event_id:)
|
14
|
+
Unit::Resource::EventResource.get(event_id)
|
15
|
+
end
|
16
|
+
|
17
|
+
# List events
|
18
|
+
# @see https://docs.unit.co/events#list-events
|
19
|
+
# @param limit [Integer]
|
20
|
+
# @param offset [Integer]
|
21
|
+
# @param type [Array<String>] - optional
|
22
|
+
# @param since [String] - optional
|
23
|
+
# @param _until [String] - optional
|
24
|
+
def list_events(limit: EVENT_LIST_LIMIT, offset: EVENT_LIST_OFFSET, type: nil, since: nil, _until: nil)
|
25
|
+
params = ListEventParams.new(limit, offset, type, since, _until)
|
26
|
+
Unit::Resource::EventResource.list(params)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Fire event
|
30
|
+
# @see https://docs.unit.co/events#fire-event
|
31
|
+
# @param event_id [String]
|
32
|
+
def fire_event(event_id:)
|
33
|
+
Unit::Resource::EventResource.fire(event_id)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# params for listing events
|
4
|
+
# https://docs.unit.co/events#list-events
|
5
|
+
module Unit
|
6
|
+
module Event
|
7
|
+
class ListEventParams
|
8
|
+
attr_reader :limit, :offset, :type, :since, :_until
|
9
|
+
|
10
|
+
# @param limit [Integer]
|
11
|
+
# @param offset [Integer]
|
12
|
+
# @param type [Array<String>] - optional
|
13
|
+
# @param since [String] - optional
|
14
|
+
# @param _until [String] - optional
|
15
|
+
def initialize(limit = EVENT_LIST_LIMIT, offset = EVENT_LIST_OFFSET, type = nil, since = nil, _until = nil)
|
16
|
+
@limit = limit
|
17
|
+
@offset = offset
|
18
|
+
@type = type
|
19
|
+
@since = since
|
20
|
+
@_until = _until
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_hash
|
24
|
+
params = {
|
25
|
+
"page[limit]": limit,
|
26
|
+
"page[offset]": offset,
|
27
|
+
"filter[since]": since,
|
28
|
+
"filter[until]": _until
|
29
|
+
}
|
30
|
+
type&.each_with_index&.map do |val, index|
|
31
|
+
params.merge!({ "filter[type][#{index}]": val })
|
32
|
+
end
|
33
|
+
params.compact
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create fee
|
4
|
+
# @see https://docs.unit.co/fees/#create-fee
|
5
|
+
module Unit
|
6
|
+
module Fee
|
7
|
+
class CreateFeeRequest
|
8
|
+
attr_reader :account_id, :amount, :description, :tags, :idempotency_key
|
9
|
+
|
10
|
+
# @param account_id [String]
|
11
|
+
# @param amount [Integer]
|
12
|
+
# @param description [String]
|
13
|
+
# @param tags [Hash] - optional
|
14
|
+
# @param idempotency_key [String] - optional
|
15
|
+
def initialize(account_id, amount, description, tags = nil, idempotency_key = nil)
|
16
|
+
@account_id = account_id
|
17
|
+
@amount = amount
|
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": "fee",
|
27
|
+
"attributes": {
|
28
|
+
"amount": amount,
|
29
|
+
"description": description,
|
30
|
+
"tags": tags,
|
31
|
+
"idempotencyKey": idempotency_key
|
32
|
+
},
|
33
|
+
"relationships": {
|
34
|
+
"account": Unit::Types::Relationship.new("depositAccount", account_id).to_hash
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
payload[:data][:attributes].compact!
|
39
|
+
payload.to_json
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,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,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,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
# class for serializing payment requests
|
6
|
+
module Unit
|
7
|
+
module Payment
|
8
|
+
class BulkPaymentRequest
|
9
|
+
def self.serialize(requests)
|
10
|
+
payload = requests.map(&:change_attributes)
|
11
|
+
{ "data": payload }.to_json
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -18,8 +18,8 @@ module Unit
|
|
18
18
|
# @param tags [Hash] - optional
|
19
19
|
# @param same_day [Boolean] - optional
|
20
20
|
# @param sec_code [String] - optional
|
21
|
-
def initialize(account_id
|
22
|
-
addenda
|
21
|
+
def initialize(account_id:, amount:, direction:, counterparty:, description:,
|
22
|
+
addenda: nil, idempotency_key: nil, tags: nil, same_day: nil, sec_code: nil)
|
23
23
|
@account_id = account_id
|
24
24
|
@amount = amount
|
25
25
|
@direction = direction
|
@@ -34,27 +34,37 @@ module Unit
|
|
34
34
|
|
35
35
|
def to_json_api
|
36
36
|
payload = {
|
37
|
-
"data":
|
38
|
-
"type": "achPayment",
|
39
|
-
"attributes": {
|
40
|
-
amount: amount,
|
41
|
-
direction: direction,
|
42
|
-
counterparty: counterparty.represent,
|
43
|
-
description: description,
|
44
|
-
addenda: addenda,
|
45
|
-
idempotencyKey: idempotency_key,
|
46
|
-
tags: tags,
|
47
|
-
sameDay: same_day,
|
48
|
-
secCode: sec_code
|
49
|
-
},
|
50
|
-
"relationships": {
|
51
|
-
"account": Unit::Types::Relationship.new("account", account_id).to_hash
|
52
|
-
}
|
53
|
-
}
|
37
|
+
"data": to_hash
|
54
38
|
}
|
55
39
|
payload[:data][:attributes].compact!
|
56
40
|
payload.to_json
|
57
41
|
end
|
42
|
+
|
43
|
+
def to_hash
|
44
|
+
{
|
45
|
+
"type": "achPayment",
|
46
|
+
"attributes": {
|
47
|
+
amount: amount,
|
48
|
+
direction: direction,
|
49
|
+
counterparty: counterparty.represent,
|
50
|
+
description: description,
|
51
|
+
addenda: addenda,
|
52
|
+
idempotencyKey: idempotency_key,
|
53
|
+
tags: tags,
|
54
|
+
sameDay: same_day,
|
55
|
+
secCode: sec_code
|
56
|
+
},
|
57
|
+
"relationships": {
|
58
|
+
"account": Unit::Types::Relationship.new("account", account_id).to_hash
|
59
|
+
}
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
def change_attributes
|
64
|
+
payload = to_hash
|
65
|
+
payload[:attributes].compact!
|
66
|
+
payload
|
67
|
+
end
|
58
68
|
end
|
59
69
|
end
|
60
70
|
end
|