unit_ruby_sdk 0.1.2 → 0.1.4
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/.rubocop.yml +3 -0
- data/Gemfile +0 -10
- data/README.md +97 -1
- data/lib/unit/api_resources/account_resource.rb +125 -0
- data/lib/unit/api_resources/api_token_resource.rb +59 -0
- data/lib/unit/api_resources/application_resource.rb +9 -9
- data/lib/unit/api_resources/base_resource.rb +3 -11
- data/lib/unit/api_resources/customer_resource.rb +12 -11
- data/lib/unit/api_resources/payment_resource.rb +32 -0
- data/lib/unit/api_resources/transaction_resource.rb +40 -0
- data/lib/unit/errors/unit_error.rb +7 -13
- data/lib/unit/errors/unit_error_payload.rb +15 -2
- data/lib/unit/models/account/account.rb +157 -0
- data/lib/unit/models/account/deposit/account_owners_request.rb +29 -0
- data/lib/unit/models/account/deposit/balance_history_request.rb +39 -0
- data/lib/unit/models/account/deposit/close_deposit_account_request.rb +36 -0
- data/lib/unit/models/account/deposit/create_deposit_account_request.rb +39 -0
- data/lib/unit/models/account/deposit/freeze_account_request.rb +36 -0
- data/lib/unit/models/account/deposit/list_account_params.rb +48 -0
- data/lib/unit/models/account/deposit/patch_deposit_account_request.rb +36 -0
- data/lib/unit/models/api_token/api_token.rb +89 -0
- data/lib/unit/models/api_token/customer/create_customer_token_request.rb +41 -0
- data/lib/unit/models/api_token/customer/create_customer_token_verification.rb +37 -0
- data/lib/unit/models/api_token/customer/create_token_using_jwt_request.rb +30 -0
- data/lib/unit/models/api_token/org/create_api_token_request.rb +40 -0
- data/lib/unit/models/application/application.rb +127 -0
- data/lib/unit/models/application/create_business_application_request.rb +7 -7
- data/lib/unit/models/application/create_individual_application_request.rb +14 -14
- data/lib/unit/models/application/list_application_params.rb +4 -4
- data/lib/unit/models/application/patch_application_request.rb +3 -3
- data/lib/unit/models/application/upload_document_request.rb +1 -1
- data/lib/unit/models/customer/add_authorized_users_request.rb +3 -3
- data/lib/unit/models/customer/archive_customer_request.rb +3 -4
- data/lib/unit/models/customer/customer.rb +96 -0
- data/lib/unit/models/customer/list_customer_params.rb +10 -12
- data/lib/unit/models/customer/patch_business_customer_request.rb +8 -8
- data/lib/unit/models/customer/patch_individual_customer_request.rb +9 -10
- data/lib/unit/models/customer/remove_authorized_users_request.rb +3 -3
- data/lib/unit/models/payment/create_book_payment_request.rb +49 -0
- data/lib/unit/models/payment/patch_book_payment_request.rb +31 -0
- data/lib/unit/models/payment/payment.rb +37 -0
- data/lib/unit/models/transaction/get_transaction_params.rb +28 -0
- data/lib/unit/models/transaction/list_transaction_params.rb +70 -0
- data/lib/unit/models/transaction/patch_tags_request.rb +33 -0
- data/lib/unit/models/transaction/transaction.rb +60 -0
- data/lib/unit/models/unit_response.rb +7 -1
- data/lib/unit/types/authorized_user.rb +1 -1
- data/lib/unit/types/relationship.rb +4 -5
- data/lib/unit/types/relationship_array.rb +14 -12
- data/lib/unit/types/restricted_resource.rb +23 -0
- data/lib/unit/utils/http_helper.rb +56 -0
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +22 -21
- metadata +76 -7
- data/Gemfile.lock +0 -133
@@ -0,0 +1,127 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module Application
|
5
|
+
APPLICATION_LIST_OFFSET = 0
|
6
|
+
APPLICATION_LIST_LIMIT = 100
|
7
|
+
autoload :CreateBusinessApplicationRequest, "unit/models/application/create_business_application_request"
|
8
|
+
autoload :CreateIndividualApplicationRequest, "unit/models/application/create_individual_application_request"
|
9
|
+
autoload :ListApplicationParams, "unit/models/application/list_application_params"
|
10
|
+
autoload :PatchApplicationRequest, "unit/models/application/patch_application_request"
|
11
|
+
autoload :UploadDocumentRequest, "unit/models/application/upload_document_request"
|
12
|
+
|
13
|
+
class << self
|
14
|
+
# Create a new business application by calling Unit's API
|
15
|
+
# @param name [String]
|
16
|
+
# @param address [Address]
|
17
|
+
# @param phone [Phone]
|
18
|
+
# @param state_of_incorporation [String]
|
19
|
+
# @param ein [String]
|
20
|
+
# @param industry [String]
|
21
|
+
# @param contact [BusinessContact]
|
22
|
+
# @param officer [Officer]
|
23
|
+
# @param beneficial_owners [Array]
|
24
|
+
# @param entity_type [String]
|
25
|
+
# @param dba [String] - optional
|
26
|
+
# @param ip [String] - optional
|
27
|
+
# @param website [String] - optional
|
28
|
+
# @param tags [Hash] - optional
|
29
|
+
# @param idempotency_key [String] - optional
|
30
|
+
# @param device_fingerprints [DeviceFingerprint] - optional
|
31
|
+
# @return [UnitResponse, UnitError]
|
32
|
+
def create_business_application(name:, address:, phone:, state_of_incorporation:, ein:, industry:, contact:,
|
33
|
+
officer:, beneficial_owners:, entity_type:, dba: nil, ip: nil, website: nil,
|
34
|
+
tags: nil, idempotency_key: nil, device_fingerprints: nil)
|
35
|
+
|
36
|
+
request = CreateBusinessApplicationRequest.new(
|
37
|
+
name, address, phone, state_of_incorporation, ein, industry, contact, officer,
|
38
|
+
beneficial_owners, entity_type, dba, ip, website, tags, idempotency_key, device_fingerprints
|
39
|
+
)
|
40
|
+
|
41
|
+
Unit::Resource::ApplicationResource.create_application(request)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Create a new individual application by calling Unit's API
|
45
|
+
# @param ssn [String]
|
46
|
+
# @param full_name [FullName]
|
47
|
+
# @param date_of_birth [Date]
|
48
|
+
# @param address [Address]
|
49
|
+
# @param email [String]
|
50
|
+
# @param phone [Phone]
|
51
|
+
# @param ip [String] - optional
|
52
|
+
# @param ein [String] - optional
|
53
|
+
# @param industry [String] - optional
|
54
|
+
# @param dba [String] - optional
|
55
|
+
# @param sole_proprietorship [Boolean] - optional
|
56
|
+
# @param passport [String] - optional
|
57
|
+
# @param nationality [String] - optional
|
58
|
+
# @param device_fingerprints [DeviceFingerprint] - optional
|
59
|
+
# @param idempotency_key [String] - optional
|
60
|
+
# @param tags [Hash] - optional
|
61
|
+
# @param jwt_subject [String] - optional
|
62
|
+
# @param power_of_attorney_agent [PowerOfAttorneyAgent] - optional
|
63
|
+
# @param evaluation_params [EvaluationParams] - optional
|
64
|
+
# @return [UnitResponse, UnitError]
|
65
|
+
def create_individual_application(ssn:, full_name:, date_of_birth:, address:, email:, phone:, ip: nil, ein: nil,
|
66
|
+
industry: nil, dba: nil, sole_proprietorship: nil, passport: nil, nationality: nil,
|
67
|
+
device_fingerprints: nil, idempotency_key: nil, tags: nil, jwt_subject: nil,
|
68
|
+
power_of_attorney_agent: nil, evaluation_params: nil)
|
69
|
+
|
70
|
+
request = CreateIndividualApplicationRequest.new(
|
71
|
+
ssn, full_name, date_of_birth, address, email, phone, ip, ein, industry, dba, sole_proprietorship, passport,
|
72
|
+
nationality, device_fingerprints, idempotency_key, tags, jwt_subject, power_of_attorney_agent, evaluation_params
|
73
|
+
)
|
74
|
+
|
75
|
+
Unit::Resource::ApplicationResource.create_application(request)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Update an application by calling Unit's API
|
79
|
+
# @param application_id [String] The application id
|
80
|
+
# @param type [String] The type
|
81
|
+
# @param tags [Hash] The tags
|
82
|
+
# @return [UnitResponse, UnitError]
|
83
|
+
def update_application(application_id:, type:, tags: nil)
|
84
|
+
request = PatchApplicationRequest.new(application_id, type, tags)
|
85
|
+
Unit::Resource::ApplicationResource.update(request)
|
86
|
+
end
|
87
|
+
|
88
|
+
# List applications by calling Unit's API
|
89
|
+
# @param offset [Integer] Number of resources to skip.
|
90
|
+
# @param limit [Integer] The limit Maximum number of resources that will be returned.
|
91
|
+
# @param email [String] Filter applications by email address (case sensitive).
|
92
|
+
# @param tags [String] Filter applications by tags. More information regarding tags: https://docs.unit.co/#tags
|
93
|
+
# @param query [String] Search term according to the: https://docs.unit.co/#full-text-search
|
94
|
+
# @param status [String] Filter applications by status: https://docs.unit.co/applications/#application-statuses
|
95
|
+
# @param sort [String] Sorts the resources by the specified field.
|
96
|
+
# @option sort=createdAt for ascending order
|
97
|
+
# @option sort=-createdAt (leading minus sign) for descending order.
|
98
|
+
# @return [UnitResponse, UnitError]
|
99
|
+
def list_applications(offset: APPLICATION_LIST_OFFSET, limit: APPLICATION_LIST_LIMIT, email: nil, tags: nil, query: nil, status: nil, sort: nil)
|
100
|
+
request = Unit::Application::ListApplicationParams.new(offset, limit, email, tags, query, status, sort)
|
101
|
+
Unit::Resource::ApplicationResource.list_applications(request)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Get an application by calling Unit's API
|
105
|
+
# @param [String] application_id
|
106
|
+
# @return [UnitResponse, UnitError]
|
107
|
+
def get_application(application_id)
|
108
|
+
Unit::Resource::ApplicationResource.get_application(application_id)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Upload an application document by calling Unit's API
|
112
|
+
# @param application_id [String] The application ID
|
113
|
+
# @param document_id [String] The document ID
|
114
|
+
# @param file [String] The file path
|
115
|
+
# @param file_type [String] The file type
|
116
|
+
# @option file_type [String] :pdf
|
117
|
+
# @option file_type [String] :jpg
|
118
|
+
# @option file_type [String] :png
|
119
|
+
# @param is_back_side [Boolean] The file is back side
|
120
|
+
# @return [UnitResponse, UnitError]
|
121
|
+
def upload_document(application_id:, document_id:, file:, file_type:, is_back_side: false)
|
122
|
+
request = UploadDocumentRequest.new(application_id, document_id, file, file_type, is_back_side: is_back_side)
|
123
|
+
Unit::Resource::ApplicationResource.upload(request)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -8,7 +8,7 @@ require "unit/types/beneficial_owner"
|
|
8
8
|
require "unit/types/officer"
|
9
9
|
|
10
10
|
# Request to create a business application
|
11
|
-
#
|
11
|
+
# @see https://docs.unit.co/applications/#create-business-application
|
12
12
|
module Unit
|
13
13
|
module Application
|
14
14
|
class CreateBusinessApplicationRequest
|
@@ -25,12 +25,12 @@ module Unit
|
|
25
25
|
# @param officer [Officer]
|
26
26
|
# @param beneficial_owners [Array]
|
27
27
|
# @param entity_type [String]
|
28
|
-
# @param
|
29
|
-
# @param
|
30
|
-
# @param
|
31
|
-
# @param
|
32
|
-
# @param
|
33
|
-
# @param
|
28
|
+
# @param dba [String] - optional
|
29
|
+
# @param ip [String] - optional
|
30
|
+
# @param website [String] - optional
|
31
|
+
# @param tags [Hash] - optional
|
32
|
+
# @param idempotency_key [String] - optional
|
33
|
+
# @param device_fingerprints [DeviceFingerprint] - optional
|
34
34
|
def initialize(name, address, phone, state_of_incorporation, ein, industry, contact, officer,
|
35
35
|
beneficial_owners, entity_type, dba = nil, ip = nil, website = nil, tags = nil, idempotency_key = nil,
|
36
36
|
device_fingerprints = nil)
|
@@ -6,7 +6,7 @@ require "unit/types/phone"
|
|
6
6
|
require "unit/types/device_fingerprint"
|
7
7
|
|
8
8
|
# Request to create an individual application
|
9
|
-
#
|
9
|
+
# @see https://docs.unit.co/applications/#create-individual-application
|
10
10
|
module Unit
|
11
11
|
module Application
|
12
12
|
class CreateIndividualApplicationRequest
|
@@ -20,19 +20,19 @@ module Unit
|
|
20
20
|
# @param address [Address]
|
21
21
|
# @param email [String]
|
22
22
|
# @param phone [Phone]
|
23
|
-
# @param
|
24
|
-
# @param
|
25
|
-
# @param
|
26
|
-
# @param
|
27
|
-
# @param
|
28
|
-
# @param
|
29
|
-
# @param
|
30
|
-
# @param
|
31
|
-
# @param
|
32
|
-
# @param
|
33
|
-
# @param
|
34
|
-
# @param
|
35
|
-
# @param
|
23
|
+
# @param ip [String] - optional
|
24
|
+
# @param ein [String] - optional
|
25
|
+
# @param industry [String] - optional
|
26
|
+
# @param dba [String] - optional
|
27
|
+
# @param sole_proprietorship [Boolean] - optional
|
28
|
+
# @param passport [String] - optional
|
29
|
+
# @param nationality [String] - optional
|
30
|
+
# @param device_fingerprints [DeviceFingerprint] - optional
|
31
|
+
# @param idempotency_key [String] - optional
|
32
|
+
# @param tags [Hash] - optional
|
33
|
+
# @param jwt_subject [String] - optional
|
34
|
+
# @param power_of_attorney_agent [PowerOfAttorneyAgent] - optional
|
35
|
+
# @param evaluation_params [EvaluationParams] - optional
|
36
36
|
def initialize(ssn, full_name, date_of_birth, address, email, phone, ip = nil, ein = nil, industry = nil, dba = nil, sole_proprietorship = nil, passport = nil,
|
37
37
|
nationality = nil, device_fingerprints = nil, idempotency_key = nil, tags = nil, jwt_subject = nil, power_of_attorney_agent = nil,
|
38
38
|
evaluation_params = nil)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# params for list applications
|
4
|
-
#
|
4
|
+
# @see https://docs.unit.co/applications/#list-applications
|
5
5
|
module Unit
|
6
6
|
module Application
|
7
7
|
class ListApplicationParams
|
@@ -10,13 +10,13 @@ module Unit
|
|
10
10
|
# @param offset [Integer] Number of resources to skip. See pagination: https://docs.unit.co/#intro-pagination
|
11
11
|
# @param limit [Integer] The limit Maximum number of resources that will be returned. Maximum is 1000 resources.
|
12
12
|
# @param email [String] Filter applications by email address (case sensitive).
|
13
|
-
# @param tags [
|
13
|
+
# @param tags [Hash] Filter applications by tags. More information regarding tags: https://docs.unit.co/#tags
|
14
14
|
# @param query [String] Search term according to the: https://docs.unit.co/#full-text-search
|
15
15
|
# @param status [String] Filter applications by status: https://docs.unit.co/applications/#application-statuses
|
16
16
|
# @param sort [String] Sorts the resources by the specified field.
|
17
17
|
# @option sort=createdAt for ascending order
|
18
18
|
# @option sort=-createdAt (leading minus sign) for descending order.
|
19
|
-
def initialize(offset =
|
19
|
+
def initialize(offset = APPLICATION_LIST_OFFSET, limit = APPLICATION_LIST_LIMIT, email = nil, tags = nil,
|
20
20
|
query = nil, status = nil, sort = nil)
|
21
21
|
@offset = offset
|
22
22
|
@limit = limit
|
@@ -35,7 +35,7 @@ module Unit
|
|
35
35
|
"filter[query]": query,
|
36
36
|
"filter[status]": status,
|
37
37
|
"sort": sort }
|
38
|
-
params.compact
|
38
|
+
params.compact
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Request to update application
|
4
|
-
#
|
5
|
-
#
|
4
|
+
# @see for updating business application: https://docs.unit.co/applications/#update-business-application
|
5
|
+
# @see for updating individual application: https://docs.unit.co/applications/#update-individual-application
|
6
6
|
module Unit
|
7
7
|
module Application
|
8
8
|
class PatchApplicationRequest
|
@@ -10,7 +10,7 @@ module Unit
|
|
10
10
|
|
11
11
|
# @param application_id [String] The application id
|
12
12
|
# @param type [String] The type
|
13
|
-
# @param
|
13
|
+
# @param tags [String] The tags
|
14
14
|
def initialize(application_id, type, tags = nil)
|
15
15
|
@application_id = application_id
|
16
16
|
@type = type
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Creates request for uploading a document
|
4
|
-
#
|
4
|
+
# @see https://docs.unit.co/application-documents/#upload-document
|
5
5
|
module Unit
|
6
6
|
module Application
|
7
7
|
class UploadDocumentRequest
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Request to add authorized users to a project
|
4
|
-
#
|
4
|
+
# @see https://docs.unit.co/customers#add-authorized-users
|
5
5
|
module Unit
|
6
6
|
module Customer
|
7
7
|
class AddAuthorizedUsersRequest
|
8
8
|
attr_reader :customer_id, :authorized_users
|
9
9
|
|
10
|
-
# @param customer_id [String]
|
11
|
-
# @param authorized_users [Array<AuthorizedUser>]
|
10
|
+
# @param customer_id [String]
|
11
|
+
# @param authorized_users [Array<AuthorizedUser>]
|
12
12
|
def initialize(customer_id, authorized_users)
|
13
13
|
@customer_id = customer_id
|
14
14
|
@authorized_users = authorized_users
|
@@ -1,15 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Request to archive customer
|
4
|
-
#
|
4
|
+
# @see https://docs.unit.co/customers#archive-customer
|
5
5
|
module Unit
|
6
6
|
module Customer
|
7
7
|
class ArchiveCustomerRequest
|
8
8
|
attr_reader :customer_id, :reason
|
9
9
|
|
10
|
-
# @param customer_id [String]
|
11
|
-
# @param
|
12
|
-
# @option reason [String] Need to be one of the following: Inactive, FraudACHActivity, FraudCardActivity, FraudCheckActivity, FraudApplicationHistory, FraudAccountActivity, FraudClientIdentified, FraudLinkedToFraudulentCustomer.
|
10
|
+
# @param customer_id [String]
|
11
|
+
# @param reason [String] - optional
|
13
12
|
def initialize(customer_id, reason = nil)
|
14
13
|
@customer_id = customer_id
|
15
14
|
@reason = reason
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module Customer
|
5
|
+
CUSTOMER_LIST_LIMIT = 100
|
6
|
+
CUSTOMER_LIST_OFFSET = 0
|
7
|
+
|
8
|
+
autoload :AddAuthorizedUsersRequest, "unit/models/customer/add_authorized_users_request"
|
9
|
+
autoload :ArchiveCustomerRequest, "unit/models/customer/archive_customer_request"
|
10
|
+
autoload :ListCustomerParams, "unit/models/customer/list_customer_params"
|
11
|
+
autoload :PatchBusinessCustomerRequest, "unit/models/customer/patch_business_customer_request"
|
12
|
+
autoload :PatchIndividualCustomerRequest, "unit/models/customer/patch_individual_customer_request"
|
13
|
+
autoload :RemoveAuthorizedUsersRequest, "unit/models/customer/remove_authorized_users_request"
|
14
|
+
|
15
|
+
class << self
|
16
|
+
# Update individual customer by calling Unit's API
|
17
|
+
# @see https://docs.unit.co/customers#update-individual-customer
|
18
|
+
# @param customer_id [String]
|
19
|
+
# @param address [Address] - optional
|
20
|
+
# @param phone [Phone] - optional
|
21
|
+
# @param email [String] - optional
|
22
|
+
# @param dba [String] - optional
|
23
|
+
# @param authorized_users [Array<AuthorizedUser>] - optional
|
24
|
+
# @param tags [Hash] - optional
|
25
|
+
# @param jwt_subject [String] - optional
|
26
|
+
def update_individual_customer(customer_id:, address: nil, phone: nil, email: nil, dba: nil, authorized_users: nil, tags: nil, jwt_subject: nil)
|
27
|
+
request = PatchIndividualCustomerRequest.new(customer_id, address, phone, email, dba, authorized_users, tags, jwt_subject)
|
28
|
+
Unit::Resource::CustomerResource.update(request)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Update business customer by calling Unit's API
|
32
|
+
# @see https://docs.unit.co/customers#update-business-customer
|
33
|
+
# @param customer_id [String]
|
34
|
+
# @param address [Address] - optional
|
35
|
+
# @param phone [Phone] - optional
|
36
|
+
# @param contact [BusinessContact] - optional
|
37
|
+
# @param authorized_users [Array<AuthorizedUser>] - optional
|
38
|
+
# @param dba [String] - optional
|
39
|
+
# @param tags [Hash] - optional
|
40
|
+
# @return [UnitResponse, UnitError]
|
41
|
+
def update_business_customer(customer_id:, address: nil, phone: nil, contact: nil, authorized_users: nil, dba: nil, tags: nil)
|
42
|
+
request = PatchBusinessCustomerRequest.new(customer_id, address, phone, contact, authorized_users, dba, tags)
|
43
|
+
Unit::Resource::CustomerResource.update(request)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Get customer by calling Unit's API
|
47
|
+
# @see https://docs.unit.co/customers#get-specific-customer
|
48
|
+
# @param customer_id [String]
|
49
|
+
# @return [UnitResponse, UnitError]
|
50
|
+
def get_customer(customer_id)
|
51
|
+
Unit::Resource::CustomerResource.get(customer_id)
|
52
|
+
end
|
53
|
+
|
54
|
+
# List customers by calling Unit's API
|
55
|
+
# @see https://docs.unit.co/customers#list-customers
|
56
|
+
# @param limit [Integer] - optional
|
57
|
+
# @param offset [Integer] - optional
|
58
|
+
# @param query [String] - optional
|
59
|
+
# @param email [String] - optional
|
60
|
+
# @param tags [Hash] - optional
|
61
|
+
# @param status [String] - optional
|
62
|
+
# @param sort [String] - optional
|
63
|
+
def list_customers(offset: CUSTOMER_LIST_OFFSET, limit: CUSTOMER_LIST_LIMIT, email: nil, tags: nil, status: nil, query: nil, sort: nil)
|
64
|
+
request = ListCustomerParams.new(offset, limit, email, tags, status, query, sort)
|
65
|
+
Unit::Resource::CustomerResource.list(request)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Archive customer by calling Unit's API
|
69
|
+
# @see https://docs.unit.co/customers#archive-customer
|
70
|
+
# @param customer_id [String]
|
71
|
+
# @param reason [String] - optional
|
72
|
+
def archive_customer(customer_id:, reason: nil)
|
73
|
+
request = ArchiveCustomerRequest.new(customer_id, reason)
|
74
|
+
Unit::Resource::CustomerResource.archive(request)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Add authorized users by calling Unit's API
|
78
|
+
# @see https://docs.unit.co/customers#add-authorized-users
|
79
|
+
# @param customer_id [String]
|
80
|
+
# @param authorized_users [Array<AuthorizedUser>]
|
81
|
+
def add_authorized_users(customer_id:, authorized_users:)
|
82
|
+
request = AddAuthorizedUsersRequest.new(customer_id, authorized_users)
|
83
|
+
Unit::Resource::CustomerResource.add_authorized_users(request)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Remove authorized users by calling Unit's API
|
87
|
+
# @see https://docs.unit.co/customers#remove-authorized-users
|
88
|
+
# @param customer_id [String]
|
89
|
+
# @param authorized_users [Array<AuthorizedUser>]
|
90
|
+
def remove_authorized_users(customer_id:, authorized_users:)
|
91
|
+
request = RemoveAuthorizedUsersRequest.new(customer_id, authorized_users)
|
92
|
+
Unit::Resource::CustomerResource.remove_authorized_users(request)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -1,22 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# params for listing customers
|
4
|
-
#
|
4
|
+
# @see https://docs.unit.co/customers#list-customers
|
5
5
|
module Unit
|
6
6
|
module Customer
|
7
7
|
class ListCustomerParams
|
8
8
|
attr_reader :limit, :offset, :query, :email, :tags, :status, :sort
|
9
9
|
|
10
|
-
# @param
|
11
|
-
# @param
|
12
|
-
# @param
|
13
|
-
# @param
|
14
|
-
# @param
|
15
|
-
# @param
|
16
|
-
# @param
|
17
|
-
|
18
|
-
# @option sort=-createdAt (leading minus sign) for descending order.
|
19
|
-
def initialize(limit = 100, offset = 0, query = nil, email = nil, tags = nil, status = nil,
|
10
|
+
# @param limit [Integer] - optional
|
11
|
+
# @param offset [Integer] - optional
|
12
|
+
# @param query [String] - optional
|
13
|
+
# @param email [String] - optional
|
14
|
+
# @param tags [Hash] - optional
|
15
|
+
# @param status [String] - optional
|
16
|
+
# @param sort [String] - optional
|
17
|
+
def initialize(limit = CUSTOMER_LIST_LIMIT, offset = CUSTOMER_LIST_OFFSET, query = nil, email = nil, tags = nil, status = nil,
|
20
18
|
sort = nil)
|
21
19
|
@limit = limit
|
22
20
|
@offset = offset
|
@@ -35,7 +33,7 @@ module Unit
|
|
35
33
|
"filter[tags]": tags,
|
36
34
|
"filter[status]": status,
|
37
35
|
"sort": sort }
|
38
|
-
params.compact
|
36
|
+
params.compact
|
39
37
|
end
|
40
38
|
end
|
41
39
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Update business customer information request
|
4
|
-
#
|
4
|
+
# @see https://docs.unit.co/customers#update-business-customer
|
5
5
|
module Unit
|
6
6
|
module Customer
|
7
7
|
class PatchBusinessCustomerRequest
|
8
8
|
attr_reader :customer_id, :address, :phone, :contact, :authorized_users, :dba, :tags
|
9
9
|
|
10
|
-
# @param customer_id [String]
|
11
|
-
# @param
|
12
|
-
# @param
|
13
|
-
# @param
|
14
|
-
# @param
|
15
|
-
# @param
|
16
|
-
# @param
|
10
|
+
# @param customer_id [String]
|
11
|
+
# @param address [Address] - optional
|
12
|
+
# @param phone [Phone] - optional
|
13
|
+
# @param contact [BusinessContact] - optional
|
14
|
+
# @param authorized_users [Array<AuthorizedUser>] - optional
|
15
|
+
# @param dba [String] - optional
|
16
|
+
# @param tags [Hash] - optional
|
17
17
|
# more information regarding tags: https://docs.unit.co/#updating-tags
|
18
18
|
def initialize(customer_id, address = nil, phone = nil, contact = nil,
|
19
19
|
authorized_users = nil, dba = nil, tags = nil)
|
@@ -1,21 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Update individual customer information request
|
4
|
-
#
|
4
|
+
# @see https://docs.unit.co/customers#update-individual-customer
|
5
5
|
module Unit
|
6
6
|
module Customer
|
7
7
|
class PatchIndividualCustomerRequest
|
8
8
|
attr_reader :customer_id, :address, :phone, :email, :dba, :authorized_users, :tags, :jwt_subject
|
9
9
|
|
10
|
-
# @param customer_id [String]
|
11
|
-
# @param
|
12
|
-
# @param
|
13
|
-
# @param
|
14
|
-
# @param
|
15
|
-
# @param
|
16
|
-
# @param
|
17
|
-
# @param
|
18
|
-
# More information regarding JWTSubject: https://docs.unit.co/customer-api-tokens/#customers-create-customer-bearer-token-jwt
|
10
|
+
# @param customer_id [String]
|
11
|
+
# @param address [Address] - optional
|
12
|
+
# @param phone [Phone] - optional
|
13
|
+
# @param email [String] - optional
|
14
|
+
# @param dba [String] - optional
|
15
|
+
# @param authorized_users [Array<AuthorizedUser>] - optional
|
16
|
+
# @param tags [Hash] - optional
|
17
|
+
# @param jwt_subject [String] - optional
|
19
18
|
def initialize(customer_id, address = nil, phone = nil, email = nil, dba = nil, authorized_users = nil, tags = nil, jwt_subject = nil)
|
20
19
|
@customer_id = customer_id
|
21
20
|
@address = address
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Request to remove authorized users from customer
|
4
|
-
#
|
4
|
+
# @see https://docs.unit.co/customers#remove-authorized-users
|
5
5
|
module Unit
|
6
6
|
module Customer
|
7
7
|
class RemoveAuthorizedUsersRequest
|
8
8
|
attr_reader :customer_id, :authorized_users_emails
|
9
9
|
|
10
|
-
# @param customer_id [String]
|
11
|
-
# @param authorized_users_emails [Array<String>]
|
10
|
+
# @param customer_id [String]
|
11
|
+
# @param authorized_users_emails [Array<String>]
|
12
12
|
def initialize(customer_id, authorized_users_emails)
|
13
13
|
@customer_id = customer_id
|
14
14
|
@authorized_users_emails = authorized_users_emails
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create a book payment
|
4
|
+
# @see https://docs.unit.co/book-payments#book-payments
|
5
|
+
module Unit
|
6
|
+
module Payment
|
7
|
+
class CreateBookPaymentRequest
|
8
|
+
attr_reader :amount, :description, :account_id, :counterparty_account_id, :transaction_summary_override, :idempotency_key, :tags, :relationships
|
9
|
+
|
10
|
+
# @param amount [Integer]
|
11
|
+
# @param description [String]
|
12
|
+
# @param account_id [String]
|
13
|
+
# @param counterparty_account_id [String]
|
14
|
+
# @param transaction_summary_override [String] - optional
|
15
|
+
# @param idempotency_key [String] - optional
|
16
|
+
# @param tags [Hash] - optional
|
17
|
+
def initialize(amount, description, account_id, counterparty_account_id, relationships, transaction_summary_override = nil,
|
18
|
+
idempotency_key = nil, tags = nil)
|
19
|
+
@amount = amount
|
20
|
+
@description = description
|
21
|
+
@account_id = account_id
|
22
|
+
@counterparty_account_id = counterparty_account_id
|
23
|
+
@relationships = relationships
|
24
|
+
@transaction_summary_override = transaction_summary_override
|
25
|
+
@idempotency_key = idempotency_key
|
26
|
+
@tags = tags
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_json_api
|
30
|
+
payload = {
|
31
|
+
data: {
|
32
|
+
type: "bookPayment",
|
33
|
+
attributes: {
|
34
|
+
amount: amount,
|
35
|
+
description: description,
|
36
|
+
transactionSummaryOverride: transaction_summary_override,
|
37
|
+
idempotencyKey: idempotency_key,
|
38
|
+
tags: tags
|
39
|
+
},
|
40
|
+
relationships: { account: Unit::Types::Relationship.new("depositAccount", account_id).to_hash,
|
41
|
+
counterpartyAccount: Unit::Types::Relationship.new("depositAccount", counterparty_account_id).to_hash }
|
42
|
+
}
|
43
|
+
}
|
44
|
+
payload[:data][:attributes].compact!
|
45
|
+
payload.to_json
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to update a book payment
|
4
|
+
# @see https://docs.unit.co/book-payments#update-book-payment
|
5
|
+
module Unit
|
6
|
+
module Payment
|
7
|
+
class PatchBookPaymentRequest
|
8
|
+
attr_reader :payment_id, :tags
|
9
|
+
|
10
|
+
# @param payment_id [String]
|
11
|
+
# @param tags [Hash] - optional
|
12
|
+
def initialize(payment_id, tags = nil)
|
13
|
+
@payment_id = payment_id
|
14
|
+
@tags = tags
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_json_api
|
18
|
+
payload = {
|
19
|
+
data: {
|
20
|
+
type: "bookPayment",
|
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,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Unit
|
4
|
+
module Payment
|
5
|
+
autoload :CreateBookPaymentRequest, "unit/models/payment/create_book_payment_request"
|
6
|
+
autoload :PatchBookPaymentRequest, "unit/models/payment/patch_book_payment_request"
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# Create a new book payment by calling Unit's API
|
10
|
+
# @see https://docs.unit.co/book-payments#book-payments
|
11
|
+
# @param amount [Integer]
|
12
|
+
# @param description [String]
|
13
|
+
# @param account_id [String]
|
14
|
+
# @param counterparty_account_id [String]
|
15
|
+
# @param transaction_summary_override [String] - optional
|
16
|
+
# @param idempotency_key [String] - optional
|
17
|
+
# @param tags [Hash] - optional
|
18
|
+
# @return [UnitResponse, UnitError]
|
19
|
+
def create_book_payment(amount:, description:, account_id:, counterparty_account_id:, transaction_summary_override: nil,
|
20
|
+
idempotency_key: nil, tags: nil)
|
21
|
+
request = Unit::Payment::CreateBookPaymentRequest.new(amount, description, account_id, counterparty_account_id, transaction_summary_override,
|
22
|
+
idempotency_key, tags)
|
23
|
+
Unit::Resource::PaymentResource.create_payment(request)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Update a book payment by calling Unit's API
|
27
|
+
# @see https://docs.unit.co/book-payments#update-book-payment
|
28
|
+
# @param payment_id [String]
|
29
|
+
# @param tags [Hash] - optional
|
30
|
+
# @return [UnitResponse, UnitError]
|
31
|
+
def update_book_payment(payment_id:, tags: nil)
|
32
|
+
request = Unit::Payment::PatchBookPaymentRequest.new(payment_id, tags)
|
33
|
+
Unit::Resource::PaymentResource.update_payment(request)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|