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
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to update a trust application
|
4
|
+
# @see https://docs.unit.co/applications/#update-trust-application
|
5
|
+
module Unit
|
6
|
+
module Application
|
7
|
+
class PatchTrustApplicationRequest
|
8
|
+
attr_reader :application_id, :tags
|
9
|
+
|
10
|
+
# @param application_id [String]
|
11
|
+
# @param tags [Hash] - optional
|
12
|
+
def initialize(application_id, tags = nil)
|
13
|
+
@application_id = application_id
|
14
|
+
@tags = tags
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_json_api
|
18
|
+
payload = {
|
19
|
+
data: {
|
20
|
+
type: "trustApplication",
|
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,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module ApplicationForm
|
5
|
+
APPLICATION_FORM_LIST_LIMIT = 100
|
6
|
+
APPLICATION_FORM_LIST_OFFSET = 0
|
7
|
+
autoload :CreateApplicationFormRequest, "unit/models/application_form/create_application_form_request"
|
8
|
+
autoload :ListApplicationFormParams, "unit/models/application_form/list_application_form_params"
|
9
|
+
class << self
|
10
|
+
# Create an application form by calling Unit's API
|
11
|
+
# @see https://docs.unit.co/application-forms/#create-application-form
|
12
|
+
# @param tags [Hash] - optional
|
13
|
+
# @param applicant_details [ApplicationFormPrefill] - optional
|
14
|
+
# @parma allowed_application_types [Array<String>] - optional
|
15
|
+
# @param lang [String] - optional
|
16
|
+
# @param settings_override [ApplicationFormSettingsOverride] - optional
|
17
|
+
# @param require_id_verification [RequireIdVerification] - optional
|
18
|
+
# @param hide_application_progress_tracker [Boolean] - optional
|
19
|
+
def create_application_form(tags: nil, applicant_details: nil, allowed_application_types: nil, lang: nil, settings_override: nil, require_id_verification: nil, hide_application_progress_tracker: nil)
|
20
|
+
request = Unit::ApplicationForm::CreateApplicationFormRequest.new(tags, applicant_details, allowed_application_types, lang, settings_override, require_id_verification, hide_application_progress_tracker)
|
21
|
+
Unit::Resource::ApplicationFormResource.create_application_form(request)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Get an application form by calling Unit's API
|
25
|
+
# @see https://docs.unit.co/application-forms#get-application-form-by-id
|
26
|
+
# @param application_form_id [String]
|
27
|
+
def get_application_form(application_form_id)
|
28
|
+
Unit::Resource::ApplicationFormResource.get_application_form(application_form_id)
|
29
|
+
end
|
30
|
+
|
31
|
+
# List application forms by calling Unit's API
|
32
|
+
# @see https://docs.unit.co/application-forms#list-application-forms
|
33
|
+
# @param limit [Integer] - optional
|
34
|
+
# @param offset [Integer] - optional
|
35
|
+
# @param tags [Hash] - optional
|
36
|
+
# @param sort [String] - optional
|
37
|
+
def list_application_forms(limit: APPLICATION_FORM_LIST_LIMIT, offset: APPLICATION_FORM_LIST_OFFSET, tags: nil, sort: nil)
|
38
|
+
request = Unit::ApplicationForm::ListApplicationFormParams.new(limit, offset, tags, sort)
|
39
|
+
Unit::Resource::ApplicationFormResource.list_application_forms(request)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
# Create application form request
|
5
|
+
# @see https://docs.unit.co/application-forms/#create-application-form
|
6
|
+
module ApplicationForm
|
7
|
+
class CreateApplicationFormRequest
|
8
|
+
attr_reader :tags, :applicant_details, :allowed_application_types, :lang,
|
9
|
+
:settings_override, :require_id_verification, :hide_application_progress_tracker
|
10
|
+
|
11
|
+
# @param tags [Hash] - optional
|
12
|
+
# @param applicant_details [ApplicationFormPrefill] - optional
|
13
|
+
# @parma allowed_application_types [Array<String>] - optional
|
14
|
+
# @param lang [String] - optional
|
15
|
+
# @param settings_override [ApplicationFormSettingsOverride] - optional
|
16
|
+
# @param require_id_verification [RequireIdVerification] - optional
|
17
|
+
# @param hide_application_progress_tracker [Boolean] - optional
|
18
|
+
def initialize(tags = nil, applicant_details = nil, allowed_application_types = nil, lang = nil, settings_override = nil, require_id_verification = nil, hide_application_progress_tracker = nil)
|
19
|
+
@tags = tags
|
20
|
+
@applicant_details = applicant_details&.represent
|
21
|
+
@allowed_application_types = allowed_application_types
|
22
|
+
@lang = lang
|
23
|
+
@settings_override = settings_override&.represent
|
24
|
+
@require_id_verification = require_id_verification&.represent
|
25
|
+
@hide_application_progress_tracker = hide_application_progress_tracker
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_json_api
|
29
|
+
payload = {
|
30
|
+
data: {
|
31
|
+
type: "applicationForm",
|
32
|
+
attributes: {
|
33
|
+
tags: tags,
|
34
|
+
applicantDetails: applicant_details,
|
35
|
+
allowedApplicationTypes: allowed_application_types,
|
36
|
+
lang: lang,
|
37
|
+
settingsOverride: settings_override,
|
38
|
+
requireIdVerification: require_id_verification,
|
39
|
+
hideApplicationProgressTracker: hide_application_progress_tracker
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
payload[:data][:attributes].compact!
|
44
|
+
payload.to_json
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# params for listing application form params
|
4
|
+
# @see https://docs.unit.co/application-forms#list-application-forms
|
5
|
+
module Unit
|
6
|
+
module ApplicationForm
|
7
|
+
class ListApplicationFormParams
|
8
|
+
attr_reader :limit, :offset, :tags, :sort
|
9
|
+
|
10
|
+
# @param limit [Integer] - optional
|
11
|
+
# @param offset [Integer] - optional
|
12
|
+
# @param tags [Hash] - optional
|
13
|
+
# @param sort [String] - optional
|
14
|
+
def initialize(limit = APPLICATION_FORM_LIST_LIMIT, offset = APPLICATION_FORM_LIST_OFFSET, tags = nil, sort = nil)
|
15
|
+
@limit = limit
|
16
|
+
@offset = offset
|
17
|
+
@tags = tags
|
18
|
+
@sort = sort
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_hash
|
22
|
+
params = { "page[limit]": limit,
|
23
|
+
"page[offset]": offset,
|
24
|
+
"filter[tags]": tags,
|
25
|
+
"sort": sort }
|
26
|
+
params.compact
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module Authorization
|
5
|
+
AUTHORIZATION_LIMIT = 100
|
6
|
+
AUTHORIZATION_OFFSET = 0
|
7
|
+
|
8
|
+
autoload :GetRequest, "unit/models/authorization/get_request"
|
9
|
+
autoload :ListRequest, "unit/models/authorization/list_request"
|
10
|
+
class << self
|
11
|
+
# Get authorization by id
|
12
|
+
# @see https://docs.unit.co/cards-authorizations#get-authorization-by-id
|
13
|
+
# @param authorization_id [String]
|
14
|
+
# @param include_non_authorized [Boolean] - optional
|
15
|
+
def get_authorization(authorization_id:, include_non_authorized: nil)
|
16
|
+
request = GetRequest.new(authorization_id, include_non_authorized)
|
17
|
+
Unit::Resource::AuthorizationResource.get(request)
|
18
|
+
end
|
19
|
+
|
20
|
+
# List authorizations
|
21
|
+
# @see https://docs.unit.co/cards-authorizations#list-authorizations
|
22
|
+
# @param limit [Integer] - optional
|
23
|
+
# @param offset [Integer] - optional
|
24
|
+
# @param account_id [String] - optional
|
25
|
+
# @param customer_id [String] - optional
|
26
|
+
# @param card_id [String] - optional
|
27
|
+
# @param since [String] - optional
|
28
|
+
# @param until_ [String] - optional
|
29
|
+
# @param include_non_authorized [Boolean] - optional
|
30
|
+
# @param status [Array<String>] - optional
|
31
|
+
# @param merchant_category_code [Array<String>] - optional
|
32
|
+
# @param from_amount [Integer] - optional
|
33
|
+
# @param to_amount [Integer] - optional
|
34
|
+
# @param sort [String] - optional
|
35
|
+
def list_authorizations(limit: AUTHORIZATION_LIMIT, offset: AUTHORIZATION_OFFSET, account_id: nil, customer_id: nil, card_id: nil, since: nil,
|
36
|
+
until_: nil, include_non_authorized: nil, status: nil, merchant_category_code: nil, from_amount: nil, to_amount: nil, sort: nil)
|
37
|
+
request = ListRequest.new(limit, offset, account_id, customer_id, card_id, since, until_, include_non_authorized, status, merchant_category_code, from_amount, to_amount, sort)
|
38
|
+
Unit::Resource::AuthorizationResource.list(request)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to get authorization
|
4
|
+
# @see https://docs.unit.co/cards-authorizations#get-authorization-by-id
|
5
|
+
module Unit
|
6
|
+
module Authorization
|
7
|
+
class GetRequest
|
8
|
+
attr_reader :authorization_id, :include_non_authorized
|
9
|
+
|
10
|
+
# @param authorization_id [String]
|
11
|
+
# @param include_non_authorized [Boolean]
|
12
|
+
def initialize(authorization_id, include_non_authorized = nil)
|
13
|
+
@authorization_id = authorization_id
|
14
|
+
@include_non_authorized = include_non_authorized
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_hash
|
18
|
+
{ 'filter[includeNonAuthorized]': include_non_authorized }.compact
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# List authorizations
|
4
|
+
# @see https://docs.unit.co/cards-authorizations#list-authorizations
|
5
|
+
module Unit
|
6
|
+
module Authorization
|
7
|
+
class ListRequest
|
8
|
+
attr_reader :limit, :offset, :account_id, :customer_id, :card_id, :since,
|
9
|
+
:until_, :include_non_authorized, :status, :merchant_category_code,
|
10
|
+
:from_amount, :to_amount, :sort
|
11
|
+
|
12
|
+
# @param limit [Integer] - optional
|
13
|
+
# @param offset [Integer] - optional
|
14
|
+
# @param account_id [String] - optional
|
15
|
+
# @param customer_id [String] - optional
|
16
|
+
# @param card_id [String] - optional
|
17
|
+
# @param since [String] - optional
|
18
|
+
# @param until_ [String] - optional
|
19
|
+
# @param include_non_authorized [Boolean] - optional
|
20
|
+
# @param status [Array<String>] - optional
|
21
|
+
# @param merchant_category_code [Array<String>] - optional
|
22
|
+
# @param from_amount [Integer] - optional
|
23
|
+
# @param to_amount [Integer] - optional
|
24
|
+
# @param sort [String] - optional
|
25
|
+
def initialize(limit = AUTHORIZATION_LIMIT, offset = AUTHORIZATION_OFFSET, account_id = nil, customer_id = nil, card_id = nil,
|
26
|
+
since = nil, until_ = nil, include_non_authorized = nil, status = nil, merchant_category_code = nil,
|
27
|
+
from_amount = nil, to_amount = nil, sort = nil)
|
28
|
+
@limit = limit
|
29
|
+
@offset = offset
|
30
|
+
@account_id = account_id
|
31
|
+
@customer_id = customer_id
|
32
|
+
@card_id = card_id
|
33
|
+
@since = since
|
34
|
+
@until_ = until_
|
35
|
+
@include_non_authorized = include_non_authorized
|
36
|
+
@status = status
|
37
|
+
@merchant_category_code = merchant_category_code
|
38
|
+
@from_amount = from_amount
|
39
|
+
@to_amount = to_amount
|
40
|
+
@sort = sort
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_hash
|
44
|
+
payload = {
|
45
|
+
"page[limit]": limit,
|
46
|
+
"page[offset]": offset,
|
47
|
+
"filter[accountId]": account_id,
|
48
|
+
"filter[customerId]": customer_id,
|
49
|
+
"filter[cardId]": card_id,
|
50
|
+
"filter[since]": since,
|
51
|
+
"filter[until]": until_,
|
52
|
+
"filter[includeNonAuthorized]": include_non_authorized,
|
53
|
+
"filter[fromAmount]": from_amount,
|
54
|
+
"filter[toAmount]": to_amount,
|
55
|
+
sort: sort
|
56
|
+
}
|
57
|
+
merchant_category_code&.each_with_index&.map do |val, index|
|
58
|
+
params.merge!({ "filter[merchantCategoryCode][#{index}]": val })
|
59
|
+
end
|
60
|
+
status&.each_with_index&.map do |val, index|
|
61
|
+
params.merge!({ "filter[status][#{index}]": val })
|
62
|
+
end
|
63
|
+
payload.compact
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# class for approving the authorization request
|
4
|
+
# @see https://docs.unit.co/cards-authorization-requests/#approve-authorization-request
|
5
|
+
module Unit
|
6
|
+
module AuthorizationRequest
|
7
|
+
class ApproveRequest
|
8
|
+
attr_reader :authorization_request_id, :amount, :funding_account, :tags
|
9
|
+
|
10
|
+
# @param authorization_request_id [String]
|
11
|
+
# @param amount [Integer] - optional
|
12
|
+
# @param funding_account [String] - optional
|
13
|
+
# @param tags [Hash] - optional
|
14
|
+
def initialize(authorization_request_id, amount = nil, funding_account = nil, tags = nil)
|
15
|
+
@authorization_request_id = authorization_request_id
|
16
|
+
@amount = amount
|
17
|
+
@funding_account = funding_account
|
18
|
+
@tags = tags
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_json_api
|
22
|
+
payload = {
|
23
|
+
data: {
|
24
|
+
type: "approveAuthorizationRequest",
|
25
|
+
attributes: {
|
26
|
+
amount: amount,
|
27
|
+
fundingAccount: funding_account,
|
28
|
+
tags: tags
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
payload[:data][:attributes].compact!
|
33
|
+
payload.to_json
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module AuthorizationRequest
|
5
|
+
AUTHORIZATION_REQUEST_LIMIT = 100
|
6
|
+
AUTHORIZATION_REQUEST_OFFSET = 0
|
7
|
+
|
8
|
+
autoload :ApproveRequest, "unit/models/authorization_request/approve_request"
|
9
|
+
autoload :DeclineRequest, "unit/models/authorization_request/decline_request"
|
10
|
+
autoload :ListAuthorizationParams, "unit/models/authorization_request/list_authorization_params"
|
11
|
+
class << self
|
12
|
+
# get authorization request
|
13
|
+
# @see https://docs.unit.co/cards-authorization-requests/#get-authorization-request-by-id
|
14
|
+
# @param authorization_request_id [String]
|
15
|
+
def get_authorization_request(authorization_request_id:)
|
16
|
+
Unit::Resource::AuthorizationRequestResource.get_authorization_request(authorization_request_id)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Approve authorization request
|
20
|
+
# @see https://docs.unit.co/cards-authorization-requests/#approve-authorization-request
|
21
|
+
# @param authorization_request_id [String]
|
22
|
+
# @param amount [Integer] - optional
|
23
|
+
# @param funding_account [String] - optional
|
24
|
+
# @param tags [Hash] - optional
|
25
|
+
def approve_authorization_request(authorization_request_id:, amount:, funding_account:, tags:)
|
26
|
+
request = ApproveRequest.new(authorization_request_id, amount, funding_account, tags)
|
27
|
+
Unit::Resource::AuthorizationRequestResource.approve(request)
|
28
|
+
end
|
29
|
+
|
30
|
+
# decline authorization request
|
31
|
+
# @see https://docs.unit.co/cards-authorization-requests/#decline-authorization-request
|
32
|
+
# @param authorization_request_id [String]
|
33
|
+
# @param reason [String]
|
34
|
+
def decline_authorization_request(authorization_request_id:, reason:)
|
35
|
+
request = DeclineRequest.new(authorization_request_id, reason)
|
36
|
+
Unit::Resource::AuthorizationRequestResource.decline(request)
|
37
|
+
end
|
38
|
+
|
39
|
+
# list params for the authorization request
|
40
|
+
# @see https://docs.unit.co/cards-authorization-requests/#list-authorization-requests
|
41
|
+
# @param limit [Integer] - optional
|
42
|
+
# @param offset [Integer] - optional
|
43
|
+
# @param account_id [String] - optional
|
44
|
+
# @param customer_id [String] - optional
|
45
|
+
# @param merchant_category_code [Array] - optional
|
46
|
+
# @param from_amount [Integer] - optional
|
47
|
+
# @param to_amount [Integer]- optional
|
48
|
+
def list_authorization_requests(limit = AUTHORIZATION_REQUEST_LIMIT, offset = AUTHORIZATION_REQUEST_OFFSET,
|
49
|
+
account_id: nil, customer_id: nil, merchant_category_code: nil, from_amount: nil, to_amount: nil)
|
50
|
+
params = ListAuthorizationParams.new(limit, offset, account_id, customer_id, merchant_category_code, from_amount, to_amount)
|
51
|
+
Unit::Resource::AuthorizationRequestResource.list(params)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# class for declining the authorization request
|
4
|
+
# @see https://docs.unit.co/cards-authorization-requests/#decline-authorization-request
|
5
|
+
module Unit
|
6
|
+
module AuthorizationRequest
|
7
|
+
class DeclineRequest
|
8
|
+
attr_reader :authorization_request_id, :reason
|
9
|
+
|
10
|
+
# @param authorization_request_id [String]
|
11
|
+
# @param reason [String]
|
12
|
+
def initialize(authorization_request_id, reason)
|
13
|
+
@authorization_request_id = authorization_request_id
|
14
|
+
@reason = reason
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_json_api
|
18
|
+
payload = {
|
19
|
+
data: {
|
20
|
+
type: "declineAuthorizationRequest",
|
21
|
+
attributes: {
|
22
|
+
reason: reason
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
payload[:data][:attributes].compact!
|
27
|
+
payload.to_json
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# list params for the authorization request
|
4
|
+
# @see https://docs.unit.co/cards-authorization-requests/#list-authorization-requests
|
5
|
+
module Unit
|
6
|
+
module AuthorizationRequest
|
7
|
+
class ListAuthorizationParams
|
8
|
+
attr_reader :limit, :offset, :account_id, :customer_id, :merchant_category_code,
|
9
|
+
:from_amount, :to_amount
|
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 merchant_category_code [Array] - optional
|
16
|
+
# @param from_amount [Integer] - optional
|
17
|
+
# @param to_amount [Integer]- optional
|
18
|
+
def initialize(limit = AUTHORIZATION_REQUEST_LIMIT, offset = AUTHORIZATION_REQUEST_OFFSET,
|
19
|
+
account_id = nil, customer_id = nil, merchant_category_code = nil,
|
20
|
+
from_amount = nil, to_amount = nil)
|
21
|
+
@limit = limit
|
22
|
+
@offset = offset
|
23
|
+
@account_id = account_id
|
24
|
+
@customer_id = customer_id
|
25
|
+
@merchant_category_code = merchant_category_code
|
26
|
+
@from_amount = from_amount
|
27
|
+
@to_amount = to_amount
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_hash
|
31
|
+
params = { "page[limit]": limit,
|
32
|
+
"page[offset]": offset,
|
33
|
+
"filter[accountId]": account_id,
|
34
|
+
"filter[customerId]": customer_id,
|
35
|
+
"filter[fromAmount]": from_amount,
|
36
|
+
"filter[toAmount]": to_amount }
|
37
|
+
merchant_category_code&.each_with_index&.map do |val, index|
|
38
|
+
params.merge!({ "filter[merchantCategoryCode][#{index}]": val })
|
39
|
+
end
|
40
|
+
params.compact
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -10,6 +10,12 @@ module Unit
|
|
10
10
|
autoload :CreateIndividualVirtualCardRequest, "unit/models/card/create_individual_virtual_card_request"
|
11
11
|
autoload :ReplaceCardRequest, "unit/models/card/replace_card_request"
|
12
12
|
autoload :ListCardParams, "unit/models/card/list_card_params"
|
13
|
+
autoload :CreateBusinessCreditCardRequest, "unit/models/card/create_business_credit_card_request"
|
14
|
+
autoload :CreateBusinessVirtualCreditCardRequest, "unit/models/card/create_business_virtual_credit_card_request"
|
15
|
+
autoload :PatchBusinessCardRequest, "unit/models/card/patch_business_card_request"
|
16
|
+
autoload :PatchBusinessCreditCardRequest, "unit/models/card/patch_business_credit_card_request"
|
17
|
+
autoload :PatchBusinessVirtualCardRequest, "unit/models/card/patch_business_virtual_card_request"
|
18
|
+
autoload :PatchBusinessVirtualCreditCardRequest, "unit/models/card/patch_business_virtual_credit_card_request"
|
13
19
|
|
14
20
|
class << self
|
15
21
|
# Create a new individual debit card by calling Unit's API
|
@@ -22,10 +28,11 @@ module Unit
|
|
22
28
|
# @param tags [Hash] - optional
|
23
29
|
# @param limits [Hash] - optional
|
24
30
|
# @param print_only_business_name [String] - optional
|
31
|
+
# @param expiry_date [String] - optional
|
25
32
|
def create_individual_debit_card(account_id:, customer_id: nil, shipping_address: nil, design: nil, additional_embossed_text: nil,
|
26
|
-
idempotency_key: nil, tags: nil, limits: nil, print_only_business_name: nil)
|
33
|
+
idempotency_key: nil, tags: nil, limits: nil, print_only_business_name: nil, expiry_date: nil)
|
27
34
|
request = CreateIndividualDebitCardRequest.new(account_id, customer_id, shipping_address, design, additional_embossed_text,
|
28
|
-
idempotency_key, tags, limits, print_only_business_name)
|
35
|
+
idempotency_key, tags, limits, print_only_business_name, expiry_date)
|
29
36
|
Unit::Resource::CardResource.create_card(request)
|
30
37
|
end
|
31
38
|
|
@@ -43,13 +50,104 @@ module Unit
|
|
43
50
|
# @param tags [Hash] - optional
|
44
51
|
# @param limits [Hash] - optional
|
45
52
|
# @param print_only_business_name [Boolean] - optional
|
53
|
+
# @param expiry_date [String] - optional
|
46
54
|
def create_business_debit_card(account_id:, full_name:, date_of_birth:, address:, phone:, email:, shipping_address: nil,
|
47
|
-
design: nil, additional_embossed_text: nil, idempotency_key: nil, tags: nil, limits: nil, print_only_business_name: nil)
|
55
|
+
design: nil, additional_embossed_text: nil, idempotency_key: nil, tags: nil, limits: nil, print_only_business_name: nil, expiry_date: nil)
|
48
56
|
request = CreateBusinessDebitCardRequest.new(account_id, full_name, date_of_birth, address, shipping_address, phone, email, design, additional_embossed_text,
|
49
|
-
idempotency_key, tags, limits, print_only_business_name)
|
57
|
+
idempotency_key, tags, limits, print_only_business_name, expiry_date)
|
50
58
|
Unit::Resource::CardResource.create_card(request)
|
51
59
|
end
|
52
60
|
|
61
|
+
# Create a new business credit card by calling Unit's API
|
62
|
+
# @see https://guides.unit.co/business-charge-cards/#what-is-a-charge-card
|
63
|
+
# @param account_id [String]
|
64
|
+
# @param full_name [FullName]
|
65
|
+
# @param date_of_birth [Date]
|
66
|
+
# @param address [Address]
|
67
|
+
# @param shipping_address [Address] - optional
|
68
|
+
# @param phone [Phone] - optional
|
69
|
+
# @param email [String] - optional
|
70
|
+
# @param design [String] - optional
|
71
|
+
# @param additional_embossed_text [String] - optional
|
72
|
+
# @param idempotency_key [String] - optional
|
73
|
+
# @param tags [Hash] - optional
|
74
|
+
# @param limits [Hash] - optional
|
75
|
+
# @param print_only_business_name [Boolean] - optional
|
76
|
+
# @param expiry_date [String] - optional
|
77
|
+
def create_business_credit_card(account_id:, full_name:, date_of_birth:, address:, shipping_address: nil, phone: nil, email: nil, design: nil, additional_embossed_text: nil, idempotency_key: nil, tags: nil, limits: nil, print_only_business_name: nil, expiry_date: nil)
|
78
|
+
request = CreateBusinessCreditCardRequest.new(account_id, full_name, date_of_birth, address, shipping_address, phone, email, design, additional_embossed_text, idempotency_key, tags, limits, print_only_business_name, expiry_date)
|
79
|
+
Unit::Resource::CardResource.create_card(request)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Create a new business virtual credit card by calling Unit's API
|
83
|
+
# @see https://docs.unit.co/cards#create-business-virtual-debit-card
|
84
|
+
# @param account_id [String]
|
85
|
+
# @param type [String]
|
86
|
+
# @param idempotency_key [String] - optional
|
87
|
+
# @param tags [Hash] - optional
|
88
|
+
# @param limits [Hash] - optional
|
89
|
+
# @param expiry_date [String] - optional
|
90
|
+
def create_business_virtual_credit_card(account_id:, full_name:, date_of_birth:, address:, phone: nil, email: nil, idempotency_key: nil, tags: nil, limits: nil, expiry_date: nil)
|
91
|
+
request = CreateBusinessVirtualCreditCardRequest.new(account_id, full_name, date_of_birth, address, phone, email, idempotency_key, tags, limits, expiry_date)
|
92
|
+
Unit::Resource::CardResource.create_card(request)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Update a business debit card by calling Unit's API
|
96
|
+
# @see https://docs.unit.co/cards/#update-business-debit-card
|
97
|
+
# @param card_id [String]
|
98
|
+
# @param shipping_address [Address] - optional
|
99
|
+
# @param address [Address] - optional
|
100
|
+
# @param phone [Phone] - optional
|
101
|
+
# @param email [String] - optional
|
102
|
+
# @param design [String] - optional
|
103
|
+
# @param tags [Hash] - optional
|
104
|
+
# @param limits [Hash] - optional
|
105
|
+
def update_business_debit_card(card_id:, shipping_address: nil, address: nil, phone: nil, email: nil, design: nil, tags: nil, limits: nil)
|
106
|
+
request = PatchBusinessCardRequest.new(card_id, shipping_address, address, phone, email, design, tags, limits)
|
107
|
+
Unit::Resource::CardResource.update(request)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Update a business credit card by calling Unit's API
|
111
|
+
# @see https://guides.unit.co/business-charge-cards/
|
112
|
+
# @param card_id [String]
|
113
|
+
# @param shipping_address [Address] - optional
|
114
|
+
# @param address [Address] - optional
|
115
|
+
# @param phone [Phone] - optional
|
116
|
+
# @param email [String] - optional
|
117
|
+
# @param design [String] - optional
|
118
|
+
# @param tags [Hash] - optional
|
119
|
+
# @param limits [Hash] - optional
|
120
|
+
def update_business_credit_card(card_id:, shipping_address: nil, address: nil, phone: nil, email: nil, design: nil, tags: nil, limits: nil)
|
121
|
+
request = PatchBusinessCreditCardRequest.new(card_id, shipping_address, address, phone, email, design, tags, limits)
|
122
|
+
Unit::Resource::CardResource.update(request)
|
123
|
+
end
|
124
|
+
|
125
|
+
# Update a business virtual debit card by calling Unit's API
|
126
|
+
# @see https://docs.unit.co/cards/#update-business-virtual-debit-card
|
127
|
+
# @param card_id [String]
|
128
|
+
# @param address [Address] - optional
|
129
|
+
# @param phone [Phone] - optional
|
130
|
+
# @param email [String] - optional
|
131
|
+
# @param tags [Hash] - optional
|
132
|
+
# @param limits [Hash] - optional
|
133
|
+
def update_business_virtual_debit_card(card_id:, address: nil, phone: nil, email: nil, tags: nil, limits: nil)
|
134
|
+
request = PatchBusinessVirtualCardRequest.new(card_id, address, phone, email, tags, limits)
|
135
|
+
Unit::Resource::CardResource.update(request)
|
136
|
+
end
|
137
|
+
|
138
|
+
# Update a business virtual credit card by calling Unit's API
|
139
|
+
# @see https://guides.unit.co/business-charge-cards/
|
140
|
+
# @param card_id [String]
|
141
|
+
# @param address [Address] - optional
|
142
|
+
# @param phone [Phone] - optional
|
143
|
+
# @param email [String] - optional
|
144
|
+
# @param tags [Hash] - optional
|
145
|
+
# @param limits [Hash] - optional
|
146
|
+
def update_business_virtual_credit_card(card_id:, address: nil, phone: nil, email: nil, tags: nil, limits: nil)
|
147
|
+
request = PatchBusinessVirtualCreditCardRequest.new(card_id, address, phone, email, tags, limits)
|
148
|
+
Unit::Resource::CardResource.update(request)
|
149
|
+
end
|
150
|
+
|
53
151
|
# Create a new individual virtual card by calling Unit's API
|
54
152
|
# @see https://docs.unit.co/cards#create-individual-virtual-debit-card
|
55
153
|
# @param account_id [String]
|
@@ -0,0 +1,29 @@
|
|
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 CreateBusinessCreditCardRequest < CreateBusinessDebitCardRequest
|
8
|
+
# @param account_id [String]
|
9
|
+
# @param full_name [FullName]
|
10
|
+
# @param date_of_birth [Date]
|
11
|
+
# @param address [Address]
|
12
|
+
# @param shipping_address [Address] - optional
|
13
|
+
# @param phone [Phone] - optional
|
14
|
+
# @param email [String] - optional
|
15
|
+
# @param design [String] - optional
|
16
|
+
# @param additional_embossed_text [String] - optional
|
17
|
+
# @param idempotency_key [String] - optional
|
18
|
+
# @param tags [Hash] - optional
|
19
|
+
# @param limits [Hash] - optional
|
20
|
+
# @param print_only_business_name [Boolean] - optional
|
21
|
+
# @param expiry_date [String] - optional
|
22
|
+
def initialize(account_id, full_name, date_of_birth, address, shipping_address = nil, phone = nil, email = nil, design = nil,
|
23
|
+
additional_embossed_text = nil, idempotency_key = nil, tags = nil, limits = nil, print_only_business_name = nil, expiry_date = nil)
|
24
|
+
super
|
25
|
+
@type = "businessCreditCard"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|