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,259 @@
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 CreateSmartContractRequest
18
+ attr_accessor :type
19
+
20
+ attr_accessor :options
21
+
22
+ class EnumAttributeValidator
23
+ attr_reader :datatype
24
+ attr_reader :allowable_values
25
+
26
+ def initialize(datatype, allowable_values)
27
+ @allowable_values = allowable_values.map do |value|
28
+ case datatype.to_s
29
+ when /Integer/i
30
+ value.to_i
31
+ when /Float/i
32
+ value.to_f
33
+ else
34
+ value
35
+ end
36
+ end
37
+ end
38
+
39
+ def valid?(value)
40
+ !value || allowable_values.include?(value)
41
+ end
42
+ end
43
+
44
+ # Attribute mapping from ruby-style variable name to JSON key.
45
+ def self.attribute_map
46
+ {
47
+ :'type' => :'type',
48
+ :'options' => :'options'
49
+ }
50
+ end
51
+
52
+ # Returns all the JSON keys this model knows about
53
+ def self.acceptable_attributes
54
+ attribute_map.values
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'type' => :'SmartContractType',
61
+ :'options' => :'SmartContractOptions'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ ])
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ if (!attributes.is_a?(Hash))
75
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::CreateSmartContractRequest` initialize method"
76
+ end
77
+
78
+ # check to see if the attribute exists and convert string to symbol for hash key
79
+ attributes = attributes.each_with_object({}) { |(k, v), h|
80
+ if (!self.class.attribute_map.key?(k.to_sym))
81
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::CreateSmartContractRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
+ end
83
+ h[k.to_sym] = v
84
+ }
85
+
86
+ if attributes.key?(:'type')
87
+ self.type = attributes[:'type']
88
+ else
89
+ self.type = nil
90
+ end
91
+
92
+ if attributes.key?(:'options')
93
+ self.options = attributes[:'options']
94
+ else
95
+ self.options = nil
96
+ end
97
+ end
98
+
99
+ # Show invalid properties with the reasons. Usually used together with valid?
100
+ # @return Array for valid properties with the reasons
101
+ def list_invalid_properties
102
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
103
+ invalid_properties = Array.new
104
+ if @type.nil?
105
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
106
+ end
107
+
108
+ if @options.nil?
109
+ invalid_properties.push('invalid value for "options", options cannot be nil.')
110
+ end
111
+
112
+ invalid_properties
113
+ end
114
+
115
+ # Check to see if the all the properties in the model are valid
116
+ # @return true if the model is valid
117
+ def valid?
118
+ warn '[DEPRECATED] the `valid?` method is obsolete'
119
+ return false if @type.nil?
120
+ return false if @options.nil?
121
+ true
122
+ end
123
+
124
+ # Checks equality by comparing each attribute.
125
+ # @param [Object] Object to be compared
126
+ def ==(o)
127
+ return true if self.equal?(o)
128
+ self.class == o.class &&
129
+ type == o.type &&
130
+ options == o.options
131
+ end
132
+
133
+ # @see the `==` method
134
+ # @param [Object] Object to be compared
135
+ def eql?(o)
136
+ self == o
137
+ end
138
+
139
+ # Calculates hash code according to all attributes.
140
+ # @return [Integer] Hash code
141
+ def hash
142
+ [type, options].hash
143
+ end
144
+
145
+ # Builds the object from hash
146
+ # @param [Hash] attributes Model attributes in the form of hash
147
+ # @return [Object] Returns the model itself
148
+ def self.build_from_hash(attributes)
149
+ return nil unless attributes.is_a?(Hash)
150
+ attributes = attributes.transform_keys(&:to_sym)
151
+ transformed_hash = {}
152
+ openapi_types.each_pair do |key, type|
153
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
154
+ transformed_hash["#{key}"] = nil
155
+ elsif type =~ /\AArray<(.*)>/i
156
+ # check to ensure the input is an array given that the attribute
157
+ # is documented as an array but the input is not
158
+ if attributes[attribute_map[key]].is_a?(Array)
159
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
160
+ end
161
+ elsif !attributes[attribute_map[key]].nil?
162
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
163
+ end
164
+ end
165
+ new(transformed_hash)
166
+ end
167
+
168
+ # Deserializes the data based on type
169
+ # @param string type Data type
170
+ # @param string value Value to be deserialized
171
+ # @return [Object] Deserialized data
172
+ def self._deserialize(type, value)
173
+ case type.to_sym
174
+ when :Time
175
+ Time.parse(value)
176
+ when :Date
177
+ Date.parse(value)
178
+ when :String
179
+ value.to_s
180
+ when :Integer
181
+ value.to_i
182
+ when :Float
183
+ value.to_f
184
+ when :Boolean
185
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
186
+ true
187
+ else
188
+ false
189
+ end
190
+ when :Object
191
+ # generic object (usually a Hash), return directly
192
+ value
193
+ when /\AArray<(?<inner_type>.+)>\z/
194
+ inner_type = Regexp.last_match[:inner_type]
195
+ value.map { |v| _deserialize(inner_type, v) }
196
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
197
+ k_type = Regexp.last_match[:k_type]
198
+ v_type = Regexp.last_match[:v_type]
199
+ {}.tap do |hash|
200
+ value.each do |k, v|
201
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
202
+ end
203
+ end
204
+ else # model
205
+ # models (e.g. Pet) or oneOf
206
+ klass = Coinbase::Client.const_get(type)
207
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
208
+ end
209
+ end
210
+
211
+ # Returns the string representation of the object
212
+ # @return [String] String presentation of the object
213
+ def to_s
214
+ to_hash.to_s
215
+ end
216
+
217
+ # to_body is an alias to to_hash (backward compatibility)
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_body
220
+ to_hash
221
+ end
222
+
223
+ # Returns the object in the form of hash
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_hash
226
+ hash = {}
227
+ self.class.attribute_map.each_pair do |attr, param|
228
+ value = self.send(attr)
229
+ if value.nil?
230
+ is_nullable = self.class.openapi_nullable.include?(attr)
231
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
232
+ end
233
+
234
+ hash[param] = _to_hash(value)
235
+ end
236
+ hash
237
+ end
238
+
239
+ # Outputs non-array value in the form of hash
240
+ # For object, use to_hash. Otherwise, just return the value
241
+ # @param [Object] value Any valid value
242
+ # @return [Hash] Returns the value in the form of hash
243
+ def _to_hash(value)
244
+ if value.is_a?(Array)
245
+ value.compact.map { |v| _to_hash(v) }
246
+ elsif value.is_a?(Hash)
247
+ {}.tap do |hash|
248
+ value.each { |k, v| hash[k] = _to_hash(v) }
249
+ end
250
+ elsif value.respond_to? :to_hash
251
+ value.to_hash
252
+ else
253
+ value
254
+ end
255
+ end
256
+
257
+ end
258
+
259
+ end
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -24,7 +24,7 @@ module Coinbase::Client
24
24
  # The ID of the asset to transfer
25
25
  attr_accessor :asset_id
26
26
 
27
- # The destination address
27
+ # The destination address, which can be a 0x address, Basename, or ENS name
28
28
  attr_accessor :destination
29
29
 
30
30
  # Whether the transfer uses sponsored gas
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -20,6 +20,8 @@ module Coinbase::Client
20
20
 
21
21
  attr_accessor :event_type
22
22
 
23
+ attr_accessor :event_type_filter
24
+
23
25
  # Webhook will monitor all events that matches any one of the event filters.
24
26
  attr_accessor :event_filters
25
27
 
@@ -56,6 +58,7 @@ module Coinbase::Client
56
58
  {
57
59
  :'network_id' => :'network_id',
58
60
  :'event_type' => :'event_type',
61
+ :'event_type_filter' => :'event_type_filter',
59
62
  :'event_filters' => :'event_filters',
60
63
  :'notification_uri' => :'notification_uri',
61
64
  :'signature_header' => :'signature_header'
@@ -72,6 +75,7 @@ module Coinbase::Client
72
75
  {
73
76
  :'network_id' => :'String',
74
77
  :'event_type' => :'WebhookEventType',
78
+ :'event_type_filter' => :'WebhookEventTypeFilter',
75
79
  :'event_filters' => :'Array<WebhookEventFilter>',
76
80
  :'notification_uri' => :'String',
77
81
  :'signature_header' => :'String'
@@ -111,12 +115,14 @@ module Coinbase::Client
111
115
  self.event_type = nil
112
116
  end
113
117
 
118
+ if attributes.key?(:'event_type_filter')
119
+ self.event_type_filter = attributes[:'event_type_filter']
120
+ end
121
+
114
122
  if attributes.key?(:'event_filters')
115
123
  if (value = attributes[:'event_filters']).is_a?(Array)
116
124
  self.event_filters = value
117
125
  end
118
- else
119
- self.event_filters = nil
120
126
  end
121
127
 
122
128
  if attributes.key?(:'notification_uri')
@@ -143,10 +149,6 @@ module Coinbase::Client
143
149
  invalid_properties.push('invalid value for "event_type", event_type cannot be nil.')
144
150
  end
145
151
 
146
- if @event_filters.nil?
147
- invalid_properties.push('invalid value for "event_filters", event_filters cannot be nil.')
148
- end
149
-
150
152
  if @notification_uri.nil?
151
153
  invalid_properties.push('invalid value for "notification_uri", notification_uri cannot be nil.')
152
154
  end
@@ -160,7 +162,6 @@ module Coinbase::Client
160
162
  warn '[DEPRECATED] the `valid?` method is obsolete'
161
163
  return false if @network_id.nil?
162
164
  return false if @event_type.nil?
163
- return false if @event_filters.nil?
164
165
  return false if @notification_uri.nil?
165
166
  true
166
167
  end
@@ -172,6 +173,7 @@ module Coinbase::Client
172
173
  self.class == o.class &&
173
174
  network_id == o.network_id &&
174
175
  event_type == o.event_type &&
176
+ event_type_filter == o.event_type_filter &&
175
177
  event_filters == o.event_filters &&
176
178
  notification_uri == o.notification_uri &&
177
179
  signature_header == o.signature_header
@@ -186,7 +188,7 @@ module Coinbase::Client
186
188
  # Calculates hash code according to all attributes.
187
189
  # @return [Integer] Hash code
188
190
  def hash
189
- [network_id, event_type, event_filters, notification_uri, signature_header].hash
191
+ [network_id, event_type, event_type_filter, event_filters, notification_uri, signature_header].hash
190
192
  end
191
193
 
192
194
  # Builds the object from hash
@@ -0,0 +1,222 @@
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 DeploySmartContractRequest
18
+ # The hex-encoded signed payload of the contract deployment transaction.
19
+ attr_accessor :signed_payload
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'signed_payload' => :'signed_payload'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'signed_payload' => :'String'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::DeploySmartContractRequest` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::DeploySmartContractRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'signed_payload')
62
+ self.signed_payload = attributes[:'signed_payload']
63
+ else
64
+ self.signed_payload = nil
65
+ end
66
+ end
67
+
68
+ # Show invalid properties with the reasons. Usually used together with valid?
69
+ # @return Array for valid properties with the reasons
70
+ def list_invalid_properties
71
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
72
+ invalid_properties = Array.new
73
+ if @signed_payload.nil?
74
+ invalid_properties.push('invalid value for "signed_payload", signed_payload cannot be nil.')
75
+ end
76
+
77
+ invalid_properties
78
+ end
79
+
80
+ # Check to see if the all the properties in the model are valid
81
+ # @return true if the model is valid
82
+ def valid?
83
+ warn '[DEPRECATED] the `valid?` method is obsolete'
84
+ return false if @signed_payload.nil?
85
+ true
86
+ end
87
+
88
+ # Checks equality by comparing each attribute.
89
+ # @param [Object] Object to be compared
90
+ def ==(o)
91
+ return true if self.equal?(o)
92
+ self.class == o.class &&
93
+ signed_payload == o.signed_payload
94
+ end
95
+
96
+ # @see the `==` method
97
+ # @param [Object] Object to be compared
98
+ def eql?(o)
99
+ self == o
100
+ end
101
+
102
+ # Calculates hash code according to all attributes.
103
+ # @return [Integer] Hash code
104
+ def hash
105
+ [signed_payload].hash
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def self.build_from_hash(attributes)
112
+ return nil unless attributes.is_a?(Hash)
113
+ attributes = attributes.transform_keys(&:to_sym)
114
+ transformed_hash = {}
115
+ openapi_types.each_pair do |key, type|
116
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
117
+ transformed_hash["#{key}"] = nil
118
+ elsif type =~ /\AArray<(.*)>/i
119
+ # check to ensure the input is an array given that the attribute
120
+ # is documented as an array but the input is not
121
+ if attributes[attribute_map[key]].is_a?(Array)
122
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
123
+ end
124
+ elsif !attributes[attribute_map[key]].nil?
125
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
126
+ end
127
+ end
128
+ new(transformed_hash)
129
+ end
130
+
131
+ # Deserializes the data based on type
132
+ # @param string type Data type
133
+ # @param string value Value to be deserialized
134
+ # @return [Object] Deserialized data
135
+ def self._deserialize(type, value)
136
+ case type.to_sym
137
+ when :Time
138
+ Time.parse(value)
139
+ when :Date
140
+ Date.parse(value)
141
+ when :String
142
+ value.to_s
143
+ when :Integer
144
+ value.to_i
145
+ when :Float
146
+ value.to_f
147
+ when :Boolean
148
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
149
+ true
150
+ else
151
+ false
152
+ end
153
+ when :Object
154
+ # generic object (usually a Hash), return directly
155
+ value
156
+ when /\AArray<(?<inner_type>.+)>\z/
157
+ inner_type = Regexp.last_match[:inner_type]
158
+ value.map { |v| _deserialize(inner_type, v) }
159
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
160
+ k_type = Regexp.last_match[:k_type]
161
+ v_type = Regexp.last_match[:v_type]
162
+ {}.tap do |hash|
163
+ value.each do |k, v|
164
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
165
+ end
166
+ end
167
+ else # model
168
+ # models (e.g. Pet) or oneOf
169
+ klass = Coinbase::Client.const_get(type)
170
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
171
+ end
172
+ end
173
+
174
+ # Returns the string representation of the object
175
+ # @return [String] String presentation of the object
176
+ def to_s
177
+ to_hash.to_s
178
+ end
179
+
180
+ # to_body is an alias to to_hash (backward compatibility)
181
+ # @return [Hash] Returns the object in the form of hash
182
+ def to_body
183
+ to_hash
184
+ end
185
+
186
+ # Returns the object in the form of hash
187
+ # @return [Hash] Returns the object in the form of hash
188
+ def to_hash
189
+ hash = {}
190
+ self.class.attribute_map.each_pair do |attr, param|
191
+ value = self.send(attr)
192
+ if value.nil?
193
+ is_nullable = self.class.openapi_nullable.include?(attr)
194
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
195
+ end
196
+
197
+ hash[param] = _to_hash(value)
198
+ end
199
+ hash
200
+ end
201
+
202
+ # Outputs non-array value in the form of hash
203
+ # For object, use to_hash. Otherwise, just return the value
204
+ # @param [Object] value Any valid value
205
+ # @return [Hash] Returns the value in the form of hash
206
+ def _to_hash(value)
207
+ if value.is_a?(Array)
208
+ value.compact.map { |v| _to_hash(v) }
209
+ elsif value.is_a?(Hash)
210
+ {}.tap do |hash|
211
+ value.each { |k, v| hash[k] = _to_hash(v) }
212
+ end
213
+ elsif value.respond_to? :to_hash
214
+ value.to_hash
215
+ else
216
+ value
217
+ end
218
+ end
219
+
220
+ end
221
+
222
+ end