coinbase-sdk 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coinbase/address/wallet_address.rb +70 -1
- data/lib/coinbase/address.rb +5 -1
- data/lib/coinbase/client/api/external_addresses_api.rb +0 -79
- data/lib/coinbase/client/api/smart_contracts_api.rb +332 -0
- data/lib/coinbase/client/api/stake_api.rb +0 -8
- data/lib/coinbase/client/api/transaction_history_api.rb +101 -0
- data/lib/coinbase/client/api/users_api.rb +79 -0
- data/lib/coinbase/client/api/validators_api.rb +4 -4
- data/lib/coinbase/client/api/wallets_api.rb +4 -4
- data/lib/coinbase/client/api/webhooks_api.rb +72 -2
- data/lib/coinbase/client/models/create_smart_contract_request.rb +259 -0
- data/lib/coinbase/client/models/create_wallet_webhook_request.rb +232 -0
- data/lib/coinbase/client/models/create_webhook_request.rb +10 -8
- data/lib/coinbase/client/models/deploy_smart_contract_request.rb +222 -0
- data/lib/coinbase/client/models/multi_token_contract_options.rb +223 -0
- data/lib/coinbase/client/models/network_identifier.rb +2 -1
- data/lib/coinbase/client/models/nft_contract_options.rb +257 -0
- data/lib/coinbase/client/models/smart_contract.rb +378 -0
- data/lib/coinbase/client/models/smart_contract_list.rb +257 -0
- data/lib/coinbase/client/models/smart_contract_options.rb +107 -0
- data/lib/coinbase/client/models/smart_contract_type.rb +42 -0
- data/lib/coinbase/client/models/staking_balance.rb +2 -2
- data/lib/coinbase/client/models/staking_reward.rb +2 -2
- data/lib/coinbase/client/models/token_contract_options.rb +257 -0
- data/lib/coinbase/client/models/update_webhook_request.rb +10 -8
- data/lib/coinbase/client/models/user.rb +231 -0
- data/lib/coinbase/client/models/webhook.rb +10 -1
- data/lib/coinbase/client/models/webhook_event_type.rb +2 -1
- data/lib/coinbase/client/models/webhook_event_type_filter.rb +105 -0
- data/lib/coinbase/client/models/webhook_wallet_activity_filter.rb +228 -0
- data/lib/coinbase/client.rb +15 -0
- data/lib/coinbase/contract_invocation.rb +16 -17
- data/lib/coinbase/smart_contract.rb +264 -39
- data/lib/coinbase/transaction.rb +3 -0
- data/lib/coinbase/transfer.rb +1 -1
- data/lib/coinbase/version.rb +1 -1
- data/lib/coinbase/wallet.rb +45 -2
- data/lib/coinbase/webhook.rb +3 -7
- metadata +18 -2
@@ -0,0 +1,378 @@
|
|
1
|
+
=begin
|
2
|
+
#Coinbase Platform API
|
3
|
+
|
4
|
+
#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 0.0.1-alpha
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.8.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Coinbase::Client
|
17
|
+
# Represents a smart contract on the blockchain
|
18
|
+
class SmartContract
|
19
|
+
# The unique identifier of the smart contract
|
20
|
+
attr_accessor :smart_contract_id
|
21
|
+
|
22
|
+
# The name of the blockchain network
|
23
|
+
attr_accessor :network_id
|
24
|
+
|
25
|
+
# The ID of the wallet that deployed the smart contract
|
26
|
+
attr_accessor :wallet_id
|
27
|
+
|
28
|
+
# The EVM address of the smart contract
|
29
|
+
attr_accessor :contract_address
|
30
|
+
|
31
|
+
# The EVM address of the account that deployed the smart contract
|
32
|
+
attr_accessor :deployer_address
|
33
|
+
|
34
|
+
attr_accessor :type
|
35
|
+
|
36
|
+
attr_accessor :options
|
37
|
+
|
38
|
+
# The JSON-encoded ABI of the contract
|
39
|
+
attr_accessor :abi
|
40
|
+
|
41
|
+
attr_accessor :transaction
|
42
|
+
|
43
|
+
class EnumAttributeValidator
|
44
|
+
attr_reader :datatype
|
45
|
+
attr_reader :allowable_values
|
46
|
+
|
47
|
+
def initialize(datatype, allowable_values)
|
48
|
+
@allowable_values = allowable_values.map do |value|
|
49
|
+
case datatype.to_s
|
50
|
+
when /Integer/i
|
51
|
+
value.to_i
|
52
|
+
when /Float/i
|
53
|
+
value.to_f
|
54
|
+
else
|
55
|
+
value
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def valid?(value)
|
61
|
+
!value || allowable_values.include?(value)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
66
|
+
def self.attribute_map
|
67
|
+
{
|
68
|
+
:'smart_contract_id' => :'smart_contract_id',
|
69
|
+
:'network_id' => :'network_id',
|
70
|
+
:'wallet_id' => :'wallet_id',
|
71
|
+
:'contract_address' => :'contract_address',
|
72
|
+
:'deployer_address' => :'deployer_address',
|
73
|
+
:'type' => :'type',
|
74
|
+
:'options' => :'options',
|
75
|
+
:'abi' => :'abi',
|
76
|
+
:'transaction' => :'transaction'
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns all the JSON keys this model knows about
|
81
|
+
def self.acceptable_attributes
|
82
|
+
attribute_map.values
|
83
|
+
end
|
84
|
+
|
85
|
+
# Attribute type mapping.
|
86
|
+
def self.openapi_types
|
87
|
+
{
|
88
|
+
:'smart_contract_id' => :'String',
|
89
|
+
:'network_id' => :'String',
|
90
|
+
:'wallet_id' => :'String',
|
91
|
+
:'contract_address' => :'String',
|
92
|
+
:'deployer_address' => :'String',
|
93
|
+
:'type' => :'SmartContractType',
|
94
|
+
:'options' => :'SmartContractOptions',
|
95
|
+
:'abi' => :'String',
|
96
|
+
:'transaction' => :'Transaction'
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
# List of attributes with nullable: true
|
101
|
+
def self.openapi_nullable
|
102
|
+
Set.new([
|
103
|
+
])
|
104
|
+
end
|
105
|
+
|
106
|
+
# Initializes the object
|
107
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
108
|
+
def initialize(attributes = {})
|
109
|
+
if (!attributes.is_a?(Hash))
|
110
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::SmartContract` initialize method"
|
111
|
+
end
|
112
|
+
|
113
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
114
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
115
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
116
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::SmartContract`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
117
|
+
end
|
118
|
+
h[k.to_sym] = v
|
119
|
+
}
|
120
|
+
|
121
|
+
if attributes.key?(:'smart_contract_id')
|
122
|
+
self.smart_contract_id = attributes[:'smart_contract_id']
|
123
|
+
else
|
124
|
+
self.smart_contract_id = nil
|
125
|
+
end
|
126
|
+
|
127
|
+
if attributes.key?(:'network_id')
|
128
|
+
self.network_id = attributes[:'network_id']
|
129
|
+
else
|
130
|
+
self.network_id = nil
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.key?(:'wallet_id')
|
134
|
+
self.wallet_id = attributes[:'wallet_id']
|
135
|
+
else
|
136
|
+
self.wallet_id = nil
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.key?(:'contract_address')
|
140
|
+
self.contract_address = attributes[:'contract_address']
|
141
|
+
else
|
142
|
+
self.contract_address = nil
|
143
|
+
end
|
144
|
+
|
145
|
+
if attributes.key?(:'deployer_address')
|
146
|
+
self.deployer_address = attributes[:'deployer_address']
|
147
|
+
else
|
148
|
+
self.deployer_address = nil
|
149
|
+
end
|
150
|
+
|
151
|
+
if attributes.key?(:'type')
|
152
|
+
self.type = attributes[:'type']
|
153
|
+
else
|
154
|
+
self.type = nil
|
155
|
+
end
|
156
|
+
|
157
|
+
if attributes.key?(:'options')
|
158
|
+
self.options = attributes[:'options']
|
159
|
+
else
|
160
|
+
self.options = nil
|
161
|
+
end
|
162
|
+
|
163
|
+
if attributes.key?(:'abi')
|
164
|
+
self.abi = attributes[:'abi']
|
165
|
+
else
|
166
|
+
self.abi = nil
|
167
|
+
end
|
168
|
+
|
169
|
+
if attributes.key?(:'transaction')
|
170
|
+
self.transaction = attributes[:'transaction']
|
171
|
+
else
|
172
|
+
self.transaction = nil
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
177
|
+
# @return Array for valid properties with the reasons
|
178
|
+
def list_invalid_properties
|
179
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
180
|
+
invalid_properties = Array.new
|
181
|
+
if @smart_contract_id.nil?
|
182
|
+
invalid_properties.push('invalid value for "smart_contract_id", smart_contract_id cannot be nil.')
|
183
|
+
end
|
184
|
+
|
185
|
+
if @network_id.nil?
|
186
|
+
invalid_properties.push('invalid value for "network_id", network_id cannot be nil.')
|
187
|
+
end
|
188
|
+
|
189
|
+
if @wallet_id.nil?
|
190
|
+
invalid_properties.push('invalid value for "wallet_id", wallet_id cannot be nil.')
|
191
|
+
end
|
192
|
+
|
193
|
+
if @contract_address.nil?
|
194
|
+
invalid_properties.push('invalid value for "contract_address", contract_address cannot be nil.')
|
195
|
+
end
|
196
|
+
|
197
|
+
if @deployer_address.nil?
|
198
|
+
invalid_properties.push('invalid value for "deployer_address", deployer_address cannot be nil.')
|
199
|
+
end
|
200
|
+
|
201
|
+
if @type.nil?
|
202
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
203
|
+
end
|
204
|
+
|
205
|
+
if @options.nil?
|
206
|
+
invalid_properties.push('invalid value for "options", options cannot be nil.')
|
207
|
+
end
|
208
|
+
|
209
|
+
if @abi.nil?
|
210
|
+
invalid_properties.push('invalid value for "abi", abi cannot be nil.')
|
211
|
+
end
|
212
|
+
|
213
|
+
if @transaction.nil?
|
214
|
+
invalid_properties.push('invalid value for "transaction", transaction cannot be nil.')
|
215
|
+
end
|
216
|
+
|
217
|
+
invalid_properties
|
218
|
+
end
|
219
|
+
|
220
|
+
# Check to see if the all the properties in the model are valid
|
221
|
+
# @return true if the model is valid
|
222
|
+
def valid?
|
223
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
224
|
+
return false if @smart_contract_id.nil?
|
225
|
+
return false if @network_id.nil?
|
226
|
+
return false if @wallet_id.nil?
|
227
|
+
return false if @contract_address.nil?
|
228
|
+
return false if @deployer_address.nil?
|
229
|
+
return false if @type.nil?
|
230
|
+
return false if @options.nil?
|
231
|
+
return false if @abi.nil?
|
232
|
+
return false if @transaction.nil?
|
233
|
+
true
|
234
|
+
end
|
235
|
+
|
236
|
+
# Checks equality by comparing each attribute.
|
237
|
+
# @param [Object] Object to be compared
|
238
|
+
def ==(o)
|
239
|
+
return true if self.equal?(o)
|
240
|
+
self.class == o.class &&
|
241
|
+
smart_contract_id == o.smart_contract_id &&
|
242
|
+
network_id == o.network_id &&
|
243
|
+
wallet_id == o.wallet_id &&
|
244
|
+
contract_address == o.contract_address &&
|
245
|
+
deployer_address == o.deployer_address &&
|
246
|
+
type == o.type &&
|
247
|
+
options == o.options &&
|
248
|
+
abi == o.abi &&
|
249
|
+
transaction == o.transaction
|
250
|
+
end
|
251
|
+
|
252
|
+
# @see the `==` method
|
253
|
+
# @param [Object] Object to be compared
|
254
|
+
def eql?(o)
|
255
|
+
self == o
|
256
|
+
end
|
257
|
+
|
258
|
+
# Calculates hash code according to all attributes.
|
259
|
+
# @return [Integer] Hash code
|
260
|
+
def hash
|
261
|
+
[smart_contract_id, network_id, wallet_id, contract_address, deployer_address, type, options, abi, transaction].hash
|
262
|
+
end
|
263
|
+
|
264
|
+
# Builds the object from hash
|
265
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
266
|
+
# @return [Object] Returns the model itself
|
267
|
+
def self.build_from_hash(attributes)
|
268
|
+
return nil unless attributes.is_a?(Hash)
|
269
|
+
attributes = attributes.transform_keys(&:to_sym)
|
270
|
+
transformed_hash = {}
|
271
|
+
openapi_types.each_pair do |key, type|
|
272
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
273
|
+
transformed_hash["#{key}"] = nil
|
274
|
+
elsif type =~ /\AArray<(.*)>/i
|
275
|
+
# check to ensure the input is an array given that the attribute
|
276
|
+
# is documented as an array but the input is not
|
277
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
278
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
279
|
+
end
|
280
|
+
elsif !attributes[attribute_map[key]].nil?
|
281
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
282
|
+
end
|
283
|
+
end
|
284
|
+
new(transformed_hash)
|
285
|
+
end
|
286
|
+
|
287
|
+
# Deserializes the data based on type
|
288
|
+
# @param string type Data type
|
289
|
+
# @param string value Value to be deserialized
|
290
|
+
# @return [Object] Deserialized data
|
291
|
+
def self._deserialize(type, value)
|
292
|
+
case type.to_sym
|
293
|
+
when :Time
|
294
|
+
Time.parse(value)
|
295
|
+
when :Date
|
296
|
+
Date.parse(value)
|
297
|
+
when :String
|
298
|
+
value.to_s
|
299
|
+
when :Integer
|
300
|
+
value.to_i
|
301
|
+
when :Float
|
302
|
+
value.to_f
|
303
|
+
when :Boolean
|
304
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
305
|
+
true
|
306
|
+
else
|
307
|
+
false
|
308
|
+
end
|
309
|
+
when :Object
|
310
|
+
# generic object (usually a Hash), return directly
|
311
|
+
value
|
312
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
313
|
+
inner_type = Regexp.last_match[:inner_type]
|
314
|
+
value.map { |v| _deserialize(inner_type, v) }
|
315
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
316
|
+
k_type = Regexp.last_match[:k_type]
|
317
|
+
v_type = Regexp.last_match[:v_type]
|
318
|
+
{}.tap do |hash|
|
319
|
+
value.each do |k, v|
|
320
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
321
|
+
end
|
322
|
+
end
|
323
|
+
else # model
|
324
|
+
# models (e.g. Pet) or oneOf
|
325
|
+
klass = Coinbase::Client.const_get(type)
|
326
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
# Returns the string representation of the object
|
331
|
+
# @return [String] String presentation of the object
|
332
|
+
def to_s
|
333
|
+
to_hash.to_s
|
334
|
+
end
|
335
|
+
|
336
|
+
# to_body is an alias to to_hash (backward compatibility)
|
337
|
+
# @return [Hash] Returns the object in the form of hash
|
338
|
+
def to_body
|
339
|
+
to_hash
|
340
|
+
end
|
341
|
+
|
342
|
+
# Returns the object in the form of hash
|
343
|
+
# @return [Hash] Returns the object in the form of hash
|
344
|
+
def to_hash
|
345
|
+
hash = {}
|
346
|
+
self.class.attribute_map.each_pair do |attr, param|
|
347
|
+
value = self.send(attr)
|
348
|
+
if value.nil?
|
349
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
350
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
351
|
+
end
|
352
|
+
|
353
|
+
hash[param] = _to_hash(value)
|
354
|
+
end
|
355
|
+
hash
|
356
|
+
end
|
357
|
+
|
358
|
+
# Outputs non-array value in the form of hash
|
359
|
+
# For object, use to_hash. Otherwise, just return the value
|
360
|
+
# @param [Object] value Any valid value
|
361
|
+
# @return [Hash] Returns the value in the form of hash
|
362
|
+
def _to_hash(value)
|
363
|
+
if value.is_a?(Array)
|
364
|
+
value.compact.map { |v| _to_hash(v) }
|
365
|
+
elsif value.is_a?(Hash)
|
366
|
+
{}.tap do |hash|
|
367
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
368
|
+
end
|
369
|
+
elsif value.respond_to? :to_hash
|
370
|
+
value.to_hash
|
371
|
+
else
|
372
|
+
value
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
end
|
377
|
+
|
378
|
+
end
|
@@ -0,0 +1,257 @@
|
|
1
|
+
=begin
|
2
|
+
#Coinbase Platform API
|
3
|
+
|
4
|
+
#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 0.0.1-alpha
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.8.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Coinbase::Client
|
17
|
+
class SmartContractList
|
18
|
+
attr_accessor :data
|
19
|
+
|
20
|
+
# True if this list has another page of items after this one that can be fetched.
|
21
|
+
attr_accessor :has_more
|
22
|
+
|
23
|
+
# The page token to be used to fetch the next page.
|
24
|
+
attr_accessor :next_page
|
25
|
+
|
26
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
27
|
+
def self.attribute_map
|
28
|
+
{
|
29
|
+
:'data' => :'data',
|
30
|
+
:'has_more' => :'has_more',
|
31
|
+
:'next_page' => :'next_page'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Returns all the JSON keys this model knows about
|
36
|
+
def self.acceptable_attributes
|
37
|
+
attribute_map.values
|
38
|
+
end
|
39
|
+
|
40
|
+
# Attribute type mapping.
|
41
|
+
def self.openapi_types
|
42
|
+
{
|
43
|
+
:'data' => :'Array<SmartContract>',
|
44
|
+
:'has_more' => :'Boolean',
|
45
|
+
:'next_page' => :'String'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# List of attributes with nullable: true
|
50
|
+
def self.openapi_nullable
|
51
|
+
Set.new([
|
52
|
+
])
|
53
|
+
end
|
54
|
+
|
55
|
+
# Initializes the object
|
56
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
57
|
+
def initialize(attributes = {})
|
58
|
+
if (!attributes.is_a?(Hash))
|
59
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::SmartContractList` initialize method"
|
60
|
+
end
|
61
|
+
|
62
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
63
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
64
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
65
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::SmartContractList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
66
|
+
end
|
67
|
+
h[k.to_sym] = v
|
68
|
+
}
|
69
|
+
|
70
|
+
if attributes.key?(:'data')
|
71
|
+
if (value = attributes[:'data']).is_a?(Array)
|
72
|
+
self.data = value
|
73
|
+
end
|
74
|
+
else
|
75
|
+
self.data = nil
|
76
|
+
end
|
77
|
+
|
78
|
+
if attributes.key?(:'has_more')
|
79
|
+
self.has_more = attributes[:'has_more']
|
80
|
+
else
|
81
|
+
self.has_more = nil
|
82
|
+
end
|
83
|
+
|
84
|
+
if attributes.key?(:'next_page')
|
85
|
+
self.next_page = attributes[:'next_page']
|
86
|
+
else
|
87
|
+
self.next_page = nil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
92
|
+
# @return Array for valid properties with the reasons
|
93
|
+
def list_invalid_properties
|
94
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
95
|
+
invalid_properties = Array.new
|
96
|
+
if @data.nil?
|
97
|
+
invalid_properties.push('invalid value for "data", data cannot be nil.')
|
98
|
+
end
|
99
|
+
|
100
|
+
if @has_more.nil?
|
101
|
+
invalid_properties.push('invalid value for "has_more", has_more cannot be nil.')
|
102
|
+
end
|
103
|
+
|
104
|
+
if @next_page.nil?
|
105
|
+
invalid_properties.push('invalid value for "next_page", next_page cannot be nil.')
|
106
|
+
end
|
107
|
+
|
108
|
+
invalid_properties
|
109
|
+
end
|
110
|
+
|
111
|
+
# Check to see if the all the properties in the model are valid
|
112
|
+
# @return true if the model is valid
|
113
|
+
def valid?
|
114
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
115
|
+
return false if @data.nil?
|
116
|
+
return false if @has_more.nil?
|
117
|
+
return false if @next_page.nil?
|
118
|
+
true
|
119
|
+
end
|
120
|
+
|
121
|
+
# Checks equality by comparing each attribute.
|
122
|
+
# @param [Object] Object to be compared
|
123
|
+
def ==(o)
|
124
|
+
return true if self.equal?(o)
|
125
|
+
self.class == o.class &&
|
126
|
+
data == o.data &&
|
127
|
+
has_more == o.has_more &&
|
128
|
+
next_page == o.next_page
|
129
|
+
end
|
130
|
+
|
131
|
+
# @see the `==` method
|
132
|
+
# @param [Object] Object to be compared
|
133
|
+
def eql?(o)
|
134
|
+
self == o
|
135
|
+
end
|
136
|
+
|
137
|
+
# Calculates hash code according to all attributes.
|
138
|
+
# @return [Integer] Hash code
|
139
|
+
def hash
|
140
|
+
[data, has_more, next_page].hash
|
141
|
+
end
|
142
|
+
|
143
|
+
# Builds the object from hash
|
144
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
145
|
+
# @return [Object] Returns the model itself
|
146
|
+
def self.build_from_hash(attributes)
|
147
|
+
return nil unless attributes.is_a?(Hash)
|
148
|
+
attributes = attributes.transform_keys(&:to_sym)
|
149
|
+
transformed_hash = {}
|
150
|
+
openapi_types.each_pair do |key, type|
|
151
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
152
|
+
transformed_hash["#{key}"] = nil
|
153
|
+
elsif type =~ /\AArray<(.*)>/i
|
154
|
+
# check to ensure the input is an array given that the attribute
|
155
|
+
# is documented as an array but the input is not
|
156
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
157
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
158
|
+
end
|
159
|
+
elsif !attributes[attribute_map[key]].nil?
|
160
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
161
|
+
end
|
162
|
+
end
|
163
|
+
new(transformed_hash)
|
164
|
+
end
|
165
|
+
|
166
|
+
# Deserializes the data based on type
|
167
|
+
# @param string type Data type
|
168
|
+
# @param string value Value to be deserialized
|
169
|
+
# @return [Object] Deserialized data
|
170
|
+
def self._deserialize(type, value)
|
171
|
+
case type.to_sym
|
172
|
+
when :Time
|
173
|
+
Time.parse(value)
|
174
|
+
when :Date
|
175
|
+
Date.parse(value)
|
176
|
+
when :String
|
177
|
+
value.to_s
|
178
|
+
when :Integer
|
179
|
+
value.to_i
|
180
|
+
when :Float
|
181
|
+
value.to_f
|
182
|
+
when :Boolean
|
183
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
184
|
+
true
|
185
|
+
else
|
186
|
+
false
|
187
|
+
end
|
188
|
+
when :Object
|
189
|
+
# generic object (usually a Hash), return directly
|
190
|
+
value
|
191
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
192
|
+
inner_type = Regexp.last_match[:inner_type]
|
193
|
+
value.map { |v| _deserialize(inner_type, v) }
|
194
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
195
|
+
k_type = Regexp.last_match[:k_type]
|
196
|
+
v_type = Regexp.last_match[:v_type]
|
197
|
+
{}.tap do |hash|
|
198
|
+
value.each do |k, v|
|
199
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
else # model
|
203
|
+
# models (e.g. Pet) or oneOf
|
204
|
+
klass = Coinbase::Client.const_get(type)
|
205
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
# Returns the string representation of the object
|
210
|
+
# @return [String] String presentation of the object
|
211
|
+
def to_s
|
212
|
+
to_hash.to_s
|
213
|
+
end
|
214
|
+
|
215
|
+
# to_body is an alias to to_hash (backward compatibility)
|
216
|
+
# @return [Hash] Returns the object in the form of hash
|
217
|
+
def to_body
|
218
|
+
to_hash
|
219
|
+
end
|
220
|
+
|
221
|
+
# Returns the object in the form of hash
|
222
|
+
# @return [Hash] Returns the object in the form of hash
|
223
|
+
def to_hash
|
224
|
+
hash = {}
|
225
|
+
self.class.attribute_map.each_pair do |attr, param|
|
226
|
+
value = self.send(attr)
|
227
|
+
if value.nil?
|
228
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
229
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
230
|
+
end
|
231
|
+
|
232
|
+
hash[param] = _to_hash(value)
|
233
|
+
end
|
234
|
+
hash
|
235
|
+
end
|
236
|
+
|
237
|
+
# Outputs non-array value in the form of hash
|
238
|
+
# For object, use to_hash. Otherwise, just return the value
|
239
|
+
# @param [Object] value Any valid value
|
240
|
+
# @return [Hash] Returns the value in the form of hash
|
241
|
+
def _to_hash(value)
|
242
|
+
if value.is_a?(Array)
|
243
|
+
value.compact.map { |v| _to_hash(v) }
|
244
|
+
elsif value.is_a?(Hash)
|
245
|
+
{}.tap do |hash|
|
246
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
247
|
+
end
|
248
|
+
elsif value.respond_to? :to_hash
|
249
|
+
value.to_hash
|
250
|
+
else
|
251
|
+
value
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|