coinbase-sdk 0.11.0 → 0.14.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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address/wallet_address.rb +6 -3
  3. data/lib/coinbase/address.rb +22 -3
  4. data/lib/coinbase/address_reputation.rb +67 -0
  5. data/lib/coinbase/client/api/addresses_api.rb +9 -9
  6. data/lib/coinbase/client/api/assets_api.rb +1 -1
  7. data/lib/coinbase/client/api/balance_history_api.rb +1 -1
  8. data/lib/coinbase/client/api/contract_events_api.rb +1 -1
  9. data/lib/coinbase/client/api/contract_invocations_api.rb +4 -4
  10. data/lib/coinbase/client/api/external_addresses_api.rb +245 -4
  11. data/lib/coinbase/client/api/fund_api.rb +4 -4
  12. data/lib/coinbase/client/api/mpc_wallet_stake_api.rb +3 -3
  13. data/lib/coinbase/client/api/networks_api.rb +1 -1
  14. data/lib/coinbase/client/api/onchain_identity_api.rb +1 -1
  15. data/lib/coinbase/client/api/reputation_api.rb +1 -70
  16. data/lib/coinbase/client/api/server_signers_api.rb +6 -6
  17. data/lib/coinbase/client/api/smart_contracts_api.rb +168 -25
  18. data/lib/coinbase/client/api/stake_api.rb +7 -7
  19. data/lib/coinbase/client/api/trades_api.rb +4 -4
  20. data/lib/coinbase/client/api/transaction_history_api.rb +1 -1
  21. data/lib/coinbase/client/api/transfers_api.rb +4 -4
  22. data/lib/coinbase/client/api/wallets_api.rb +5 -5
  23. data/lib/coinbase/client/api/webhooks_api.rb +5 -5
  24. data/lib/coinbase/client/configuration.rb +14 -0
  25. data/lib/coinbase/client/models/address_reputation.rb +15 -8
  26. data/lib/coinbase/client/models/{address_risk.rb → broadcast_external_transfer_request.rb} +15 -16
  27. data/lib/coinbase/client/models/create_external_transfer_request.rb +283 -0
  28. data/lib/coinbase/client/models/create_fund_operation_request.rb +1 -1
  29. data/lib/coinbase/client/models/create_fund_quote_request.rb +1 -1
  30. data/lib/coinbase/client/models/create_transfer_request.rb +15 -5
  31. data/lib/coinbase/client/models/ethereum_transaction.rb +14 -4
  32. data/lib/coinbase/client/models/register_smart_contract_request.rb +252 -0
  33. data/lib/coinbase/client/models/smart_contract.rb +36 -30
  34. data/lib/coinbase/client/models/smart_contract_activity_event.rb +386 -0
  35. data/lib/coinbase/client/models/smart_contract_type.rb +2 -1
  36. data/lib/coinbase/client/models/transfer.rb +1 -36
  37. data/lib/coinbase/client/models/update_smart_contract_request.rb +245 -0
  38. data/lib/coinbase/client/models/webhook_event_type.rb +2 -1
  39. data/lib/coinbase/client/models/webhook_event_type_filter.rb +1 -0
  40. data/lib/coinbase/client/models/webhook_smart_contract_event_filter.rb +225 -0
  41. data/lib/coinbase/client/models/webhook_wallet_activity_filter.rb +7 -0
  42. data/lib/coinbase/client.rb +6 -1
  43. data/lib/coinbase/errors.rb +8 -0
  44. data/lib/coinbase/smart_contract.rb +338 -245
  45. data/lib/coinbase/transfer.rb +24 -2
  46. data/lib/coinbase/version.rb +1 -1
  47. data/lib/coinbase/wallet/data.rb +6 -4
  48. data/lib/coinbase/wallet.rb +3 -2
  49. data/lib/coinbase.rb +2 -1
  50. metadata +13 -7
@@ -0,0 +1,386 @@
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.9.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ # Represents an event triggered by a smart contract activity on the blockchain. Contains information about the function, transaction, block, and involved addresses.
18
+ class SmartContractActivityEvent
19
+ # Unique identifier for the webhook that triggered this event.
20
+ attr_accessor :webhook_id
21
+
22
+ # Type of event, in this case, an ERC-721 token transfer.
23
+ attr_accessor :event_type
24
+
25
+ # Blockchain network where the event occurred.
26
+ attr_accessor :network
27
+
28
+ # Name of the project this smart contract belongs to.
29
+ attr_accessor :project_name
30
+
31
+ # Name of the contract.
32
+ attr_accessor :contract_name
33
+
34
+ # Name of the function.
35
+ attr_accessor :func
36
+
37
+ # Signature of the function.
38
+ attr_accessor :sig
39
+
40
+ # First 4 bytes of the Transaction, a unique ID.
41
+ attr_accessor :four_bytes
42
+
43
+ # Address of the smart contract.
44
+ attr_accessor :contract_address
45
+
46
+ # Hash of the block containing the transaction.
47
+ attr_accessor :block_hash
48
+
49
+ # Number of the block containing the transaction.
50
+ attr_accessor :block_number
51
+
52
+ # Timestamp when the block was mined.
53
+ attr_accessor :block_time
54
+
55
+ # Hash of the transaction that triggered the event.
56
+ attr_accessor :transaction_hash
57
+
58
+ # Position of the transaction within the block.
59
+ attr_accessor :transaction_index
60
+
61
+ # Position of the event log within the transaction.
62
+ attr_accessor :log_index
63
+
64
+ # Address of the initiator in the transfer.
65
+ attr_accessor :from
66
+
67
+ # Address of the recipient in the transfer.
68
+ attr_accessor :to
69
+
70
+ # Amount of tokens transferred, typically in the smallest unit (e.g., wei for Ethereum).
71
+ attr_accessor :value
72
+
73
+ # Attribute mapping from ruby-style variable name to JSON key.
74
+ def self.attribute_map
75
+ {
76
+ :'webhook_id' => :'webhookId',
77
+ :'event_type' => :'eventType',
78
+ :'network' => :'network',
79
+ :'project_name' => :'projectName',
80
+ :'contract_name' => :'contractName',
81
+ :'func' => :'func',
82
+ :'sig' => :'sig',
83
+ :'four_bytes' => :'fourBytes',
84
+ :'contract_address' => :'contractAddress',
85
+ :'block_hash' => :'blockHash',
86
+ :'block_number' => :'blockNumber',
87
+ :'block_time' => :'blockTime',
88
+ :'transaction_hash' => :'transactionHash',
89
+ :'transaction_index' => :'transactionIndex',
90
+ :'log_index' => :'logIndex',
91
+ :'from' => :'from',
92
+ :'to' => :'to',
93
+ :'value' => :'value'
94
+ }
95
+ end
96
+
97
+ # Returns all the JSON keys this model knows about
98
+ def self.acceptable_attributes
99
+ attribute_map.values
100
+ end
101
+
102
+ # Attribute type mapping.
103
+ def self.openapi_types
104
+ {
105
+ :'webhook_id' => :'String',
106
+ :'event_type' => :'String',
107
+ :'network' => :'String',
108
+ :'project_name' => :'String',
109
+ :'contract_name' => :'String',
110
+ :'func' => :'String',
111
+ :'sig' => :'String',
112
+ :'four_bytes' => :'String',
113
+ :'contract_address' => :'String',
114
+ :'block_hash' => :'String',
115
+ :'block_number' => :'Integer',
116
+ :'block_time' => :'Time',
117
+ :'transaction_hash' => :'String',
118
+ :'transaction_index' => :'Integer',
119
+ :'log_index' => :'Integer',
120
+ :'from' => :'String',
121
+ :'to' => :'String',
122
+ :'value' => :'Integer'
123
+ }
124
+ end
125
+
126
+ # List of attributes with nullable: true
127
+ def self.openapi_nullable
128
+ Set.new([
129
+ ])
130
+ end
131
+
132
+ # Initializes the object
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ def initialize(attributes = {})
135
+ if (!attributes.is_a?(Hash))
136
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::SmartContractActivityEvent` initialize method"
137
+ end
138
+
139
+ # check to see if the attribute exists and convert string to symbol for hash key
140
+ attributes = attributes.each_with_object({}) { |(k, v), h|
141
+ if (!self.class.attribute_map.key?(k.to_sym))
142
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::SmartContractActivityEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
143
+ end
144
+ h[k.to_sym] = v
145
+ }
146
+
147
+ if attributes.key?(:'webhook_id')
148
+ self.webhook_id = attributes[:'webhook_id']
149
+ end
150
+
151
+ if attributes.key?(:'event_type')
152
+ self.event_type = attributes[:'event_type']
153
+ end
154
+
155
+ if attributes.key?(:'network')
156
+ self.network = attributes[:'network']
157
+ end
158
+
159
+ if attributes.key?(:'project_name')
160
+ self.project_name = attributes[:'project_name']
161
+ end
162
+
163
+ if attributes.key?(:'contract_name')
164
+ self.contract_name = attributes[:'contract_name']
165
+ end
166
+
167
+ if attributes.key?(:'func')
168
+ self.func = attributes[:'func']
169
+ end
170
+
171
+ if attributes.key?(:'sig')
172
+ self.sig = attributes[:'sig']
173
+ end
174
+
175
+ if attributes.key?(:'four_bytes')
176
+ self.four_bytes = attributes[:'four_bytes']
177
+ end
178
+
179
+ if attributes.key?(:'contract_address')
180
+ self.contract_address = attributes[:'contract_address']
181
+ end
182
+
183
+ if attributes.key?(:'block_hash')
184
+ self.block_hash = attributes[:'block_hash']
185
+ end
186
+
187
+ if attributes.key?(:'block_number')
188
+ self.block_number = attributes[:'block_number']
189
+ end
190
+
191
+ if attributes.key?(:'block_time')
192
+ self.block_time = attributes[:'block_time']
193
+ end
194
+
195
+ if attributes.key?(:'transaction_hash')
196
+ self.transaction_hash = attributes[:'transaction_hash']
197
+ end
198
+
199
+ if attributes.key?(:'transaction_index')
200
+ self.transaction_index = attributes[:'transaction_index']
201
+ end
202
+
203
+ if attributes.key?(:'log_index')
204
+ self.log_index = attributes[:'log_index']
205
+ end
206
+
207
+ if attributes.key?(:'from')
208
+ self.from = attributes[:'from']
209
+ end
210
+
211
+ if attributes.key?(:'to')
212
+ self.to = attributes[:'to']
213
+ end
214
+
215
+ if attributes.key?(:'value')
216
+ self.value = attributes[:'value']
217
+ end
218
+ end
219
+
220
+ # Show invalid properties with the reasons. Usually used together with valid?
221
+ # @return Array for valid properties with the reasons
222
+ def list_invalid_properties
223
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
224
+ invalid_properties = Array.new
225
+ invalid_properties
226
+ end
227
+
228
+ # Check to see if the all the properties in the model are valid
229
+ # @return true if the model is valid
230
+ def valid?
231
+ warn '[DEPRECATED] the `valid?` method is obsolete'
232
+ true
233
+ end
234
+
235
+ # Checks equality by comparing each attribute.
236
+ # @param [Object] Object to be compared
237
+ def ==(o)
238
+ return true if self.equal?(o)
239
+ self.class == o.class &&
240
+ webhook_id == o.webhook_id &&
241
+ event_type == o.event_type &&
242
+ network == o.network &&
243
+ project_name == o.project_name &&
244
+ contract_name == o.contract_name &&
245
+ func == o.func &&
246
+ sig == o.sig &&
247
+ four_bytes == o.four_bytes &&
248
+ contract_address == o.contract_address &&
249
+ block_hash == o.block_hash &&
250
+ block_number == o.block_number &&
251
+ block_time == o.block_time &&
252
+ transaction_hash == o.transaction_hash &&
253
+ transaction_index == o.transaction_index &&
254
+ log_index == o.log_index &&
255
+ from == o.from &&
256
+ to == o.to &&
257
+ value == o.value
258
+ end
259
+
260
+ # @see the `==` method
261
+ # @param [Object] Object to be compared
262
+ def eql?(o)
263
+ self == o
264
+ end
265
+
266
+ # Calculates hash code according to all attributes.
267
+ # @return [Integer] Hash code
268
+ def hash
269
+ [webhook_id, event_type, network, project_name, contract_name, func, sig, four_bytes, contract_address, block_hash, block_number, block_time, transaction_hash, transaction_index, log_index, from, to, value].hash
270
+ end
271
+
272
+ # Builds the object from hash
273
+ # @param [Hash] attributes Model attributes in the form of hash
274
+ # @return [Object] Returns the model itself
275
+ def self.build_from_hash(attributes)
276
+ return nil unless attributes.is_a?(Hash)
277
+ attributes = attributes.transform_keys(&:to_sym)
278
+ transformed_hash = {}
279
+ openapi_types.each_pair do |key, type|
280
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
281
+ transformed_hash["#{key}"] = nil
282
+ elsif type =~ /\AArray<(.*)>/i
283
+ # check to ensure the input is an array given that the attribute
284
+ # is documented as an array but the input is not
285
+ if attributes[attribute_map[key]].is_a?(Array)
286
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
287
+ end
288
+ elsif !attributes[attribute_map[key]].nil?
289
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
290
+ end
291
+ end
292
+ new(transformed_hash)
293
+ end
294
+
295
+ # Deserializes the data based on type
296
+ # @param string type Data type
297
+ # @param string value Value to be deserialized
298
+ # @return [Object] Deserialized data
299
+ def self._deserialize(type, value)
300
+ case type.to_sym
301
+ when :Time
302
+ Time.parse(value)
303
+ when :Date
304
+ Date.parse(value)
305
+ when :String
306
+ value.to_s
307
+ when :Integer
308
+ value.to_i
309
+ when :Float
310
+ value.to_f
311
+ when :Boolean
312
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
313
+ true
314
+ else
315
+ false
316
+ end
317
+ when :Object
318
+ # generic object (usually a Hash), return directly
319
+ value
320
+ when /\AArray<(?<inner_type>.+)>\z/
321
+ inner_type = Regexp.last_match[:inner_type]
322
+ value.map { |v| _deserialize(inner_type, v) }
323
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
324
+ k_type = Regexp.last_match[:k_type]
325
+ v_type = Regexp.last_match[:v_type]
326
+ {}.tap do |hash|
327
+ value.each do |k, v|
328
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
329
+ end
330
+ end
331
+ else # model
332
+ # models (e.g. Pet) or oneOf
333
+ klass = Coinbase::Client.const_get(type)
334
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
335
+ end
336
+ end
337
+
338
+ # Returns the string representation of the object
339
+ # @return [String] String presentation of the object
340
+ def to_s
341
+ to_hash.to_s
342
+ end
343
+
344
+ # to_body is an alias to to_hash (backward compatibility)
345
+ # @return [Hash] Returns the object in the form of hash
346
+ def to_body
347
+ to_hash
348
+ end
349
+
350
+ # Returns the object in the form of hash
351
+ # @return [Hash] Returns the object in the form of hash
352
+ def to_hash
353
+ hash = {}
354
+ self.class.attribute_map.each_pair do |attr, param|
355
+ value = self.send(attr)
356
+ if value.nil?
357
+ is_nullable = self.class.openapi_nullable.include?(attr)
358
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
359
+ end
360
+
361
+ hash[param] = _to_hash(value)
362
+ end
363
+ hash
364
+ end
365
+
366
+ # Outputs non-array value in the form of hash
367
+ # For object, use to_hash. Otherwise, just return the value
368
+ # @param [Object] value Any valid value
369
+ # @return [Hash] Returns the value in the form of hash
370
+ def _to_hash(value)
371
+ if value.is_a?(Array)
372
+ value.compact.map { |v| _to_hash(v) }
373
+ elsif value.is_a?(Hash)
374
+ {}.tap do |hash|
375
+ value.each { |k, v| hash[k] = _to_hash(v) }
376
+ end
377
+ elsif value.respond_to? :to_hash
378
+ value.to_hash
379
+ else
380
+ value
381
+ end
382
+ end
383
+
384
+ end
385
+
386
+ end
@@ -18,10 +18,11 @@ module Coinbase::Client
18
18
  ERC20 = "erc20".freeze
19
19
  ERC721 = "erc721".freeze
20
20
  ERC1155 = "erc1155".freeze
21
+ CUSTOM = "custom".freeze
21
22
  UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze
22
23
 
23
24
  def self.all_vars
24
- @all_vars ||= [ERC20, ERC721, ERC1155, UNKNOWN_DEFAULT_OPEN_API].freeze
25
+ @all_vars ||= [ERC20, ERC721, ERC1155, CUSTOM, UNKNOWN_DEFAULT_OPEN_API].freeze
25
26
  end
26
27
 
27
28
  # Builds the enum from string
@@ -31,7 +31,7 @@ module Coinbase::Client
31
31
  # The amount in the atomic units of the asset
32
32
  attr_accessor :amount
33
33
 
34
- # The ID of the asset being transferred
34
+ # The ID of the asset being transferred. Use `asset.asset_id` instead.
35
35
  attr_accessor :asset_id
36
36
 
37
37
  attr_accessor :asset
@@ -52,34 +52,11 @@ module Coinbase::Client
52
52
  # The hash of the transfer transaction
53
53
  attr_accessor :transaction_hash
54
54
 
55
- # The status of the transfer
56
55
  attr_accessor :status
57
56
 
58
57
  # Whether the transfer uses sponsored gas
59
58
  attr_accessor :gasless
60
59
 
61
- class EnumAttributeValidator
62
- attr_reader :datatype
63
- attr_reader :allowable_values
64
-
65
- def initialize(datatype, allowable_values)
66
- @allowable_values = allowable_values.map do |value|
67
- case datatype.to_s
68
- when /Integer/i
69
- value.to_i
70
- when /Float/i
71
- value.to_f
72
- else
73
- value
74
- end
75
- end
76
- end
77
-
78
- def valid?(value)
79
- !value || allowable_values.include?(value)
80
- end
81
- end
82
-
83
60
  # Attribute mapping from ruby-style variable name to JSON key.
84
61
  def self.attribute_map
85
62
  {
@@ -283,22 +260,10 @@ module Coinbase::Client
283
260
  return false if @asset_id.nil?
284
261
  return false if @asset.nil?
285
262
  return false if @transfer_id.nil?
286
- status_validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed", "unknown_default_open_api"])
287
- return false unless status_validator.valid?(@status)
288
263
  return false if @gasless.nil?
289
264
  true
290
265
  end
291
266
 
292
- # Custom attribute writer method checking allowed values (enum).
293
- # @param [Object] status Object to be assigned
294
- def status=(status)
295
- validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed", "unknown_default_open_api"])
296
- unless validator.valid?(status)
297
- fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
298
- end
299
- @status = status
300
- end
301
-
302
267
  # Checks equality by comparing each attribute.
303
268
  # @param [Object] Object to be compared
304
269
  def ==(o)
@@ -0,0 +1,245 @@
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.9.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ # Smart Contract data to be updated
18
+ class UpdateSmartContractRequest
19
+ # ABI of the smart contract
20
+ attr_accessor :abi
21
+
22
+ # Name of the smart contract
23
+ attr_accessor :contract_name
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'abi' => :'abi',
29
+ :'contract_name' => :'contract_name'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'abi' => :'String',
42
+ :'contract_name' => :'String'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ ])
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ if (!attributes.is_a?(Hash))
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::UpdateSmartContractRequest` initialize method"
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!self.class.attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::UpdateSmartContractRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'abi')
68
+ self.abi = attributes[:'abi']
69
+ end
70
+
71
+ if attributes.key?(:'contract_name')
72
+ self.contract_name = attributes[:'contract_name']
73
+ end
74
+ end
75
+
76
+ # Show invalid properties with the reasons. Usually used together with valid?
77
+ # @return Array for valid properties with the reasons
78
+ def list_invalid_properties
79
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
80
+ invalid_properties = Array.new
81
+ if !@contract_name.nil? && @contract_name.to_s.length > 100
82
+ invalid_properties.push('invalid value for "contract_name", the character length must be smaller than or equal to 100.')
83
+ end
84
+
85
+ invalid_properties
86
+ end
87
+
88
+ # Check to see if the all the properties in the model are valid
89
+ # @return true if the model is valid
90
+ def valid?
91
+ warn '[DEPRECATED] the `valid?` method is obsolete'
92
+ return false if !@contract_name.nil? && @contract_name.to_s.length > 100
93
+ true
94
+ end
95
+
96
+ # Custom attribute writer method with validation
97
+ # @param [Object] contract_name Value to be assigned
98
+ def contract_name=(contract_name)
99
+ if contract_name.nil?
100
+ fail ArgumentError, 'contract_name cannot be nil'
101
+ end
102
+
103
+ if contract_name.to_s.length > 100
104
+ fail ArgumentError, 'invalid value for "contract_name", the character length must be smaller than or equal to 100.'
105
+ end
106
+
107
+ @contract_name = contract_name
108
+ end
109
+
110
+ # Checks equality by comparing each attribute.
111
+ # @param [Object] Object to be compared
112
+ def ==(o)
113
+ return true if self.equal?(o)
114
+ self.class == o.class &&
115
+ abi == o.abi &&
116
+ contract_name == o.contract_name
117
+ end
118
+
119
+ # @see the `==` method
120
+ # @param [Object] Object to be compared
121
+ def eql?(o)
122
+ self == o
123
+ end
124
+
125
+ # Calculates hash code according to all attributes.
126
+ # @return [Integer] Hash code
127
+ def hash
128
+ [abi, contract_name].hash
129
+ end
130
+
131
+ # Builds the object from hash
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ # @return [Object] Returns the model itself
134
+ def self.build_from_hash(attributes)
135
+ return nil unless attributes.is_a?(Hash)
136
+ attributes = attributes.transform_keys(&:to_sym)
137
+ transformed_hash = {}
138
+ openapi_types.each_pair do |key, type|
139
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
140
+ transformed_hash["#{key}"] = nil
141
+ elsif type =~ /\AArray<(.*)>/i
142
+ # check to ensure the input is an array given that the attribute
143
+ # is documented as an array but the input is not
144
+ if attributes[attribute_map[key]].is_a?(Array)
145
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
146
+ end
147
+ elsif !attributes[attribute_map[key]].nil?
148
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
149
+ end
150
+ end
151
+ new(transformed_hash)
152
+ end
153
+
154
+ # Deserializes the data based on type
155
+ # @param string type Data type
156
+ # @param string value Value to be deserialized
157
+ # @return [Object] Deserialized data
158
+ def self._deserialize(type, value)
159
+ case type.to_sym
160
+ when :Time
161
+ Time.parse(value)
162
+ when :Date
163
+ Date.parse(value)
164
+ when :String
165
+ value.to_s
166
+ when :Integer
167
+ value.to_i
168
+ when :Float
169
+ value.to_f
170
+ when :Boolean
171
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
172
+ true
173
+ else
174
+ false
175
+ end
176
+ when :Object
177
+ # generic object (usually a Hash), return directly
178
+ value
179
+ when /\AArray<(?<inner_type>.+)>\z/
180
+ inner_type = Regexp.last_match[:inner_type]
181
+ value.map { |v| _deserialize(inner_type, v) }
182
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
183
+ k_type = Regexp.last_match[:k_type]
184
+ v_type = Regexp.last_match[:v_type]
185
+ {}.tap do |hash|
186
+ value.each do |k, v|
187
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
188
+ end
189
+ end
190
+ else # model
191
+ # models (e.g. Pet) or oneOf
192
+ klass = Coinbase::Client.const_get(type)
193
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
194
+ end
195
+ end
196
+
197
+ # Returns the string representation of the object
198
+ # @return [String] String presentation of the object
199
+ def to_s
200
+ to_hash.to_s
201
+ end
202
+
203
+ # to_body is an alias to to_hash (backward compatibility)
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_body
206
+ to_hash
207
+ end
208
+
209
+ # Returns the object in the form of hash
210
+ # @return [Hash] Returns the object in the form of hash
211
+ def to_hash
212
+ hash = {}
213
+ self.class.attribute_map.each_pair do |attr, param|
214
+ value = self.send(attr)
215
+ if value.nil?
216
+ is_nullable = self.class.openapi_nullable.include?(attr)
217
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
218
+ end
219
+
220
+ hash[param] = _to_hash(value)
221
+ end
222
+ hash
223
+ end
224
+
225
+ # Outputs non-array value in the form of hash
226
+ # For object, use to_hash. Otherwise, just return the value
227
+ # @param [Object] value Any valid value
228
+ # @return [Hash] Returns the value in the form of hash
229
+ def _to_hash(value)
230
+ if value.is_a?(Array)
231
+ value.compact.map { |v| _to_hash(v) }
232
+ elsif value.is_a?(Hash)
233
+ {}.tap do |hash|
234
+ value.each { |k, v| hash[k] = _to_hash(v) }
235
+ end
236
+ elsif value.respond_to? :to_hash
237
+ value.to_hash
238
+ else
239
+ value
240
+ end
241
+ end
242
+
243
+ end
244
+
245
+ end