tesser-api-sdk 1.0.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 +7 -0
- data/LICENSE +28 -0
- data/README.md +148 -0
- data/bin/console +15 -0
- data/lib/tesser_apiv1/api_helper.rb +10 -0
- data/lib/tesser_apiv1/client.rb +118 -0
- data/lib/tesser_apiv1/configuration.rb +182 -0
- data/lib/tesser_apiv1/controllers/accounts_controller.rb +193 -0
- data/lib/tesser_apiv1/controllers/base_controller.rb +60 -0
- data/lib/tesser_apiv1/controllers/counterparties_controller.rb +171 -0
- data/lib/tesser_apiv1/controllers/currencies_controller.rb +39 -0
- data/lib/tesser_apiv1/controllers/experimental_controller.rb +49 -0
- data/lib/tesser_apiv1/controllers/health_controller.rb +24 -0
- data/lib/tesser_apiv1/controllers/networks_controller.rb +39 -0
- data/lib/tesser_apiv1/controllers/payments_controller.rb +202 -0
- data/lib/tesser_apiv1/controllers/tenants_controller.rb +156 -0
- data/lib/tesser_apiv1/controllers/treasury_controller.rb +77 -0
- data/lib/tesser_apiv1/exceptions/api_exception.rb +21 -0
- data/lib/tesser_apiv1/http/auth/o_auth2.rb +53 -0
- data/lib/tesser_apiv1/http/http_call_back.rb +10 -0
- data/lib/tesser_apiv1/http/http_method_enum.rb +10 -0
- data/lib/tesser_apiv1/http/http_request.rb +10 -0
- data/lib/tesser_apiv1/http/http_response.rb +10 -0
- data/lib/tesser_apiv1/http/proxy_settings.rb +22 -0
- data/lib/tesser_apiv1/models/account.rb +230 -0
- data/lib/tesser_apiv1/models/account_list_item.rb +230 -0
- data/lib/tesser_apiv1/models/account_list_response.rb +69 -0
- data/lib/tesser_apiv1/models/account_response.rb +60 -0
- data/lib/tesser_apiv1/models/account_safe.rb +218 -0
- data/lib/tesser_apiv1/models/balance_status1_enum.rb +40 -0
- data/lib/tesser_apiv1/models/balance_status_enum.rb +40 -0
- data/lib/tesser_apiv1/models/base_model.rb +110 -0
- data/lib/tesser_apiv1/models/classification7_enum.rb +36 -0
- data/lib/tesser_apiv1/models/classification_enum.rb +36 -0
- data/lib/tesser_apiv1/models/counterparty.rb +411 -0
- data/lib/tesser_apiv1/models/counterparty_list_response.rb +69 -0
- data/lib/tesser_apiv1/models/counterparty_response.rb +60 -0
- data/lib/tesser_apiv1/models/create_bank_request.rb +122 -0
- data/lib/tesser_apiv1/models/create_bank_response.rb +60 -0
- data/lib/tesser_apiv1/models/create_counterparty_request.rb +350 -0
- data/lib/tesser_apiv1/models/create_counterparty_response.rb +60 -0
- data/lib/tesser_apiv1/models/create_deposit_request.rb +119 -0
- data/lib/tesser_apiv1/models/create_payment_request.rb +168 -0
- data/lib/tesser_apiv1/models/create_tenant_request.rb +183 -0
- data/lib/tesser_apiv1/models/create_tenant_response.rb +60 -0
- data/lib/tesser_apiv1/models/create_wallet_request.rb +112 -0
- data/lib/tesser_apiv1/models/create_wallet_response.rb +60 -0
- data/lib/tesser_apiv1/models/create_withdrawal_request.rb +130 -0
- data/lib/tesser_apiv1/models/currencies_response.rb +69 -0
- data/lib/tesser_apiv1/models/currency.rb +119 -0
- data/lib/tesser_apiv1/models/data.rb +221 -0
- data/lib/tesser_apiv1/models/data6.rb +242 -0
- data/lib/tesser_apiv1/models/data7.rb +419 -0
- data/lib/tesser_apiv1/models/data8.rb +200 -0
- data/lib/tesser_apiv1/models/direction1_enum.rb +40 -0
- data/lib/tesser_apiv1/models/direction_enum.rb +40 -0
- data/lib/tesser_apiv1/models/execute_payment_request_dto.rb +71 -0
- data/lib/tesser_apiv1/models/fee.rb +117 -0
- data/lib/tesser_apiv1/models/fee1.rb +117 -0
- data/lib/tesser_apiv1/models/network.rb +68 -0
- data/lib/tesser_apiv1/models/networks_response.rb +69 -0
- data/lib/tesser_apiv1/models/pagination.rb +104 -0
- data/lib/tesser_apiv1/models/payment.rb +421 -0
- data/lib/tesser_apiv1/models/payment_list_response.rb +79 -0
- data/lib/tesser_apiv1/models/payment_response.rb +60 -0
- data/lib/tesser_apiv1/models/payment_type3_enum.rb +52 -0
- data/lib/tesser_apiv1/models/payment_type_enum.rb +54 -0
- data/lib/tesser_apiv1/models/provider_key1_enum.rb +36 -0
- data/lib/tesser_apiv1/models/provider_key_enum.rb +36 -0
- data/lib/tesser_apiv1/models/response.rb +81 -0
- data/lib/tesser_apiv1/models/review_payment_request.rb +60 -0
- data/lib/tesser_apiv1/models/risk_status_enum.rb +44 -0
- data/lib/tesser_apiv1/models/status1_enum.rb +52 -0
- data/lib/tesser_apiv1/models/status_enum.rb +48 -0
- data/lib/tesser_apiv1/models/step.rb +421 -0
- data/lib/tesser_apiv1/models/step_type_enum.rb +44 -0
- data/lib/tesser_apiv1/models/tenant.rb +275 -0
- data/lib/tesser_apiv1/models/tenant_api_credentials.rb +88 -0
- data/lib/tesser_apiv1/models/tenant_list_response.rb +69 -0
- data/lib/tesser_apiv1/models/tenant_response.rb +60 -0
- data/lib/tesser_apiv1/models/transfer_step.rb +422 -0
- data/lib/tesser_apiv1/models/turnkey_stamp.rb +81 -0
- data/lib/tesser_apiv1/models/type3_enum.rb +40 -0
- data/lib/tesser_apiv1/models/type4_enum.rb +44 -0
- data/lib/tesser_apiv1/models/type_enum.rb +44 -0
- data/lib/tesser_apiv1/models/update_account_request.rb +62 -0
- data/lib/tesser_apiv1/models/update_account_response.rb +60 -0
- data/lib/tesser_apiv1/models/update_counterparty_request.rb +166 -0
- data/lib/tesser_apiv1/models/update_counterparty_response.rb +60 -0
- data/lib/tesser_apiv1/models/update_payment_request.rb +100 -0
- data/lib/tesser_apiv1/models/update_tenant_request.rb +111 -0
- data/lib/tesser_apiv1/models/update_tenant_response.rb +60 -0
- data/lib/tesser_apiv1/utilities/date_time_helper.rb +11 -0
- data/lib/tesser_apiv1/utilities/file_wrapper.rb +28 -0
- data/lib/tesser_apiv1/utilities/union_type_lookup.rb +1234 -0
- data/lib/tesser_apiv1.rb +116 -0
- data/test/controllers/controller_test_base.rb +23 -0
- data/test/controllers/test_health_controller.rb +31 -0
- data/test/controllers/test_tenants_controller.rb +133 -0
- data/test/http_response_catcher.rb +19 -0
- metadata +212 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# tesser_apiv1
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module TesserApiv1
|
|
7
|
+
# AccountSafe Model.
|
|
8
|
+
class AccountSafe < BaseModel
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# Unique identifier for the account.
|
|
13
|
+
# @return [String]
|
|
14
|
+
attr_accessor :id
|
|
15
|
+
|
|
16
|
+
# ID of the workspace.
|
|
17
|
+
# @return [String]
|
|
18
|
+
attr_accessor :workspace_id
|
|
19
|
+
|
|
20
|
+
# Tenant ID (optional - if provided, this account is associated with a
|
|
21
|
+
# tenant). At most one of tenant_id or counterparty_id may be set.
|
|
22
|
+
# @return [Object]
|
|
23
|
+
attr_accessor :tenant_id
|
|
24
|
+
|
|
25
|
+
# Counterparty ID (optional - if provided, this account is associated with a
|
|
26
|
+
# counterparty). At most one of tenant_id or counterparty_id may be set.
|
|
27
|
+
# @return [Object]
|
|
28
|
+
attr_accessor :counterparty_id
|
|
29
|
+
|
|
30
|
+
# Account type.
|
|
31
|
+
# @return [TypeEnum]
|
|
32
|
+
attr_accessor :type
|
|
33
|
+
|
|
34
|
+
# Account name.
|
|
35
|
+
# @return [String]
|
|
36
|
+
attr_accessor :name
|
|
37
|
+
|
|
38
|
+
# Bank name (for fiat accounts).
|
|
39
|
+
# @return [Object]
|
|
40
|
+
attr_accessor :bank_name
|
|
41
|
+
|
|
42
|
+
# Bank code type (e.g., SWIFT, BIC).
|
|
43
|
+
# @return [Object]
|
|
44
|
+
attr_accessor :bank_code_type
|
|
45
|
+
|
|
46
|
+
# Bank identifier code value.
|
|
47
|
+
# @return [Object]
|
|
48
|
+
attr_accessor :bank_identifier_code
|
|
49
|
+
|
|
50
|
+
# Crypto wallet address (for wallet accounts).
|
|
51
|
+
# @return [Object]
|
|
52
|
+
attr_accessor :crypto_wallet_address
|
|
53
|
+
|
|
54
|
+
# Creation timestamp.
|
|
55
|
+
# @return [String]
|
|
56
|
+
attr_accessor :created_at
|
|
57
|
+
|
|
58
|
+
# Last update timestamp.
|
|
59
|
+
# @return [String]
|
|
60
|
+
attr_accessor :updated_at
|
|
61
|
+
|
|
62
|
+
# A mapping from model property names to API property names.
|
|
63
|
+
def self.names
|
|
64
|
+
@_hash = {} if @_hash.nil?
|
|
65
|
+
@_hash['id'] = 'id'
|
|
66
|
+
@_hash['workspace_id'] = 'workspace_id'
|
|
67
|
+
@_hash['tenant_id'] = 'tenant_id'
|
|
68
|
+
@_hash['counterparty_id'] = 'counterparty_id'
|
|
69
|
+
@_hash['type'] = 'type'
|
|
70
|
+
@_hash['name'] = 'name'
|
|
71
|
+
@_hash['bank_name'] = 'bank_name'
|
|
72
|
+
@_hash['bank_code_type'] = 'bank_code_type'
|
|
73
|
+
@_hash['bank_identifier_code'] = 'bank_identifier_code'
|
|
74
|
+
@_hash['crypto_wallet_address'] = 'crypto_wallet_address'
|
|
75
|
+
@_hash['created_at'] = 'created_at'
|
|
76
|
+
@_hash['updated_at'] = 'updated_at'
|
|
77
|
+
@_hash
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# An array for optional fields
|
|
81
|
+
def self.optionals
|
|
82
|
+
%w[
|
|
83
|
+
workspace_id
|
|
84
|
+
tenant_id
|
|
85
|
+
counterparty_id
|
|
86
|
+
bank_name
|
|
87
|
+
bank_code_type
|
|
88
|
+
bank_identifier_code
|
|
89
|
+
crypto_wallet_address
|
|
90
|
+
]
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# An array for nullable fields
|
|
94
|
+
def self.nullables
|
|
95
|
+
[]
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def initialize(id = nil, type = nil, name = nil, created_at = nil,
|
|
99
|
+
updated_at = nil, workspace_id = SKIP, tenant_id = SKIP,
|
|
100
|
+
counterparty_id = SKIP, bank_name = SKIP,
|
|
101
|
+
bank_code_type = SKIP, bank_identifier_code = SKIP,
|
|
102
|
+
crypto_wallet_address = SKIP)
|
|
103
|
+
@id = id
|
|
104
|
+
@workspace_id = workspace_id unless workspace_id == SKIP
|
|
105
|
+
@tenant_id = tenant_id unless tenant_id == SKIP
|
|
106
|
+
@counterparty_id = counterparty_id unless counterparty_id == SKIP
|
|
107
|
+
@type = type
|
|
108
|
+
@name = name
|
|
109
|
+
@bank_name = bank_name unless bank_name == SKIP
|
|
110
|
+
@bank_code_type = bank_code_type unless bank_code_type == SKIP
|
|
111
|
+
@bank_identifier_code = bank_identifier_code unless bank_identifier_code == SKIP
|
|
112
|
+
@crypto_wallet_address = crypto_wallet_address unless crypto_wallet_address == SKIP
|
|
113
|
+
@created_at = created_at
|
|
114
|
+
@updated_at = updated_at
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Creates an instance of the object from a hash.
|
|
118
|
+
def self.from_hash(hash)
|
|
119
|
+
return nil unless hash
|
|
120
|
+
|
|
121
|
+
# Extract variables from the hash.
|
|
122
|
+
id = hash.key?('id') ? hash['id'] : nil
|
|
123
|
+
type = hash.key?('type') ? hash['type'] : nil
|
|
124
|
+
name = hash.key?('name') ? hash['name'] : nil
|
|
125
|
+
created_at = hash.key?('created_at') ? hash['created_at'] : nil
|
|
126
|
+
updated_at = hash.key?('updated_at') ? hash['updated_at'] : nil
|
|
127
|
+
workspace_id = hash.key?('workspace_id') ? hash['workspace_id'] : SKIP
|
|
128
|
+
tenant_id = hash.key?('tenant_id') ? APIHelper.deserialize_union_type(
|
|
129
|
+
UnionTypeLookUp.get(:AccountSafeTenantId), hash['tenant_id']
|
|
130
|
+
) : SKIP
|
|
131
|
+
counterparty_id = hash.key?('counterparty_id') ? APIHelper.deserialize_union_type(
|
|
132
|
+
UnionTypeLookUp.get(:AccountSafeCounterpartyId), hash['counterparty_id']
|
|
133
|
+
) : SKIP
|
|
134
|
+
bank_name = hash.key?('bank_name') ? APIHelper.deserialize_union_type(
|
|
135
|
+
UnionTypeLookUp.get(:AccountSafeBankName), hash['bank_name']
|
|
136
|
+
) : SKIP
|
|
137
|
+
bank_code_type = hash.key?('bank_code_type') ? APIHelper.deserialize_union_type(
|
|
138
|
+
UnionTypeLookUp.get(:AccountSafeBankCodeType), hash['bank_code_type']
|
|
139
|
+
) : SKIP
|
|
140
|
+
bank_identifier_code = hash.key?('bank_identifier_code') ? APIHelper.deserialize_union_type(
|
|
141
|
+
UnionTypeLookUp.get(:AccountSafeBankIdentifierCode), hash['bank_identifier_code']
|
|
142
|
+
) : SKIP
|
|
143
|
+
crypto_wallet_address = hash.key?('crypto_wallet_address') ? APIHelper.deserialize_union_type(
|
|
144
|
+
UnionTypeLookUp.get(:AccountSafeCryptoWalletAddress), hash['crypto_wallet_address']
|
|
145
|
+
) : SKIP
|
|
146
|
+
|
|
147
|
+
# Create object from extracted values.
|
|
148
|
+
AccountSafe.new(id,
|
|
149
|
+
type,
|
|
150
|
+
name,
|
|
151
|
+
created_at,
|
|
152
|
+
updated_at,
|
|
153
|
+
workspace_id,
|
|
154
|
+
tenant_id,
|
|
155
|
+
counterparty_id,
|
|
156
|
+
bank_name,
|
|
157
|
+
bank_code_type,
|
|
158
|
+
bank_identifier_code,
|
|
159
|
+
crypto_wallet_address)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Validates an instance of the object from a given value.
|
|
163
|
+
# @param [AccountSafe | Hash] The value against the validation is performed.
|
|
164
|
+
def self.validate(value)
|
|
165
|
+
if value.instance_of? self
|
|
166
|
+
return (
|
|
167
|
+
APIHelper.valid_type?(value.id,
|
|
168
|
+
->(val) { val.instance_of? String }) and
|
|
169
|
+
APIHelper.valid_type?(value.type,
|
|
170
|
+
->(val) { TypeEnum.validate(val) }) and
|
|
171
|
+
APIHelper.valid_type?(value.name,
|
|
172
|
+
->(val) { val.instance_of? String }) and
|
|
173
|
+
APIHelper.valid_type?(value.created_at,
|
|
174
|
+
->(val) { val.instance_of? String }) and
|
|
175
|
+
APIHelper.valid_type?(value.updated_at,
|
|
176
|
+
->(val) { val.instance_of? String })
|
|
177
|
+
)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
return false unless value.instance_of? Hash
|
|
181
|
+
|
|
182
|
+
(
|
|
183
|
+
APIHelper.valid_type?(value['id'],
|
|
184
|
+
->(val) { val.instance_of? String }) and
|
|
185
|
+
APIHelper.valid_type?(value['type'],
|
|
186
|
+
->(val) { TypeEnum.validate(val) }) and
|
|
187
|
+
APIHelper.valid_type?(value['name'],
|
|
188
|
+
->(val) { val.instance_of? String }) and
|
|
189
|
+
APIHelper.valid_type?(value['created_at'],
|
|
190
|
+
->(val) { val.instance_of? String }) and
|
|
191
|
+
APIHelper.valid_type?(value['updated_at'],
|
|
192
|
+
->(val) { val.instance_of? String })
|
|
193
|
+
)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# Provides a human-readable string representation of the object.
|
|
197
|
+
def to_s
|
|
198
|
+
class_name = self.class.name.split('::').last
|
|
199
|
+
"<#{class_name} id: #{@id}, workspace_id: #{@workspace_id}, tenant_id: #{@tenant_id},"\
|
|
200
|
+
" counterparty_id: #{@counterparty_id}, type: #{@type}, name: #{@name}, bank_name:"\
|
|
201
|
+
" #{@bank_name}, bank_code_type: #{@bank_code_type}, bank_identifier_code:"\
|
|
202
|
+
" #{@bank_identifier_code}, crypto_wallet_address: #{@crypto_wallet_address}, created_at:"\
|
|
203
|
+
" #{@created_at}, updated_at: #{@updated_at}>"
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
207
|
+
def inspect
|
|
208
|
+
class_name = self.class.name.split('::').last
|
|
209
|
+
"<#{class_name} id: #{@id.inspect}, workspace_id: #{@workspace_id.inspect}, tenant_id:"\
|
|
210
|
+
" #{@tenant_id.inspect}, counterparty_id: #{@counterparty_id.inspect}, type:"\
|
|
211
|
+
" #{@type.inspect}, name: #{@name.inspect}, bank_name: #{@bank_name.inspect},"\
|
|
212
|
+
" bank_code_type: #{@bank_code_type.inspect}, bank_identifier_code:"\
|
|
213
|
+
" #{@bank_identifier_code.inspect}, crypto_wallet_address:"\
|
|
214
|
+
" #{@crypto_wallet_address.inspect}, created_at: #{@created_at.inspect}, updated_at:"\
|
|
215
|
+
" #{@updated_at.inspect}>"
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# tesser_apiv1
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module TesserApiv1
|
|
7
|
+
# Balance reservation status.
|
|
8
|
+
class BalanceStatus1Enum
|
|
9
|
+
BALANCE_STATUS1_ENUM = [
|
|
10
|
+
# TODO: Write general description for UNRESERVED
|
|
11
|
+
UNRESERVED = 'unreserved'.freeze,
|
|
12
|
+
|
|
13
|
+
# TODO: Write general description for RESERVED
|
|
14
|
+
RESERVED = 'reserved'.freeze,
|
|
15
|
+
|
|
16
|
+
# TODO: Write general description for INSUFFICIENT_BALANCE
|
|
17
|
+
INSUFFICIENT_BALANCE = 'insufficient_balance'.freeze
|
|
18
|
+
].freeze
|
|
19
|
+
|
|
20
|
+
def self.validate(value)
|
|
21
|
+
return false if value.nil?
|
|
22
|
+
|
|
23
|
+
BALANCE_STATUS1_ENUM.include?(value)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.from_value(value, default_value = UNRESERVED)
|
|
27
|
+
return default_value if value.nil?
|
|
28
|
+
|
|
29
|
+
str = value.to_s.strip
|
|
30
|
+
|
|
31
|
+
case str.downcase
|
|
32
|
+
when 'unreserved' then UNRESERVED
|
|
33
|
+
when 'reserved' then RESERVED
|
|
34
|
+
when 'insufficient_balance' then INSUFFICIENT_BALANCE
|
|
35
|
+
else
|
|
36
|
+
default_value
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# tesser_apiv1
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module TesserApiv1
|
|
7
|
+
# BalanceStatus.
|
|
8
|
+
class BalanceStatusEnum
|
|
9
|
+
BALANCE_STATUS_ENUM = [
|
|
10
|
+
# TODO: Write general description for UNRESERVED
|
|
11
|
+
UNRESERVED = 'unreserved'.freeze,
|
|
12
|
+
|
|
13
|
+
# TODO: Write general description for RESERVED
|
|
14
|
+
RESERVED = 'reserved'.freeze,
|
|
15
|
+
|
|
16
|
+
# TODO: Write general description for INSUFFICIENT_BALANCE
|
|
17
|
+
INSUFFICIENT_BALANCE = 'insufficient_balance'.freeze
|
|
18
|
+
].freeze
|
|
19
|
+
|
|
20
|
+
def self.validate(value)
|
|
21
|
+
return false if value.nil?
|
|
22
|
+
|
|
23
|
+
BALANCE_STATUS_ENUM.include?(value)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.from_value(value, default_value = UNRESERVED)
|
|
27
|
+
return default_value if value.nil?
|
|
28
|
+
|
|
29
|
+
str = value.to_s.strip
|
|
30
|
+
|
|
31
|
+
case str.downcase
|
|
32
|
+
when 'unreserved' then UNRESERVED
|
|
33
|
+
when 'reserved' then RESERVED
|
|
34
|
+
when 'insufficient_balance' then INSUFFICIENT_BALANCE
|
|
35
|
+
else
|
|
36
|
+
default_value
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# tesser_apiv1
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module TesserApiv1
|
|
7
|
+
# Base model.
|
|
8
|
+
# rubocop:disable all
|
|
9
|
+
class BaseModel < CoreLibrary::BaseModel
|
|
10
|
+
# Returns a Hash representation of the current object.
|
|
11
|
+
def to_hash
|
|
12
|
+
# validating the model being serialized
|
|
13
|
+
self.class.validate(self) if self.class.respond_to?(:validate)
|
|
14
|
+
|
|
15
|
+
hash = {}
|
|
16
|
+
instance_variables.each do |name|
|
|
17
|
+
value = instance_variable_get(name)
|
|
18
|
+
name = name[1..]
|
|
19
|
+
if name == 'additional_properties'
|
|
20
|
+
additional_properties = process_additional_properties(value, self.class.names)
|
|
21
|
+
hash.merge!(additional_properties)
|
|
22
|
+
else
|
|
23
|
+
key = self.class.names.key?(name) ? self.class.names[name] : name
|
|
24
|
+
optional_fields = self.class.optionals
|
|
25
|
+
nullable_fields = self.class.nullables
|
|
26
|
+
if value.nil?
|
|
27
|
+
next unless nullable_fields.include?(name)
|
|
28
|
+
|
|
29
|
+
if !optional_fields.include?(name) && !nullable_fields.include?(name)
|
|
30
|
+
raise ArgumentError,
|
|
31
|
+
"`#{name}` cannot be nil in `#{self.class}`. Please specify a valid value."
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
hash[key] = nil
|
|
36
|
+
unless value.nil?
|
|
37
|
+
if respond_to?("to_custom_#{name}")
|
|
38
|
+
if (value.instance_of? Array) || (value.instance_of? Hash)
|
|
39
|
+
params = [hash, key]
|
|
40
|
+
hash[key] = send("to_custom_#{name}", *params)
|
|
41
|
+
else
|
|
42
|
+
hash[key] = send("to_custom_#{name}")
|
|
43
|
+
end
|
|
44
|
+
elsif respond_to?("to_union_type_#{name}")
|
|
45
|
+
hash[key] = send("to_union_type_#{name}")
|
|
46
|
+
elsif value.instance_of? Array
|
|
47
|
+
hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
|
|
48
|
+
elsif value.instance_of? Hash
|
|
49
|
+
hash[key] = {}
|
|
50
|
+
value.each do |k, v|
|
|
51
|
+
hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
hash
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Processes additional properties, ensuring no conflicts with existing properties.
|
|
63
|
+
def process_additional_properties(additional_properties, existing_prop_names)
|
|
64
|
+
hash = {}
|
|
65
|
+
additional_properties.each do |name, value|
|
|
66
|
+
check_for_conflict(name, existing_prop_names)
|
|
67
|
+
|
|
68
|
+
hash[name] = if value.is_a?(Array)
|
|
69
|
+
process_array(value)
|
|
70
|
+
elsif value.is_a?(Hash)
|
|
71
|
+
process_hash(value)
|
|
72
|
+
else
|
|
73
|
+
process_basic_value(value)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
hash
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Checks if an additional property conflicts with a model's existing property.
|
|
80
|
+
def check_for_conflict(name, existing_prop_names)
|
|
81
|
+
return unless existing_prop_names.key?(name)
|
|
82
|
+
|
|
83
|
+
raise ArgumentError, "An additional property key, '#{name}' conflicts with one of the model's properties"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Processes an array of values, recursively calling `to_hash` on BaseModel objects.
|
|
87
|
+
def process_array(value)
|
|
88
|
+
value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Processes a hash of values, recursively calling `to_hash` on BaseModel objects.
|
|
92
|
+
def process_hash(value)
|
|
93
|
+
value.transform_values do |v|
|
|
94
|
+
v.is_a?(BaseModel) ? v.to_hash : v
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Processes a basic value (non-array, non-hash).
|
|
99
|
+
def process_basic_value(value)
|
|
100
|
+
value.is_a?(BaseModel) ? value.to_hash : value
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Returns a JSON representation of the curent object.
|
|
104
|
+
def to_json(options = {})
|
|
105
|
+
hash = to_hash
|
|
106
|
+
hash.to_json(options)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
# rubocop:enable all
|
|
110
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# tesser_apiv1
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module TesserApiv1
|
|
7
|
+
# classification7.
|
|
8
|
+
class Classification7Enum
|
|
9
|
+
CLASSIFICATION7_ENUM = [
|
|
10
|
+
# TODO: Write general description for INDIVIDUAL
|
|
11
|
+
INDIVIDUAL = 'individual'.freeze,
|
|
12
|
+
|
|
13
|
+
# TODO: Write general description for BUSINESS
|
|
14
|
+
BUSINESS = 'business'.freeze
|
|
15
|
+
].freeze
|
|
16
|
+
|
|
17
|
+
def self.validate(value)
|
|
18
|
+
return false if value.nil?
|
|
19
|
+
|
|
20
|
+
CLASSIFICATION7_ENUM.include?(value)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.from_value(value, default_value = INDIVIDUAL)
|
|
24
|
+
return default_value if value.nil?
|
|
25
|
+
|
|
26
|
+
str = value.to_s.strip
|
|
27
|
+
|
|
28
|
+
case str.downcase
|
|
29
|
+
when 'individual' then INDIVIDUAL
|
|
30
|
+
when 'business' then BUSINESS
|
|
31
|
+
else
|
|
32
|
+
default_value
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# tesser_apiv1
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module TesserApiv1
|
|
7
|
+
# Classification: 'individual' or 'business'.
|
|
8
|
+
class ClassificationEnum
|
|
9
|
+
CLASSIFICATION_ENUM = [
|
|
10
|
+
# TODO: Write general description for INDIVIDUAL
|
|
11
|
+
INDIVIDUAL = 'individual'.freeze,
|
|
12
|
+
|
|
13
|
+
# TODO: Write general description for BUSINESS
|
|
14
|
+
BUSINESS = 'business'.freeze
|
|
15
|
+
].freeze
|
|
16
|
+
|
|
17
|
+
def self.validate(value)
|
|
18
|
+
return false if value.nil?
|
|
19
|
+
|
|
20
|
+
CLASSIFICATION_ENUM.include?(value)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.from_value(value, default_value = INDIVIDUAL)
|
|
24
|
+
return default_value if value.nil?
|
|
25
|
+
|
|
26
|
+
str = value.to_s.strip
|
|
27
|
+
|
|
28
|
+
case str.downcase
|
|
29
|
+
when 'individual' then INDIVIDUAL
|
|
30
|
+
when 'business' then BUSINESS
|
|
31
|
+
else
|
|
32
|
+
default_value
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|