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,113 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to create a proprietor application
|
|
4
|
+
# @see https://docs.unit.co/applications#create-sole-proprietor-application
|
|
5
|
+
module Unit
|
|
6
|
+
module Application
|
|
7
|
+
class CreateSoleProprietorApplicationRequest
|
|
8
|
+
attr_reader :ssn, :passport, :nationality, :full_name, :date_of_birth,
|
|
9
|
+
:address, :phone, :email, :sole_proprietorship, :ein, :industry,
|
|
10
|
+
:dba, :power_of_attorney_agent, :evaluation_params, :occupation,
|
|
11
|
+
:annual_income, :source_of_income, :annual_revenue, :number_of_employees,
|
|
12
|
+
:business_vertical, :website, :ip, :tags, :idempotency_key,
|
|
13
|
+
:device_fingerprints, :jwt_subject
|
|
14
|
+
|
|
15
|
+
# @param nationality [String]
|
|
16
|
+
# @param full_name [FullName]
|
|
17
|
+
# @param date_of_birth [Date]
|
|
18
|
+
# @param address [Address]
|
|
19
|
+
# @param phone [Phone]
|
|
20
|
+
# @param email [String]
|
|
21
|
+
# @param sole_proprietorship [Boolean]
|
|
22
|
+
# @param industry [String]
|
|
23
|
+
# @param ssn [String] - optional
|
|
24
|
+
# @param passport [String] - optional
|
|
25
|
+
# @param ein [String] - optional
|
|
26
|
+
# @param dba [String] - optional
|
|
27
|
+
# @param power_of_attorney_agent [PowerOfAttorneyAgent] - optional
|
|
28
|
+
# @param evaluation_params [EvaluationParams] - optional
|
|
29
|
+
# @param occupation [String] - optional
|
|
30
|
+
# @param annual_income [String] - optional
|
|
31
|
+
# @param source_of_income [String] - optional
|
|
32
|
+
# @param annual_revenue [String] - optional
|
|
33
|
+
# @param number_of_employees [String] - optional
|
|
34
|
+
# @param business_vertical [String] - optional
|
|
35
|
+
# @param website [String] - optional
|
|
36
|
+
# @param ip [String] - optional
|
|
37
|
+
# @param tags [Hash] - optional
|
|
38
|
+
# @param idempotency_key [String] - optional
|
|
39
|
+
# @param device_fingerprints [Array<DeviceFingerprint>] - optional
|
|
40
|
+
# @param jwt_subject [String] - optional
|
|
41
|
+
def initialize(nationality, full_name, date_of_birth, address, phone,
|
|
42
|
+
email, industry, ssn = nil, passport = nil, ein = nil, dba = nil, power_of_attorney_agent = nil, evaluation_params = nil,
|
|
43
|
+
occupation = nil, annual_income = nil, source_of_income = nil, annual_revenue = nil,
|
|
44
|
+
number_of_employees = nil, business_vertical = nil, website = nil, ip = nil, tags = nil,
|
|
45
|
+
idempotency_key = nil, device_fingerprints = nil, jwt_subject = nil, sole_proprietorship: true)
|
|
46
|
+
@ssn = ssn
|
|
47
|
+
@passport = passport
|
|
48
|
+
@nationality = nationality
|
|
49
|
+
@full_name = full_name
|
|
50
|
+
@date_of_birth = date_of_birth
|
|
51
|
+
@address = address
|
|
52
|
+
@phone = phone
|
|
53
|
+
@email = email
|
|
54
|
+
@sole_proprietorship = sole_proprietorship
|
|
55
|
+
@ein = ein
|
|
56
|
+
@industry = industry
|
|
57
|
+
@dba = dba
|
|
58
|
+
@power_of_attorney_agent = power_of_attorney_agent
|
|
59
|
+
@evaluation_params = evaluation_params
|
|
60
|
+
@occupation = occupation
|
|
61
|
+
@annual_income = annual_income
|
|
62
|
+
@source_of_income = source_of_income
|
|
63
|
+
@annual_revenue = annual_revenue
|
|
64
|
+
@number_of_employees = number_of_employees
|
|
65
|
+
@business_vertical = business_vertical
|
|
66
|
+
@website = website
|
|
67
|
+
@ip = ip
|
|
68
|
+
@tags = tags
|
|
69
|
+
@idempotency_key = idempotency_key
|
|
70
|
+
@device_fingerprints = device_fingerprints
|
|
71
|
+
@jwt_subject = jwt_subject
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def to_json_api
|
|
75
|
+
payload = {
|
|
76
|
+
data: {
|
|
77
|
+
type: "individualApplication",
|
|
78
|
+
attributes: {
|
|
79
|
+
ssn: ssn,
|
|
80
|
+
passport: passport,
|
|
81
|
+
nationality: nationality,
|
|
82
|
+
fullName: full_name.represent,
|
|
83
|
+
dateOfBirth: date_of_birth,
|
|
84
|
+
address: address.represent,
|
|
85
|
+
phone: phone&.represent,
|
|
86
|
+
email: email,
|
|
87
|
+
soleProprietorship: sole_proprietorship,
|
|
88
|
+
ein: ein,
|
|
89
|
+
industry: industry,
|
|
90
|
+
dba: dba,
|
|
91
|
+
powerOfAttorneyAgent: power_of_attorney_agent&.represent,
|
|
92
|
+
evaluationParams: evaluation_params&.represent,
|
|
93
|
+
occupation: occupation,
|
|
94
|
+
annualIncome: annual_income,
|
|
95
|
+
sourceOfIncome: source_of_income,
|
|
96
|
+
annualRevenue: annual_revenue,
|
|
97
|
+
numberOfEmployees: number_of_employees,
|
|
98
|
+
businessVertical: business_vertical,
|
|
99
|
+
website: website,
|
|
100
|
+
ip: ip,
|
|
101
|
+
tags: tags,
|
|
102
|
+
idempotencyKey: idempotency_key,
|
|
103
|
+
deviceFingerprints: device_fingerprints&.map(&:represent),
|
|
104
|
+
jwtSubject: jwt_subject
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
payload[:data][:attributes].compact!
|
|
109
|
+
payload.to_json
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Request to create a trust application
|
|
4
|
+
# @see https://docs.unit.co/applications#create-trust-application
|
|
5
|
+
module Unit
|
|
6
|
+
module Application
|
|
7
|
+
class CreateTrustApplicationRequest
|
|
8
|
+
attr_reader :name, :state_of_incorporation, :revocability, :source_of_funds, :tax_id,
|
|
9
|
+
:grantor, :trustees, :beneficiaries, :contact, :ip, :tags, :idempotency_key, :device_fingerprints
|
|
10
|
+
|
|
11
|
+
# @param name [String]
|
|
12
|
+
# @param state_of_incorporation [String]
|
|
13
|
+
# @param revocability [String]
|
|
14
|
+
# @param source_of_funds [String]
|
|
15
|
+
# @param tax_id [String]
|
|
16
|
+
# @param grantor [Grantor]
|
|
17
|
+
# @param trustees [Array<Trustee>]
|
|
18
|
+
# @param beneficiaries [Array<Beneficiary>]
|
|
19
|
+
# @param contact [TrustContact]
|
|
20
|
+
# @param ip [String] - optional
|
|
21
|
+
# @param tags [Hash] - optional
|
|
22
|
+
# @param idempotency_key [String] - optional
|
|
23
|
+
# @param device_fingerprints [Array<DeviceFingerprint>] - optional
|
|
24
|
+
def initialize(name, state_of_incorporation, revocability, source_of_funds, tax_id,
|
|
25
|
+
grantor, trustees, beneficiaries, contact, ip = nil, tags = nil, idempotency_key = nil, device_fingerprints = nil)
|
|
26
|
+
@name = name
|
|
27
|
+
@state_of_incorporation = state_of_incorporation
|
|
28
|
+
@revocability = revocability
|
|
29
|
+
@source_of_funds = source_of_funds
|
|
30
|
+
@tax_id = tax_id
|
|
31
|
+
@grantor = grantor
|
|
32
|
+
@trustees = trustees
|
|
33
|
+
@beneficiaries = beneficiaries
|
|
34
|
+
@contact = contact
|
|
35
|
+
@ip = ip
|
|
36
|
+
@tags = tags
|
|
37
|
+
@idempotency_key = idempotency_key
|
|
38
|
+
@device_fingerprints = device_fingerprints
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def to_json_api
|
|
42
|
+
payload = {
|
|
43
|
+
data: {
|
|
44
|
+
type: "trustApplication",
|
|
45
|
+
attributes: {
|
|
46
|
+
name: name,
|
|
47
|
+
stateOfIncorporation: state_of_incorporation,
|
|
48
|
+
revocability: revocability,
|
|
49
|
+
sourceOfFunds: source_of_funds,
|
|
50
|
+
taxId: tax_id,
|
|
51
|
+
grantor: grantor&.represent,
|
|
52
|
+
trustees: trustees,
|
|
53
|
+
beneficiaries: beneficiaries,
|
|
54
|
+
contact: contact&.represent,
|
|
55
|
+
ip: ip,
|
|
56
|
+
tags: tags,
|
|
57
|
+
idempotencyKey: idempotency_key,
|
|
58
|
+
deviceFingerprints: device_fingerprints
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
payload[:data][:attributes].compact!
|
|
63
|
+
payload.to_json
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -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
|