coinbase-sdk 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address.rb +63 -44
  3. data/lib/coinbase/authenticator.rb +1 -1
  4. data/lib/coinbase/client/api/server_signers_api.rb +419 -0
  5. data/lib/coinbase/client/api/trades_api.rb +342 -0
  6. data/lib/coinbase/client/models/broadcast_trade_request.rb +222 -0
  7. data/lib/coinbase/client/models/create_address_request.rb +0 -14
  8. data/lib/coinbase/client/models/create_server_signer_request.rb +239 -0
  9. data/lib/coinbase/client/models/create_trade_request.rb +256 -0
  10. data/lib/coinbase/client/models/create_wallet_request.rb +1 -1
  11. data/lib/coinbase/client/models/create_wallet_request_wallet.rb +233 -0
  12. data/lib/coinbase/client/models/seed_creation_event.rb +240 -0
  13. data/lib/coinbase/client/models/seed_creation_event_result.rb +274 -0
  14. data/lib/coinbase/client/models/server_signer.rb +235 -0
  15. data/lib/coinbase/client/models/server_signer_event.rb +239 -0
  16. data/lib/coinbase/client/models/server_signer_event_event.rb +105 -0
  17. data/lib/coinbase/client/models/server_signer_event_list.rb +275 -0
  18. data/lib/coinbase/client/models/signature_creation_event.rb +363 -0
  19. data/lib/coinbase/client/models/signature_creation_event_result.rb +329 -0
  20. data/lib/coinbase/client/models/trade.rb +356 -0
  21. data/lib/coinbase/client/models/trade_list.rb +275 -0
  22. data/lib/coinbase/client/models/transaction.rb +294 -0
  23. data/lib/coinbase/client/models/transaction_type.rb +39 -0
  24. data/lib/coinbase/client/models/wallet.rb +55 -4
  25. data/lib/coinbase/client.rb +18 -0
  26. data/lib/coinbase/transfer.rb +21 -21
  27. data/lib/coinbase/user.rb +14 -89
  28. data/lib/coinbase/wallet.rb +176 -26
  29. data/lib/coinbase.rb +16 -4
  30. metadata +34 -2
@@ -0,0 +1,342 @@
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
+ Contact: yuga.cohler@coinbase.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.5.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module Coinbase::Client
16
+ class TradesApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Broadcast a trade
23
+ # Broadcast a trade
24
+ # @param wallet_id [String] The ID of the wallet the address belongs to
25
+ # @param address_id [String] The ID of the address the trade belongs to
26
+ # @param trade_id [String] The ID of the trade to broadcast
27
+ # @param broadcast_trade_request [BroadcastTradeRequest]
28
+ # @param [Hash] opts the optional parameters
29
+ # @return [Trade]
30
+ def broadcast_trade(wallet_id, address_id, trade_id, broadcast_trade_request, opts = {})
31
+ data, _status_code, _headers = broadcast_trade_with_http_info(wallet_id, address_id, trade_id, broadcast_trade_request, opts)
32
+ data
33
+ end
34
+
35
+ # Broadcast a trade
36
+ # Broadcast a trade
37
+ # @param wallet_id [String] The ID of the wallet the address belongs to
38
+ # @param address_id [String] The ID of the address the trade belongs to
39
+ # @param trade_id [String] The ID of the trade to broadcast
40
+ # @param broadcast_trade_request [BroadcastTradeRequest]
41
+ # @param [Hash] opts the optional parameters
42
+ # @return [Array<(Trade, Integer, Hash)>] Trade data, response status code and response headers
43
+ def broadcast_trade_with_http_info(wallet_id, address_id, trade_id, broadcast_trade_request, opts = {})
44
+ if @api_client.config.debugging
45
+ @api_client.config.logger.debug 'Calling API: TradesApi.broadcast_trade ...'
46
+ end
47
+ # verify the required parameter 'wallet_id' is set
48
+ if @api_client.config.client_side_validation && wallet_id.nil?
49
+ fail ArgumentError, "Missing the required parameter 'wallet_id' when calling TradesApi.broadcast_trade"
50
+ end
51
+ # verify the required parameter 'address_id' is set
52
+ if @api_client.config.client_side_validation && address_id.nil?
53
+ fail ArgumentError, "Missing the required parameter 'address_id' when calling TradesApi.broadcast_trade"
54
+ end
55
+ # verify the required parameter 'trade_id' is set
56
+ if @api_client.config.client_side_validation && trade_id.nil?
57
+ fail ArgumentError, "Missing the required parameter 'trade_id' when calling TradesApi.broadcast_trade"
58
+ end
59
+ # verify the required parameter 'broadcast_trade_request' is set
60
+ if @api_client.config.client_side_validation && broadcast_trade_request.nil?
61
+ fail ArgumentError, "Missing the required parameter 'broadcast_trade_request' when calling TradesApi.broadcast_trade"
62
+ end
63
+ # resource path
64
+ local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/trades/{trade_id}/broadcast'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)).sub('{' + 'trade_id' + '}', CGI.escape(trade_id.to_s))
65
+
66
+ # query parameters
67
+ query_params = opts[:query_params] || {}
68
+
69
+ # header parameters
70
+ header_params = opts[:header_params] || {}
71
+ # HTTP header 'Accept' (if needed)
72
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
73
+ # HTTP header 'Content-Type'
74
+ content_type = @api_client.select_header_content_type(['application/json'])
75
+ if !content_type.nil?
76
+ header_params['Content-Type'] = content_type
77
+ end
78
+
79
+ # form parameters
80
+ form_params = opts[:form_params] || {}
81
+
82
+ # http body (model)
83
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(broadcast_trade_request)
84
+
85
+ # return_type
86
+ return_type = opts[:debug_return_type] || 'Trade'
87
+
88
+ # auth_names
89
+ auth_names = opts[:debug_auth_names] || []
90
+
91
+ new_options = opts.merge(
92
+ :operation => :"TradesApi.broadcast_trade",
93
+ :header_params => header_params,
94
+ :query_params => query_params,
95
+ :form_params => form_params,
96
+ :body => post_body,
97
+ :auth_names => auth_names,
98
+ :return_type => return_type
99
+ )
100
+
101
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
102
+ if @api_client.config.debugging
103
+ @api_client.config.logger.debug "API called: TradesApi#broadcast_trade\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
104
+ end
105
+ return data, status_code, headers
106
+ end
107
+
108
+ # Create a new trade for an address
109
+ # Create a new trade
110
+ # @param wallet_id [String] The ID of the wallet the source address belongs to
111
+ # @param address_id [String] The ID of the address to conduct the trade from
112
+ # @param create_trade_request [CreateTradeRequest]
113
+ # @param [Hash] opts the optional parameters
114
+ # @return [Trade]
115
+ def create_trade(wallet_id, address_id, create_trade_request, opts = {})
116
+ data, _status_code, _headers = create_trade_with_http_info(wallet_id, address_id, create_trade_request, opts)
117
+ data
118
+ end
119
+
120
+ # Create a new trade for an address
121
+ # Create a new trade
122
+ # @param wallet_id [String] The ID of the wallet the source address belongs to
123
+ # @param address_id [String] The ID of the address to conduct the trade from
124
+ # @param create_trade_request [CreateTradeRequest]
125
+ # @param [Hash] opts the optional parameters
126
+ # @return [Array<(Trade, Integer, Hash)>] Trade data, response status code and response headers
127
+ def create_trade_with_http_info(wallet_id, address_id, create_trade_request, opts = {})
128
+ if @api_client.config.debugging
129
+ @api_client.config.logger.debug 'Calling API: TradesApi.create_trade ...'
130
+ end
131
+ # verify the required parameter 'wallet_id' is set
132
+ if @api_client.config.client_side_validation && wallet_id.nil?
133
+ fail ArgumentError, "Missing the required parameter 'wallet_id' when calling TradesApi.create_trade"
134
+ end
135
+ # verify the required parameter 'address_id' is set
136
+ if @api_client.config.client_side_validation && address_id.nil?
137
+ fail ArgumentError, "Missing the required parameter 'address_id' when calling TradesApi.create_trade"
138
+ end
139
+ # verify the required parameter 'create_trade_request' is set
140
+ if @api_client.config.client_side_validation && create_trade_request.nil?
141
+ fail ArgumentError, "Missing the required parameter 'create_trade_request' when calling TradesApi.create_trade"
142
+ end
143
+ # resource path
144
+ local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/trades'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s))
145
+
146
+ # query parameters
147
+ query_params = opts[:query_params] || {}
148
+
149
+ # header parameters
150
+ header_params = opts[:header_params] || {}
151
+ # HTTP header 'Accept' (if needed)
152
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
153
+ # HTTP header 'Content-Type'
154
+ content_type = @api_client.select_header_content_type(['application/json'])
155
+ if !content_type.nil?
156
+ header_params['Content-Type'] = content_type
157
+ end
158
+
159
+ # form parameters
160
+ form_params = opts[:form_params] || {}
161
+
162
+ # http body (model)
163
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(create_trade_request)
164
+
165
+ # return_type
166
+ return_type = opts[:debug_return_type] || 'Trade'
167
+
168
+ # auth_names
169
+ auth_names = opts[:debug_auth_names] || []
170
+
171
+ new_options = opts.merge(
172
+ :operation => :"TradesApi.create_trade",
173
+ :header_params => header_params,
174
+ :query_params => query_params,
175
+ :form_params => form_params,
176
+ :body => post_body,
177
+ :auth_names => auth_names,
178
+ :return_type => return_type
179
+ )
180
+
181
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
182
+ if @api_client.config.debugging
183
+ @api_client.config.logger.debug "API called: TradesApi#create_trade\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
184
+ end
185
+ return data, status_code, headers
186
+ end
187
+
188
+ # Get a trade by ID
189
+ # Get a trade by ID
190
+ # @param wallet_id [String] The ID of the wallet the address belongs to
191
+ # @param address_id [String] The ID of the address the trade belongs to
192
+ # @param trade_id [String] The ID of the trade to fetch
193
+ # @param [Hash] opts the optional parameters
194
+ # @return [Trade]
195
+ def get_trade(wallet_id, address_id, trade_id, opts = {})
196
+ data, _status_code, _headers = get_trade_with_http_info(wallet_id, address_id, trade_id, opts)
197
+ data
198
+ end
199
+
200
+ # Get a trade by ID
201
+ # Get a trade by ID
202
+ # @param wallet_id [String] The ID of the wallet the address belongs to
203
+ # @param address_id [String] The ID of the address the trade belongs to
204
+ # @param trade_id [String] The ID of the trade to fetch
205
+ # @param [Hash] opts the optional parameters
206
+ # @return [Array<(Trade, Integer, Hash)>] Trade data, response status code and response headers
207
+ def get_trade_with_http_info(wallet_id, address_id, trade_id, opts = {})
208
+ if @api_client.config.debugging
209
+ @api_client.config.logger.debug 'Calling API: TradesApi.get_trade ...'
210
+ end
211
+ # verify the required parameter 'wallet_id' is set
212
+ if @api_client.config.client_side_validation && wallet_id.nil?
213
+ fail ArgumentError, "Missing the required parameter 'wallet_id' when calling TradesApi.get_trade"
214
+ end
215
+ # verify the required parameter 'address_id' is set
216
+ if @api_client.config.client_side_validation && address_id.nil?
217
+ fail ArgumentError, "Missing the required parameter 'address_id' when calling TradesApi.get_trade"
218
+ end
219
+ # verify the required parameter 'trade_id' is set
220
+ if @api_client.config.client_side_validation && trade_id.nil?
221
+ fail ArgumentError, "Missing the required parameter 'trade_id' when calling TradesApi.get_trade"
222
+ end
223
+ # resource path
224
+ local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/trades/{trade_id}'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)).sub('{' + 'trade_id' + '}', CGI.escape(trade_id.to_s))
225
+
226
+ # query parameters
227
+ query_params = opts[:query_params] || {}
228
+
229
+ # header parameters
230
+ header_params = opts[:header_params] || {}
231
+ # HTTP header 'Accept' (if needed)
232
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
233
+
234
+ # form parameters
235
+ form_params = opts[:form_params] || {}
236
+
237
+ # http body (model)
238
+ post_body = opts[:debug_body]
239
+
240
+ # return_type
241
+ return_type = opts[:debug_return_type] || 'Trade'
242
+
243
+ # auth_names
244
+ auth_names = opts[:debug_auth_names] || []
245
+
246
+ new_options = opts.merge(
247
+ :operation => :"TradesApi.get_trade",
248
+ :header_params => header_params,
249
+ :query_params => query_params,
250
+ :form_params => form_params,
251
+ :body => post_body,
252
+ :auth_names => auth_names,
253
+ :return_type => return_type
254
+ )
255
+
256
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
257
+ if @api_client.config.debugging
258
+ @api_client.config.logger.debug "API called: TradesApi#get_trade\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
259
+ end
260
+ return data, status_code, headers
261
+ end
262
+
263
+ # List trades for an address.
264
+ # List trades for an address.
265
+ # @param wallet_id [String] The ID of the wallet the address belongs to
266
+ # @param address_id [String] The ID of the address to list trades for
267
+ # @param [Hash] opts the optional parameters
268
+ # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
269
+ # @option opts [String] :page A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
270
+ # @return [TradeList]
271
+ def list_trades(wallet_id, address_id, opts = {})
272
+ data, _status_code, _headers = list_trades_with_http_info(wallet_id, address_id, opts)
273
+ data
274
+ end
275
+
276
+ # List trades for an address.
277
+ # List trades for an address.
278
+ # @param wallet_id [String] The ID of the wallet the address belongs to
279
+ # @param address_id [String] The ID of the address to list trades for
280
+ # @param [Hash] opts the optional parameters
281
+ # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
282
+ # @option opts [String] :page A cursor for pagination across multiple pages of results. Don&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
283
+ # @return [Array<(TradeList, Integer, Hash)>] TradeList data, response status code and response headers
284
+ def list_trades_with_http_info(wallet_id, address_id, opts = {})
285
+ if @api_client.config.debugging
286
+ @api_client.config.logger.debug 'Calling API: TradesApi.list_trades ...'
287
+ end
288
+ # verify the required parameter 'wallet_id' is set
289
+ if @api_client.config.client_side_validation && wallet_id.nil?
290
+ fail ArgumentError, "Missing the required parameter 'wallet_id' when calling TradesApi.list_trades"
291
+ end
292
+ # verify the required parameter 'address_id' is set
293
+ if @api_client.config.client_side_validation && address_id.nil?
294
+ fail ArgumentError, "Missing the required parameter 'address_id' when calling TradesApi.list_trades"
295
+ end
296
+ if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'].to_s.length > 5000
297
+ fail ArgumentError, 'invalid value for "opts[:"page"]" when calling TradesApi.list_trades, the character length must be smaller than or equal to 5000.'
298
+ end
299
+
300
+ # resource path
301
+ local_var_path = '/v1/wallets/{wallet_id}/addresses/{address_id}/trades'.sub('{' + 'wallet_id' + '}', CGI.escape(wallet_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s))
302
+
303
+ # query parameters
304
+ query_params = opts[:query_params] || {}
305
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
306
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
307
+
308
+ # header parameters
309
+ header_params = opts[:header_params] || {}
310
+ # HTTP header 'Accept' (if needed)
311
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
312
+
313
+ # form parameters
314
+ form_params = opts[:form_params] || {}
315
+
316
+ # http body (model)
317
+ post_body = opts[:debug_body]
318
+
319
+ # return_type
320
+ return_type = opts[:debug_return_type] || 'TradeList'
321
+
322
+ # auth_names
323
+ auth_names = opts[:debug_auth_names] || []
324
+
325
+ new_options = opts.merge(
326
+ :operation => :"TradesApi.list_trades",
327
+ :header_params => header_params,
328
+ :query_params => query_params,
329
+ :form_params => form_params,
330
+ :body => post_body,
331
+ :auth_names => auth_names,
332
+ :return_type => return_type
333
+ )
334
+
335
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
336
+ if @api_client.config.debugging
337
+ @api_client.config.logger.debug "API called: TradesApi#list_trades\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
338
+ end
339
+ return data, status_code, headers
340
+ end
341
+ end
342
+ end
@@ -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
+ Contact: yuga.cohler@coinbase.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.5.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ class BroadcastTradeRequest
18
+ # The hex-encoded signed payload of the trade
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::BroadcastTradeRequest` 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::BroadcastTradeRequest`. 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
@@ -65,14 +65,10 @@ module Coinbase::Client
65
65
 
66
66
  if attributes.key?(:'public_key')
67
67
  self.public_key = attributes[:'public_key']
68
- else
69
- self.public_key = nil
70
68
  end
71
69
 
72
70
  if attributes.key?(:'attestation')
73
71
  self.attestation = attributes[:'attestation']
74
- else
75
- self.attestation = nil
76
72
  end
77
73
  end
78
74
 
@@ -81,14 +77,6 @@ module Coinbase::Client
81
77
  def list_invalid_properties
82
78
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
83
79
  invalid_properties = Array.new
84
- if @public_key.nil?
85
- invalid_properties.push('invalid value for "public_key", public_key cannot be nil.')
86
- end
87
-
88
- if @attestation.nil?
89
- invalid_properties.push('invalid value for "attestation", attestation cannot be nil.')
90
- end
91
-
92
80
  invalid_properties
93
81
  end
94
82
 
@@ -96,8 +84,6 @@ module Coinbase::Client
96
84
  # @return true if the model is valid
97
85
  def valid?
98
86
  warn '[DEPRECATED] the `valid?` method is obsolete'
99
- return false if @public_key.nil?
100
- return false if @attestation.nil?
101
87
  true
102
88
  end
103
89