unit_ruby_sdk 0.1.2 → 0.1.3
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 +73 -1
- data/lib/unit/api_resources/account_resource.rb +125 -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/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/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 +3 -3
- 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 +9 -11
- 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/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/utils/http_helper.rb +56 -0
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +15 -21
- metadata +60 -7
- data/Gemfile.lock +0 -133
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to get the balance history of a deposit account
|
4
|
+
# @see https://docs.unit.co/deposit-accounts#get-account-balance-history
|
5
|
+
module Unit
|
6
|
+
module Account
|
7
|
+
module Deposit
|
8
|
+
class BalanceHistoryRequest
|
9
|
+
attr_reader :limit, :offset, :account_id, :customer_id, :since, :_until
|
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 since [String] - optional
|
16
|
+
# @param _until [String] - optional
|
17
|
+
def initialize(limit = BALANCE_HISTORY_LIMIT, offset = BALANCE_HISTORY_OFFSET, account_id = nil, customer_id = nil,
|
18
|
+
since = nil, _until = nil)
|
19
|
+
@limit = limit
|
20
|
+
@offset = offset
|
21
|
+
@account_id = account_id
|
22
|
+
@customer_id = customer_id
|
23
|
+
@since = since
|
24
|
+
@_until = _until
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_hash
|
28
|
+
params = { "page[limit]": limit,
|
29
|
+
"page[offset]": offset,
|
30
|
+
"filter[accountId]": account_id,
|
31
|
+
"filter[customerId]": customer_id,
|
32
|
+
"filter[since]": since,
|
33
|
+
"filter[until]": _until }
|
34
|
+
params.compact!
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to close a deposit account
|
4
|
+
# @see https://docs.unit.co/deposit-accounts#close-account
|
5
|
+
module Unit
|
6
|
+
module Account
|
7
|
+
module Deposit
|
8
|
+
class CloseDepositAccountRequest
|
9
|
+
attr_reader :account_id, :reason, :fraud_reason
|
10
|
+
|
11
|
+
# @param account_id [String]
|
12
|
+
# @param reason [String]
|
13
|
+
# @param fraud_reason [String] - optional
|
14
|
+
def initialize(account_id, reason, fraud_reason = nil)
|
15
|
+
@account_id = account_id
|
16
|
+
@reason = reason
|
17
|
+
@fraud_reason = fraud_reason
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_json_api
|
21
|
+
payload = {
|
22
|
+
data: {
|
23
|
+
type: "accountClose",
|
24
|
+
attributes: {
|
25
|
+
reason: reason,
|
26
|
+
fraudReason: fraud_reason
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
payload[:data][:attributes].compact!
|
31
|
+
payload.to_json
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to create a deposit account
|
4
|
+
# @see https://docs.unit.co/deposit-accounts#create-deposit-account
|
5
|
+
module Unit
|
6
|
+
module Account
|
7
|
+
module Deposit
|
8
|
+
class CreateDepositAccountRequest
|
9
|
+
attr_reader :deposit_product, :tags, :idempotency_key, :relationships
|
10
|
+
|
11
|
+
# @param deposit_product [String]
|
12
|
+
# @param tags [Hash]- optional
|
13
|
+
# @param idempotency_key [String] - optional
|
14
|
+
# @param relationships [Relationship, RelationshipArray] - optional
|
15
|
+
def initialize(deposit_product, tags = nil, relationships = nil, idempotency_key = nil)
|
16
|
+
@deposit_product = deposit_product
|
17
|
+
@tags = tags
|
18
|
+
@idempotency_key = idempotency_key
|
19
|
+
@relationships = relationships
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_json_api
|
23
|
+
payload = {
|
24
|
+
data: {
|
25
|
+
type: "depositAccount",
|
26
|
+
attributes: {
|
27
|
+
depositProduct: deposit_product,
|
28
|
+
tags: tags
|
29
|
+
},
|
30
|
+
relationships: relationships
|
31
|
+
}
|
32
|
+
}
|
33
|
+
payload[:data][:attributes].compact!
|
34
|
+
payload.to_json
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to freeze a deposit account
|
4
|
+
# @see https://docs.unit.co/deposit-accounts#freeze-account
|
5
|
+
module Unit
|
6
|
+
module Account
|
7
|
+
module Deposit
|
8
|
+
class FreezeAccountRequest
|
9
|
+
attr_reader :account_id, :reason, :reason_text
|
10
|
+
|
11
|
+
# @param account_id [String]
|
12
|
+
# @param reason [String]
|
13
|
+
# @param reason_text [String] - optional
|
14
|
+
def initialize(account_id, reason, reason_text = nil)
|
15
|
+
@account_id = account_id
|
16
|
+
@reason = reason
|
17
|
+
@reason_text = reason_text
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_json_api
|
21
|
+
payload = {
|
22
|
+
data: {
|
23
|
+
type: "accountFreeze",
|
24
|
+
attributes: {
|
25
|
+
reason: reason,
|
26
|
+
reasonText: reason_text
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
payload[:data][:attributes].compact!
|
31
|
+
payload.to_json
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# params for listing deposit accounts
|
4
|
+
# @see https://docs.unit.co/deposit-accounts#list-deposit-accounts
|
5
|
+
module Unit
|
6
|
+
module Account
|
7
|
+
module Deposit
|
8
|
+
class ListAccountParams
|
9
|
+
attr_reader :limit, :offset, :customer_id, :tags, :status,
|
10
|
+
:from_balance, :to_balance, :include
|
11
|
+
|
12
|
+
# @param limit [Integer] - optional
|
13
|
+
# @param offset [Integer] - optional
|
14
|
+
# @param customer_id [String] - optional
|
15
|
+
# @param tags [Hash] - optional
|
16
|
+
# @param status [Array<String>] - optional
|
17
|
+
# @param from_balance [Integer] - optional
|
18
|
+
# @param to_balance [Integer] - optional
|
19
|
+
# @param include [Array] - optional
|
20
|
+
def initialize(limit = ACCOUNT_LIST_LIMIT, offset = ACCOUNT_LIST_OFFSET, customer_id = nil, tags = nil,
|
21
|
+
status = nil, from_balance = nil, to_balance = nil, include = nil)
|
22
|
+
@limit = limit
|
23
|
+
@offset = offset
|
24
|
+
@customer_id = customer_id
|
25
|
+
@tags = tags
|
26
|
+
@status = status
|
27
|
+
@from_balance = from_balance
|
28
|
+
@to_balance = to_balance
|
29
|
+
@include = include
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_hash
|
33
|
+
params = { "page[limit]": limit,
|
34
|
+
"page[offset]": offset,
|
35
|
+
"filter[customerId]": customer_id,
|
36
|
+
"filter[tags]": tags,
|
37
|
+
"filter[fromBalance]": from_balance,
|
38
|
+
"filter[toBalance]": to_balance,
|
39
|
+
"include": include&.join(",") }
|
40
|
+
status&.each_with_index&.map do |val, index|
|
41
|
+
params.merge!({ "filter[status][#{index}]": val })
|
42
|
+
end
|
43
|
+
params.compact
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to update a deposit account
|
4
|
+
# @see https://docs.unit.co/deposit-accounts#update-accounts
|
5
|
+
module Unit
|
6
|
+
module Account
|
7
|
+
module Deposit
|
8
|
+
class PatchDepositAccountRequest
|
9
|
+
attr_reader :account_id, :tags, :deposit_product
|
10
|
+
|
11
|
+
# @param account_id [String]
|
12
|
+
# @param tags [Hash] - optional
|
13
|
+
# @param deposit_product [String] - optional
|
14
|
+
def initialize(account_id, tags = nil, deposit_product = nil)
|
15
|
+
@account_id = account_id
|
16
|
+
@tags = tags
|
17
|
+
@deposit_product = deposit_product
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_json_api
|
21
|
+
payload = {
|
22
|
+
data: {
|
23
|
+
type: "depositAccount",
|
24
|
+
attributes: {
|
25
|
+
tags: tags,
|
26
|
+
depositProduct: deposit_product
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
payload[:data][:attributes].compact!
|
31
|
+
payload.to_json
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -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
|
@@ -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
|