coinbase-sdk 0.0.14 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/lib/coinbase/address/wallet_address.rb +7 -4
  3. data/lib/coinbase/address.rb +36 -0
  4. data/lib/coinbase/client/api/addresses_api.rb +1 -1
  5. data/lib/coinbase/client/api/assets_api.rb +1 -1
  6. data/lib/coinbase/client/api/contract_events_api.rb +1 -1
  7. data/lib/coinbase/client/api/external_addresses_api.rb +86 -1
  8. data/lib/coinbase/client/api/networks_api.rb +85 -0
  9. data/lib/coinbase/client/api/server_signers_api.rb +1 -1
  10. data/lib/coinbase/client/api/stake_api.rb +121 -1
  11. data/lib/coinbase/client/api/trades_api.rb +1 -1
  12. data/lib/coinbase/client/api/transfers_api.rb +1 -1
  13. data/lib/coinbase/client/api/users_api.rb +1 -1
  14. data/lib/coinbase/client/api/validators_api.rb +1 -1
  15. data/lib/coinbase/client/api/wallets_api.rb +1 -1
  16. data/lib/coinbase/client/api/webhooks_api.rb +1 -1
  17. data/lib/coinbase/client/api_client.rb +1 -1
  18. data/lib/coinbase/client/api_error.rb +1 -1
  19. data/lib/coinbase/client/configuration.rb +1 -11
  20. data/lib/coinbase/client/models/address.rb +1 -1
  21. data/lib/coinbase/client/models/address_balance_list.rb +1 -1
  22. data/lib/coinbase/client/models/address_historical_balance_list.rb +258 -0
  23. data/lib/coinbase/client/models/address_list.rb +1 -1
  24. data/lib/coinbase/client/models/asset.rb +1 -1
  25. data/lib/coinbase/client/models/balance.rb +1 -1
  26. data/lib/coinbase/client/models/broadcast_staking_operation_request.rb +1 -1
  27. data/lib/coinbase/client/models/broadcast_trade_request.rb +1 -1
  28. data/lib/coinbase/client/models/broadcast_transfer_request.rb +1 -1
  29. data/lib/coinbase/client/models/build_staking_operation_request.rb +1 -1
  30. data/lib/coinbase/client/models/contract_event.rb +1 -1
  31. data/lib/coinbase/client/models/contract_event_list.rb +1 -1
  32. data/lib/coinbase/client/models/create_address_request.rb +1 -1
  33. data/lib/coinbase/client/models/create_server_signer_request.rb +1 -1
  34. data/lib/coinbase/client/models/create_staking_operation_request.rb +1 -1
  35. data/lib/coinbase/client/models/create_trade_request.rb +1 -1
  36. data/lib/coinbase/client/models/create_transfer_request.rb +15 -5
  37. data/lib/coinbase/client/models/create_wallet_request.rb +1 -1
  38. data/lib/coinbase/client/models/create_wallet_request_wallet.rb +1 -1
  39. data/lib/coinbase/client/models/create_webhook_request.rb +1 -1
  40. data/lib/coinbase/client/models/error.rb +1 -1
  41. data/lib/coinbase/client/models/ethereum_validator.rb +374 -0
  42. data/lib/coinbase/client/models/ethereum_validator_metadata.rb +1 -1
  43. data/lib/coinbase/client/models/faucet_transaction.rb +1 -1
  44. data/lib/coinbase/client/models/feature.rb +1 -1
  45. data/lib/coinbase/client/models/feature_set.rb +307 -0
  46. data/lib/coinbase/client/models/fetch_historical_staking_balances200_response.rb +258 -0
  47. data/lib/coinbase/client/models/fetch_staking_rewards200_response.rb +1 -1
  48. data/lib/coinbase/client/models/fetch_staking_rewards_request.rb +1 -1
  49. data/lib/coinbase/client/models/get_staking_context_request.rb +1 -1
  50. data/lib/coinbase/client/models/get_validator200_response.rb +221 -0
  51. data/lib/coinbase/client/models/get_validator200_response_validator.rb +214 -0
  52. data/lib/coinbase/client/models/historical_balance.rb +273 -0
  53. data/lib/coinbase/client/models/native_eth_staking_context.rb +1 -1
  54. data/lib/coinbase/client/models/network.rb +355 -0
  55. data/lib/coinbase/client/models/network_identifier.rb +44 -0
  56. data/lib/coinbase/client/models/partial_eth_staking_context.rb +1 -1
  57. data/lib/coinbase/client/models/seed_creation_event.rb +1 -1
  58. data/lib/coinbase/client/models/seed_creation_event_result.rb +1 -1
  59. data/lib/coinbase/client/models/server_signer.rb +1 -1
  60. data/lib/coinbase/client/models/server_signer_event.rb +1 -1
  61. data/lib/coinbase/client/models/server_signer_event_event.rb +1 -1
  62. data/lib/coinbase/client/models/server_signer_event_list.rb +1 -1
  63. data/lib/coinbase/client/models/server_signer_list.rb +1 -1
  64. data/lib/coinbase/client/models/signature_creation_event.rb +1 -1
  65. data/lib/coinbase/client/models/signature_creation_event_result.rb +1 -1
  66. data/lib/coinbase/client/models/signed_voluntary_exit_message_metadata.rb +1 -1
  67. data/lib/coinbase/client/models/sponsored_send.rb +338 -0
  68. data/lib/coinbase/client/models/staking_balance.rb +289 -0
  69. data/lib/coinbase/client/models/staking_context.rb +1 -1
  70. data/lib/coinbase/client/models/staking_context_context.rb +223 -75
  71. data/lib/coinbase/client/models/staking_operation.rb +3 -3
  72. data/lib/coinbase/client/models/staking_operation_metadata.rb +1 -1
  73. data/lib/coinbase/client/models/staking_reward.rb +23 -7
  74. data/lib/coinbase/client/models/staking_reward_format.rb +3 -2
  75. data/lib/coinbase/client/models/staking_reward_usd_value.rb +257 -0
  76. data/lib/coinbase/client/models/trade.rb +1 -1
  77. data/lib/coinbase/client/models/trade_list.rb +1 -1
  78. data/lib/coinbase/client/models/transaction.rb +3 -3
  79. data/lib/coinbase/client/models/transaction_type.rb +3 -2
  80. data/lib/coinbase/client/models/transfer.rb +102 -9
  81. data/lib/coinbase/client/models/transfer_list.rb +1 -1
  82. data/lib/coinbase/client/models/update_webhook_request.rb +1 -1
  83. data/lib/coinbase/client/models/user.rb +1 -1
  84. data/lib/coinbase/client/models/validator.rb +1 -1
  85. data/lib/coinbase/client/models/validator_details.rb +1 -1
  86. data/lib/coinbase/client/models/validator_list.rb +1 -1
  87. data/lib/coinbase/client/models/validator_list_data.rb +216 -0
  88. data/lib/coinbase/client/models/wallet.rb +14 -17
  89. data/lib/coinbase/client/models/wallet_list.rb +1 -1
  90. data/lib/coinbase/client/models/webhook.rb +1 -1
  91. data/lib/coinbase/client/models/webhook_event_filter.rb +1 -1
  92. data/lib/coinbase/client/models/webhook_event_type.rb +3 -2
  93. data/lib/coinbase/client/models/webhook_list.rb +1 -1
  94. data/lib/coinbase/client/version.rb +1 -1
  95. data/lib/coinbase/client.rb +11 -4
  96. data/lib/coinbase/errors.rb +7 -0
  97. data/lib/coinbase/historical_balance.rb +53 -0
  98. data/lib/coinbase/server_signer.rb +14 -3
  99. data/lib/coinbase/sponsored_send.rb +110 -0
  100. data/lib/coinbase/staking_balance.rb +86 -0
  101. data/lib/coinbase/staking_reward.rb +18 -0
  102. data/lib/coinbase/transaction.rb +7 -3
  103. data/lib/coinbase/transfer.rb +56 -28
  104. data/lib/coinbase/wallet/data.rb +31 -0
  105. data/lib/coinbase/wallet.rb +15 -46
  106. data/lib/coinbase.rb +15 -3
  107. metadata +48 -2
@@ -0,0 +1,258 @@
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.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ #
18
+ class FetchHistoricalStakingBalances200Response
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
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'data' => :'data',
31
+ :'has_more' => :'has_more',
32
+ :'next_page' => :'next_page'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'data' => :'Array<StakingBalance>',
45
+ :'has_more' => :'Boolean',
46
+ :'next_page' => :'String'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::FetchHistoricalStakingBalances200Response` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::FetchHistoricalStakingBalances200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'data')
72
+ if (value = attributes[:'data']).is_a?(Array)
73
+ self.data = value
74
+ end
75
+ else
76
+ self.data = nil
77
+ end
78
+
79
+ if attributes.key?(:'has_more')
80
+ self.has_more = attributes[:'has_more']
81
+ else
82
+ self.has_more = nil
83
+ end
84
+
85
+ if attributes.key?(:'next_page')
86
+ self.next_page = attributes[:'next_page']
87
+ else
88
+ self.next_page = nil
89
+ end
90
+ end
91
+
92
+ # Show invalid properties with the reasons. Usually used together with valid?
93
+ # @return Array for valid properties with the reasons
94
+ def list_invalid_properties
95
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
96
+ invalid_properties = Array.new
97
+ if @data.nil?
98
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
99
+ end
100
+
101
+ if @has_more.nil?
102
+ invalid_properties.push('invalid value for "has_more", has_more cannot be nil.')
103
+ end
104
+
105
+ if @next_page.nil?
106
+ invalid_properties.push('invalid value for "next_page", next_page cannot be nil.')
107
+ end
108
+
109
+ invalid_properties
110
+ end
111
+
112
+ # Check to see if the all the properties in the model are valid
113
+ # @return true if the model is valid
114
+ def valid?
115
+ warn '[DEPRECATED] the `valid?` method is obsolete'
116
+ return false if @data.nil?
117
+ return false if @has_more.nil?
118
+ return false if @next_page.nil?
119
+ true
120
+ end
121
+
122
+ # Checks equality by comparing each attribute.
123
+ # @param [Object] Object to be compared
124
+ def ==(o)
125
+ return true if self.equal?(o)
126
+ self.class == o.class &&
127
+ data == o.data &&
128
+ has_more == o.has_more &&
129
+ next_page == o.next_page
130
+ end
131
+
132
+ # @see the `==` method
133
+ # @param [Object] Object to be compared
134
+ def eql?(o)
135
+ self == o
136
+ end
137
+
138
+ # Calculates hash code according to all attributes.
139
+ # @return [Integer] Hash code
140
+ def hash
141
+ [data, has_more, next_page].hash
142
+ end
143
+
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def self.build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ attributes = attributes.transform_keys(&:to_sym)
150
+ transformed_hash = {}
151
+ openapi_types.each_pair do |key, type|
152
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
153
+ transformed_hash["#{key}"] = nil
154
+ elsif type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[attribute_map[key]].is_a?(Array)
158
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
159
+ end
160
+ elsif !attributes[attribute_map[key]].nil?
161
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
162
+ end
163
+ end
164
+ new(transformed_hash)
165
+ end
166
+
167
+ # Deserializes the data based on type
168
+ # @param string type Data type
169
+ # @param string value Value to be deserialized
170
+ # @return [Object] Deserialized data
171
+ def self._deserialize(type, value)
172
+ case type.to_sym
173
+ when :Time
174
+ Time.parse(value)
175
+ when :Date
176
+ Date.parse(value)
177
+ when :String
178
+ value.to_s
179
+ when :Integer
180
+ value.to_i
181
+ when :Float
182
+ value.to_f
183
+ when :Boolean
184
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
185
+ true
186
+ else
187
+ false
188
+ end
189
+ when :Object
190
+ # generic object (usually a Hash), return directly
191
+ value
192
+ when /\AArray<(?<inner_type>.+)>\z/
193
+ inner_type = Regexp.last_match[:inner_type]
194
+ value.map { |v| _deserialize(inner_type, v) }
195
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
196
+ k_type = Regexp.last_match[:k_type]
197
+ v_type = Regexp.last_match[:v_type]
198
+ {}.tap do |hash|
199
+ value.each do |k, v|
200
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
201
+ end
202
+ end
203
+ else # model
204
+ # models (e.g. Pet) or oneOf
205
+ klass = Coinbase::Client.const_get(type)
206
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
207
+ end
208
+ end
209
+
210
+ # Returns the string representation of the object
211
+ # @return [String] String presentation of the object
212
+ def to_s
213
+ to_hash.to_s
214
+ end
215
+
216
+ # to_body is an alias to to_hash (backward compatibility)
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_body
219
+ to_hash
220
+ end
221
+
222
+ # Returns the object in the form of hash
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_hash
225
+ hash = {}
226
+ self.class.attribute_map.each_pair do |attr, param|
227
+ value = self.send(attr)
228
+ if value.nil?
229
+ is_nullable = self.class.openapi_nullable.include?(attr)
230
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
231
+ end
232
+
233
+ hash[param] = _to_hash(value)
234
+ end
235
+ hash
236
+ end
237
+
238
+ # Outputs non-array value in the form of hash
239
+ # For object, use to_hash. Otherwise, just return the value
240
+ # @param [Object] value Any valid value
241
+ # @return [Hash] Returns the value in the form of hash
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map { |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to? :to_hash
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end
255
+
256
+ end
257
+
258
+ end
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.0.1-alpha
7
7
  Contact: yuga.cohler@coinbase.com
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.6.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
  Contact: yuga.cohler@coinbase.com
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.6.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
  Contact: yuga.cohler@coinbase.com
8
8
  Generated by: https://openapi-generator.tech
9
- Generator version: 7.7.0
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -0,0 +1,221 @@
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.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Coinbase::Client
17
+ class GetValidator200Response
18
+ attr_accessor :validator
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'validator' => :'validator'
24
+ }
25
+ end
26
+
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'validator' => :'GetValidator200ResponseValidator'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::GetValidator200Response` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::GetValidator200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'validator')
61
+ self.validator = attributes[:'validator']
62
+ else
63
+ self.validator = nil
64
+ end
65
+ end
66
+
67
+ # Show invalid properties with the reasons. Usually used together with valid?
68
+ # @return Array for valid properties with the reasons
69
+ def list_invalid_properties
70
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
71
+ invalid_properties = Array.new
72
+ if @validator.nil?
73
+ invalid_properties.push('invalid value for "validator", validator cannot be nil.')
74
+ end
75
+
76
+ invalid_properties
77
+ end
78
+
79
+ # Check to see if the all the properties in the model are valid
80
+ # @return true if the model is valid
81
+ def valid?
82
+ warn '[DEPRECATED] the `valid?` method is obsolete'
83
+ return false if @validator.nil?
84
+ true
85
+ end
86
+
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
89
+ def ==(o)
90
+ return true if self.equal?(o)
91
+ self.class == o.class &&
92
+ validator == o.validator
93
+ end
94
+
95
+ # @see the `==` method
96
+ # @param [Object] Object to be compared
97
+ def eql?(o)
98
+ self == o
99
+ end
100
+
101
+ # Calculates hash code according to all attributes.
102
+ # @return [Integer] Hash code
103
+ def hash
104
+ [validator].hash
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def self.build_from_hash(attributes)
111
+ return nil unless attributes.is_a?(Hash)
112
+ attributes = attributes.transform_keys(&:to_sym)
113
+ transformed_hash = {}
114
+ openapi_types.each_pair do |key, type|
115
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
116
+ transformed_hash["#{key}"] = nil
117
+ elsif type =~ /\AArray<(.*)>/i
118
+ # check to ensure the input is an array given that the attribute
119
+ # is documented as an array but the input is not
120
+ if attributes[attribute_map[key]].is_a?(Array)
121
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
122
+ end
123
+ elsif !attributes[attribute_map[key]].nil?
124
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
125
+ end
126
+ end
127
+ new(transformed_hash)
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def self._deserialize(type, value)
135
+ case type.to_sym
136
+ when :Time
137
+ Time.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ # models (e.g. Pet) or oneOf
168
+ klass = Coinbase::Client.const_get(type)
169
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
170
+ end
171
+ end
172
+
173
+ # Returns the string representation of the object
174
+ # @return [String] String presentation of the object
175
+ def to_s
176
+ to_hash.to_s
177
+ end
178
+
179
+ # to_body is an alias to to_hash (backward compatibility)
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_body
182
+ to_hash
183
+ end
184
+
185
+ # Returns the object in the form of hash
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_hash
188
+ hash = {}
189
+ self.class.attribute_map.each_pair do |attr, param|
190
+ value = self.send(attr)
191
+ if value.nil?
192
+ is_nullable = self.class.openapi_nullable.include?(attr)
193
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
194
+ end
195
+
196
+ hash[param] = _to_hash(value)
197
+ end
198
+ hash
199
+ end
200
+
201
+ # Outputs non-array value in the form of hash
202
+ # For object, use to_hash. Otherwise, just return the value
203
+ # @param [Object] value Any valid value
204
+ # @return [Hash] Returns the value in the form of hash
205
+ def _to_hash(value)
206
+ if value.is_a?(Array)
207
+ value.compact.map { |v| _to_hash(v) }
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.each { |k, v| hash[k] = _to_hash(v) }
211
+ end
212
+ elsif value.respond_to? :to_hash
213
+ value.to_hash
214
+ else
215
+ value
216
+ end
217
+ end
218
+
219
+ end
220
+
221
+ end