coinbase-sdk 0.3.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address/wallet_address.rb +35 -2
  3. data/lib/coinbase/address.rb +5 -1
  4. data/lib/coinbase/client/api/addresses_api.rb +10 -10
  5. data/lib/coinbase/client/api/assets_api.rb +2 -2
  6. data/lib/coinbase/client/api/balance_history_api.rb +107 -0
  7. data/lib/coinbase/client/api/contract_events_api.rb +4 -4
  8. data/lib/coinbase/client/api/contract_invocations_api.rb +5 -5
  9. data/lib/coinbase/client/api/external_addresses_api.rb +5 -90
  10. data/lib/coinbase/client/api/networks_api.rb +2 -2
  11. data/lib/coinbase/client/api/server_signers_api.rb +7 -7
  12. data/lib/coinbase/client/api/smart_contracts_api.rb +332 -0
  13. data/lib/coinbase/client/api/stake_api.rb +6 -14
  14. data/lib/coinbase/client/api/trades_api.rb +5 -5
  15. data/lib/coinbase/client/api/transfers_api.rb +5 -5
  16. data/lib/coinbase/client/api/users_api.rb +2 -2
  17. data/lib/coinbase/client/api/validators_api.rb +3 -3
  18. data/lib/coinbase/client/api/wallet_stake_api.rb +4 -4
  19. data/lib/coinbase/client/api/wallets_api.rb +6 -6
  20. data/lib/coinbase/client/api/webhooks_api.rb +5 -5
  21. data/lib/coinbase/client/api_client.rb +30 -24
  22. data/lib/coinbase/client/api_error.rb +1 -1
  23. data/lib/coinbase/client/configuration.rb +1 -1
  24. data/lib/coinbase/client/models/address.rb +1 -1
  25. data/lib/coinbase/client/models/address_balance_list.rb +1 -1
  26. data/lib/coinbase/client/models/address_historical_balance_list.rb +1 -1
  27. data/lib/coinbase/client/models/address_list.rb +1 -1
  28. data/lib/coinbase/client/models/address_transaction_list.rb +1 -1
  29. data/lib/coinbase/client/models/asset.rb +1 -1
  30. data/lib/coinbase/client/models/balance.rb +1 -1
  31. data/lib/coinbase/client/models/broadcast_contract_invocation_request.rb +1 -1
  32. data/lib/coinbase/client/models/broadcast_staking_operation_request.rb +1 -1
  33. data/lib/coinbase/client/models/broadcast_trade_request.rb +1 -1
  34. data/lib/coinbase/client/models/broadcast_transfer_request.rb +1 -1
  35. data/lib/coinbase/client/models/build_staking_operation_request.rb +1 -1
  36. data/lib/coinbase/client/models/contract_event.rb +1 -1
  37. data/lib/coinbase/client/models/contract_event_list.rb +1 -1
  38. data/lib/coinbase/client/models/contract_invocation.rb +19 -2
  39. data/lib/coinbase/client/models/contract_invocation_list.rb +1 -1
  40. data/lib/coinbase/client/models/create_address_request.rb +1 -1
  41. data/lib/coinbase/client/models/create_contract_invocation_request.rb +15 -5
  42. data/lib/coinbase/client/models/create_payload_signature_request.rb +1 -1
  43. data/lib/coinbase/client/models/create_server_signer_request.rb +1 -1
  44. data/lib/coinbase/client/models/create_smart_contract_request.rb +259 -0
  45. data/lib/coinbase/client/models/create_staking_operation_request.rb +1 -1
  46. data/lib/coinbase/client/models/create_trade_request.rb +1 -1
  47. data/lib/coinbase/client/models/create_transfer_request.rb +2 -2
  48. data/lib/coinbase/client/models/create_wallet_request.rb +1 -1
  49. data/lib/coinbase/client/models/create_wallet_request_wallet.rb +1 -1
  50. data/lib/coinbase/client/models/create_webhook_request.rb +11 -9
  51. data/lib/coinbase/client/models/deploy_smart_contract_request.rb +222 -0
  52. data/lib/coinbase/client/models/erc20_transfer_event.rb +336 -0
  53. data/lib/coinbase/client/models/erc721_transfer_event.rb +336 -0
  54. data/lib/coinbase/client/models/error.rb +15 -5
  55. data/lib/coinbase/client/models/ethereum_transaction.rb +1 -1
  56. data/lib/coinbase/client/models/ethereum_transaction_access.rb +1 -1
  57. data/lib/coinbase/client/models/ethereum_transaction_access_list.rb +1 -1
  58. data/lib/coinbase/client/models/ethereum_transaction_flattened_trace.rb +1 -1
  59. data/lib/coinbase/client/models/ethereum_validator_metadata.rb +1 -1
  60. data/lib/coinbase/client/models/faucet_transaction.rb +1 -1
  61. data/lib/coinbase/client/models/feature_set.rb +1 -1
  62. data/lib/coinbase/client/models/fetch_historical_staking_balances200_response.rb +1 -1
  63. data/lib/coinbase/client/models/fetch_staking_rewards200_response.rb +1 -1
  64. data/lib/coinbase/client/models/fetch_staking_rewards_request.rb +1 -1
  65. data/lib/coinbase/client/models/get_staking_context_request.rb +1 -1
  66. data/lib/coinbase/client/models/historical_balance.rb +1 -1
  67. data/lib/coinbase/client/models/network.rb +1 -1
  68. data/lib/coinbase/client/models/network_identifier.rb +3 -2
  69. data/lib/coinbase/client/models/nft_contract_options.rb +240 -0
  70. data/lib/coinbase/client/models/payload_signature.rb +1 -1
  71. data/lib/coinbase/client/models/payload_signature_list.rb +1 -1
  72. data/lib/coinbase/client/models/seed_creation_event.rb +1 -1
  73. data/lib/coinbase/client/models/seed_creation_event_result.rb +1 -1
  74. data/lib/coinbase/client/models/server_signer.rb +1 -1
  75. data/lib/coinbase/client/models/server_signer_event.rb +1 -1
  76. data/lib/coinbase/client/models/server_signer_event_event.rb +1 -1
  77. data/lib/coinbase/client/models/server_signer_event_list.rb +1 -1
  78. data/lib/coinbase/client/models/server_signer_list.rb +1 -1
  79. data/lib/coinbase/client/models/signature_creation_event.rb +1 -1
  80. data/lib/coinbase/client/models/signature_creation_event_result.rb +1 -1
  81. data/lib/coinbase/client/models/signed_voluntary_exit_message_metadata.rb +1 -1
  82. data/lib/coinbase/client/models/smart_contract.rb +378 -0
  83. data/lib/coinbase/client/models/smart_contract_list.rb +257 -0
  84. data/lib/coinbase/client/models/smart_contract_options.rb +106 -0
  85. data/lib/coinbase/client/models/smart_contract_type.rb +41 -0
  86. data/lib/coinbase/client/models/sponsored_send.rb +1 -1
  87. data/lib/coinbase/client/models/staking_balance.rb +3 -3
  88. data/lib/coinbase/client/models/staking_context.rb +1 -1
  89. data/lib/coinbase/client/models/staking_context_context.rb +1 -1
  90. data/lib/coinbase/client/models/staking_operation.rb +1 -1
  91. data/lib/coinbase/client/models/staking_operation_metadata.rb +1 -1
  92. data/lib/coinbase/client/models/staking_reward.rb +3 -3
  93. data/lib/coinbase/client/models/staking_reward_format.rb +1 -1
  94. data/lib/coinbase/client/models/staking_reward_usd_value.rb +1 -1
  95. data/lib/coinbase/client/models/token_contract_options.rb +257 -0
  96. data/lib/coinbase/client/models/trade.rb +1 -1
  97. data/lib/coinbase/client/models/trade_list.rb +1 -1
  98. data/lib/coinbase/client/models/transaction.rb +1 -1
  99. data/lib/coinbase/client/models/transaction_content.rb +1 -1
  100. data/lib/coinbase/client/models/transaction_type.rb +1 -1
  101. data/lib/coinbase/client/models/transfer.rb +1 -1
  102. data/lib/coinbase/client/models/transfer_list.rb +1 -1
  103. data/lib/coinbase/client/models/update_webhook_request.rb +11 -9
  104. data/lib/coinbase/client/models/user.rb +1 -1
  105. data/lib/coinbase/client/models/validator.rb +1 -1
  106. data/lib/coinbase/client/models/validator_details.rb +1 -1
  107. data/lib/coinbase/client/models/validator_list.rb +1 -1
  108. data/lib/coinbase/client/models/validator_status.rb +1 -1
  109. data/lib/coinbase/client/models/wallet.rb +1 -1
  110. data/lib/coinbase/client/models/wallet_list.rb +1 -1
  111. data/lib/coinbase/client/models/webhook.rb +11 -2
  112. data/lib/coinbase/client/models/webhook_event_filter.rb +4 -4
  113. data/lib/coinbase/client/models/webhook_event_type.rb +3 -2
  114. data/lib/coinbase/client/models/webhook_event_type_filter.rb +105 -0
  115. data/lib/coinbase/client/models/webhook_list.rb +1 -1
  116. data/lib/coinbase/client/models/webhook_wallet_activity_filter.rb +228 -0
  117. data/lib/coinbase/client/version.rb +1 -1
  118. data/lib/coinbase/client.rb +15 -1
  119. data/lib/coinbase/contract_invocation.rb +34 -10
  120. data/lib/coinbase/smart_contract.rb +216 -45
  121. data/lib/coinbase/transaction.rb +3 -0
  122. data/lib/coinbase/transfer.rb +1 -1
  123. data/lib/coinbase/version.rb +1 -1
  124. data/lib/coinbase/wallet.rb +11 -2
  125. metadata +16 -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