coinbase-sdk 0.0.5 → 0.0.7

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