coinbase-sdk 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coinbase/address/external_address.rb +3 -166
- data/lib/coinbase/address/wallet_address.rb +44 -0
- data/lib/coinbase/address.rb +128 -0
- data/lib/coinbase/client/api/addresses_api.rb +1 -1
- data/lib/coinbase/client/api/assets_api.rb +3 -3
- data/lib/coinbase/client/api/contract_events_api.rb +121 -0
- data/lib/coinbase/client/api/external_addresses_api.rb +1 -1
- data/lib/coinbase/client/api/server_signers_api.rb +1 -1
- data/lib/coinbase/client/api/stake_api.rb +242 -1
- data/lib/coinbase/client/api/trades_api.rb +1 -1
- data/lib/coinbase/client/api/transfers_api.rb +1 -1
- data/lib/coinbase/client/api/users_api.rb +1 -1
- data/lib/coinbase/client/api/validators_api.rb +1 -1
- data/lib/coinbase/client/api/wallets_api.rb +1 -1
- data/lib/coinbase/client/api/webhooks_api.rb +286 -0
- data/lib/coinbase/client/api_client.rb +1 -1
- data/lib/coinbase/client/api_error.rb +1 -1
- data/lib/coinbase/client/configuration.rb +11 -1
- data/lib/coinbase/client/models/address.rb +1 -1
- data/lib/coinbase/client/models/address_balance_list.rb +1 -1
- data/lib/coinbase/client/models/address_list.rb +1 -1
- data/lib/coinbase/client/models/asset.rb +1 -1
- data/lib/coinbase/client/models/balance.rb +1 -1
- data/lib/coinbase/client/models/broadcast_staking_operation_request.rb +239 -0
- data/lib/coinbase/client/models/broadcast_trade_request.rb +1 -1
- data/lib/coinbase/client/models/broadcast_transfer_request.rb +1 -1
- data/lib/coinbase/client/models/build_staking_operation_request.rb +1 -1
- data/lib/coinbase/client/models/contract_event.rb +336 -0
- data/lib/coinbase/client/models/contract_event_list.rb +259 -0
- data/lib/coinbase/client/models/create_address_request.rb +1 -1
- data/lib/coinbase/client/models/create_server_signer_request.rb +1 -1
- data/lib/coinbase/client/models/create_staking_operation_request.rb +274 -0
- data/lib/coinbase/client/models/create_trade_request.rb +1 -1
- data/lib/coinbase/client/models/create_transfer_request.rb +1 -1
- data/lib/coinbase/client/models/create_wallet_request.rb +1 -1
- data/lib/coinbase/client/models/create_wallet_request_wallet.rb +1 -1
- data/lib/coinbase/client/models/create_webhook_request.rb +282 -0
- data/lib/coinbase/client/models/error.rb +1 -1
- data/lib/coinbase/client/models/ethereum_validator_metadata.rb +1 -1
- data/lib/coinbase/client/models/faucet_transaction.rb +1 -1
- data/lib/coinbase/client/models/feature.rb +1 -1
- data/lib/coinbase/client/models/fetch_staking_rewards200_response.rb +1 -1
- data/lib/coinbase/client/models/fetch_staking_rewards_request.rb +1 -1
- data/lib/coinbase/client/models/get_staking_context_request.rb +1 -1
- data/lib/coinbase/client/models/native_eth_staking_context.rb +1 -1
- data/lib/coinbase/client/models/partial_eth_staking_context.rb +1 -1
- data/lib/coinbase/client/models/seed_creation_event.rb +1 -1
- data/lib/coinbase/client/models/seed_creation_event_result.rb +1 -1
- data/lib/coinbase/client/models/server_signer.rb +1 -1
- data/lib/coinbase/client/models/server_signer_event.rb +1 -1
- data/lib/coinbase/client/models/server_signer_event_event.rb +1 -1
- data/lib/coinbase/client/models/server_signer_event_list.rb +1 -1
- data/lib/coinbase/client/models/server_signer_list.rb +1 -1
- data/lib/coinbase/client/models/signature_creation_event.rb +1 -1
- data/lib/coinbase/client/models/signature_creation_event_result.rb +1 -1
- data/lib/coinbase/client/models/signed_voluntary_exit_message_metadata.rb +1 -1
- data/lib/coinbase/client/models/staking_context.rb +1 -1
- data/lib/coinbase/client/models/staking_context_context.rb +1 -1
- data/lib/coinbase/client/models/staking_operation.rb +16 -6
- data/lib/coinbase/client/models/staking_operation_metadata.rb +1 -1
- data/lib/coinbase/client/models/staking_reward.rb +1 -1
- data/lib/coinbase/client/models/staking_reward_format.rb +1 -1
- data/lib/coinbase/client/models/trade.rb +1 -1
- data/lib/coinbase/client/models/trade_list.rb +1 -1
- data/lib/coinbase/client/models/transaction.rb +1 -1
- data/lib/coinbase/client/models/transaction_type.rb +1 -1
- data/lib/coinbase/client/models/transfer.rb +5 -93
- data/lib/coinbase/client/models/transfer_list.rb +1 -1
- data/lib/coinbase/client/models/update_webhook_request.rb +289 -0
- data/lib/coinbase/client/models/user.rb +1 -1
- data/lib/coinbase/client/models/validator.rb +1 -1
- data/lib/coinbase/client/models/validator_details.rb +1 -1
- data/lib/coinbase/client/models/validator_list.rb +1 -1
- data/lib/coinbase/client/models/wallet.rb +1 -1
- data/lib/coinbase/client/models/wallet_list.rb +1 -1
- data/lib/coinbase/client/models/webhook.rb +299 -0
- data/lib/coinbase/client/models/webhook_event_filter.rb +236 -0
- data/lib/coinbase/client/models/webhook_event_type.rb +41 -0
- data/lib/coinbase/client/models/webhook_list.rb +244 -0
- data/lib/coinbase/client/version.rb +1 -1
- data/lib/coinbase/client.rb +13 -1
- data/lib/coinbase/middleware.rb +12 -0
- data/lib/coinbase/staking_operation.rb +106 -5
- data/lib/coinbase/trade.rb +1 -1
- data/lib/coinbase/transfer.rb +4 -5
- data/lib/coinbase/wallet.rb +76 -0
- data/lib/coinbase.rb +2 -1
- metadata +28 -2
@@ -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.
|
9
|
+
Generator version: 7.7.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -41,40 +41,6 @@ module Coinbase::Client
|
|
41
41
|
|
42
42
|
attr_accessor :transaction
|
43
43
|
|
44
|
-
# The unsigned payload of the transfer. This is the payload that needs to be signed by the sender.
|
45
|
-
attr_accessor :unsigned_payload
|
46
|
-
|
47
|
-
# The signed payload of the transfer. This is the payload that has been signed by the sender.
|
48
|
-
attr_accessor :signed_payload
|
49
|
-
|
50
|
-
# The hash of the transfer transaction
|
51
|
-
attr_accessor :transaction_hash
|
52
|
-
|
53
|
-
# The status of the transfer
|
54
|
-
attr_accessor :status
|
55
|
-
|
56
|
-
class EnumAttributeValidator
|
57
|
-
attr_reader :datatype
|
58
|
-
attr_reader :allowable_values
|
59
|
-
|
60
|
-
def initialize(datatype, allowable_values)
|
61
|
-
@allowable_values = allowable_values.map do |value|
|
62
|
-
case datatype.to_s
|
63
|
-
when /Integer/i
|
64
|
-
value.to_i
|
65
|
-
when /Float/i
|
66
|
-
value.to_f
|
67
|
-
else
|
68
|
-
value
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def valid?(value)
|
74
|
-
!value || allowable_values.include?(value)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
44
|
# Attribute mapping from ruby-style variable name to JSON key.
|
79
45
|
def self.attribute_map
|
80
46
|
{
|
@@ -86,11 +52,7 @@ module Coinbase::Client
|
|
86
52
|
:'asset_id' => :'asset_id',
|
87
53
|
:'asset' => :'asset',
|
88
54
|
:'transfer_id' => :'transfer_id',
|
89
|
-
:'transaction' => :'transaction'
|
90
|
-
:'unsigned_payload' => :'unsigned_payload',
|
91
|
-
:'signed_payload' => :'signed_payload',
|
92
|
-
:'transaction_hash' => :'transaction_hash',
|
93
|
-
:'status' => :'status'
|
55
|
+
:'transaction' => :'transaction'
|
94
56
|
}
|
95
57
|
end
|
96
58
|
|
@@ -110,11 +72,7 @@ module Coinbase::Client
|
|
110
72
|
:'asset_id' => :'String',
|
111
73
|
:'asset' => :'Asset',
|
112
74
|
:'transfer_id' => :'String',
|
113
|
-
:'transaction' => :'Transaction'
|
114
|
-
:'unsigned_payload' => :'String',
|
115
|
-
:'signed_payload' => :'String',
|
116
|
-
:'transaction_hash' => :'String',
|
117
|
-
:'status' => :'String'
|
75
|
+
:'transaction' => :'Transaction'
|
118
76
|
}
|
119
77
|
end
|
120
78
|
|
@@ -192,26 +150,6 @@ module Coinbase::Client
|
|
192
150
|
else
|
193
151
|
self.transaction = nil
|
194
152
|
end
|
195
|
-
|
196
|
-
if attributes.key?(:'unsigned_payload')
|
197
|
-
self.unsigned_payload = attributes[:'unsigned_payload']
|
198
|
-
else
|
199
|
-
self.unsigned_payload = nil
|
200
|
-
end
|
201
|
-
|
202
|
-
if attributes.key?(:'signed_payload')
|
203
|
-
self.signed_payload = attributes[:'signed_payload']
|
204
|
-
end
|
205
|
-
|
206
|
-
if attributes.key?(:'transaction_hash')
|
207
|
-
self.transaction_hash = attributes[:'transaction_hash']
|
208
|
-
end
|
209
|
-
|
210
|
-
if attributes.key?(:'status')
|
211
|
-
self.status = attributes[:'status']
|
212
|
-
else
|
213
|
-
self.status = nil
|
214
|
-
end
|
215
153
|
end
|
216
154
|
|
217
155
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -255,14 +193,6 @@ module Coinbase::Client
|
|
255
193
|
invalid_properties.push('invalid value for "transaction", transaction cannot be nil.')
|
256
194
|
end
|
257
195
|
|
258
|
-
if @unsigned_payload.nil?
|
259
|
-
invalid_properties.push('invalid value for "unsigned_payload", unsigned_payload cannot be nil.')
|
260
|
-
end
|
261
|
-
|
262
|
-
if @status.nil?
|
263
|
-
invalid_properties.push('invalid value for "status", status cannot be nil.')
|
264
|
-
end
|
265
|
-
|
266
196
|
invalid_properties
|
267
197
|
end
|
268
198
|
|
@@ -279,23 +209,9 @@ module Coinbase::Client
|
|
279
209
|
return false if @asset.nil?
|
280
210
|
return false if @transfer_id.nil?
|
281
211
|
return false if @transaction.nil?
|
282
|
-
return false if @unsigned_payload.nil?
|
283
|
-
return false if @status.nil?
|
284
|
-
status_validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed"])
|
285
|
-
return false unless status_validator.valid?(@status)
|
286
212
|
true
|
287
213
|
end
|
288
214
|
|
289
|
-
# Custom attribute writer method checking allowed values (enum).
|
290
|
-
# @param [Object] status Object to be assigned
|
291
|
-
def status=(status)
|
292
|
-
validator = EnumAttributeValidator.new('String', ["pending", "broadcast", "complete", "failed"])
|
293
|
-
unless validator.valid?(status)
|
294
|
-
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
|
295
|
-
end
|
296
|
-
@status = status
|
297
|
-
end
|
298
|
-
|
299
215
|
# Checks equality by comparing each attribute.
|
300
216
|
# @param [Object] Object to be compared
|
301
217
|
def ==(o)
|
@@ -309,11 +225,7 @@ module Coinbase::Client
|
|
309
225
|
asset_id == o.asset_id &&
|
310
226
|
asset == o.asset &&
|
311
227
|
transfer_id == o.transfer_id &&
|
312
|
-
transaction == o.transaction
|
313
|
-
unsigned_payload == o.unsigned_payload &&
|
314
|
-
signed_payload == o.signed_payload &&
|
315
|
-
transaction_hash == o.transaction_hash &&
|
316
|
-
status == o.status
|
228
|
+
transaction == o.transaction
|
317
229
|
end
|
318
230
|
|
319
231
|
# @see the `==` method
|
@@ -325,7 +237,7 @@ module Coinbase::Client
|
|
325
237
|
# Calculates hash code according to all attributes.
|
326
238
|
# @return [Integer] Hash code
|
327
239
|
def hash
|
328
|
-
[network_id, wallet_id, address_id, destination, amount, asset_id, asset, transfer_id, transaction
|
240
|
+
[network_id, wallet_id, address_id, destination, amount, asset_id, asset, transfer_id, transaction].hash
|
329
241
|
end
|
330
242
|
|
331
243
|
# Builds the object from hash
|
@@ -0,0 +1,289 @@
|
|
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.7.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Coinbase::Client
|
17
|
+
class UpdateWebhookRequest
|
18
|
+
# The ID of the blockchain network
|
19
|
+
attr_accessor :network_id
|
20
|
+
|
21
|
+
attr_accessor :event_type
|
22
|
+
|
23
|
+
# Webhook will monitor all events that matches any one of the event filters.
|
24
|
+
attr_accessor :event_filters
|
25
|
+
|
26
|
+
# The Webhook uri that updates to
|
27
|
+
attr_accessor :notification_uri
|
28
|
+
|
29
|
+
class EnumAttributeValidator
|
30
|
+
attr_reader :datatype
|
31
|
+
attr_reader :allowable_values
|
32
|
+
|
33
|
+
def initialize(datatype, allowable_values)
|
34
|
+
@allowable_values = allowable_values.map do |value|
|
35
|
+
case datatype.to_s
|
36
|
+
when /Integer/i
|
37
|
+
value.to_i
|
38
|
+
when /Float/i
|
39
|
+
value.to_f
|
40
|
+
else
|
41
|
+
value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def valid?(value)
|
47
|
+
!value || allowable_values.include?(value)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
52
|
+
def self.attribute_map
|
53
|
+
{
|
54
|
+
:'network_id' => :'network_id',
|
55
|
+
:'event_type' => :'event_type',
|
56
|
+
:'event_filters' => :'event_filters',
|
57
|
+
:'notification_uri' => :'notification_uri'
|
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
|
+
:'event_type' => :'WebhookEventType',
|
71
|
+
:'event_filters' => :'Array<WebhookEventFilter>',
|
72
|
+
:'notification_uri' => :'String'
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
# List of attributes with nullable: true
|
77
|
+
def self.openapi_nullable
|
78
|
+
Set.new([
|
79
|
+
])
|
80
|
+
end
|
81
|
+
|
82
|
+
# Initializes the object
|
83
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
84
|
+
def initialize(attributes = {})
|
85
|
+
if (!attributes.is_a?(Hash))
|
86
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::UpdateWebhookRequest` initialize method"
|
87
|
+
end
|
88
|
+
|
89
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
90
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
91
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
92
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::UpdateWebhookRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
93
|
+
end
|
94
|
+
h[k.to_sym] = v
|
95
|
+
}
|
96
|
+
|
97
|
+
if attributes.key?(:'network_id')
|
98
|
+
self.network_id = attributes[:'network_id']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.key?(:'event_type')
|
102
|
+
self.event_type = attributes[:'event_type']
|
103
|
+
else
|
104
|
+
self.event_type = nil
|
105
|
+
end
|
106
|
+
|
107
|
+
if attributes.key?(:'event_filters')
|
108
|
+
if (value = attributes[:'event_filters']).is_a?(Array)
|
109
|
+
self.event_filters = value
|
110
|
+
end
|
111
|
+
else
|
112
|
+
self.event_filters = nil
|
113
|
+
end
|
114
|
+
|
115
|
+
if attributes.key?(:'notification_uri')
|
116
|
+
self.notification_uri = attributes[:'notification_uri']
|
117
|
+
else
|
118
|
+
self.notification_uri = nil
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
123
|
+
# @return Array for valid properties with the reasons
|
124
|
+
def list_invalid_properties
|
125
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
126
|
+
invalid_properties = Array.new
|
127
|
+
if @event_type.nil?
|
128
|
+
invalid_properties.push('invalid value for "event_type", event_type cannot be nil.')
|
129
|
+
end
|
130
|
+
|
131
|
+
if @event_filters.nil?
|
132
|
+
invalid_properties.push('invalid value for "event_filters", event_filters cannot be nil.')
|
133
|
+
end
|
134
|
+
|
135
|
+
if @notification_uri.nil?
|
136
|
+
invalid_properties.push('invalid value for "notification_uri", notification_uri cannot be nil.')
|
137
|
+
end
|
138
|
+
|
139
|
+
invalid_properties
|
140
|
+
end
|
141
|
+
|
142
|
+
# Check to see if the all the properties in the model are valid
|
143
|
+
# @return true if the model is valid
|
144
|
+
def valid?
|
145
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
146
|
+
return false if @event_type.nil?
|
147
|
+
return false if @event_filters.nil?
|
148
|
+
return false if @notification_uri.nil?
|
149
|
+
true
|
150
|
+
end
|
151
|
+
|
152
|
+
# Checks equality by comparing each attribute.
|
153
|
+
# @param [Object] Object to be compared
|
154
|
+
def ==(o)
|
155
|
+
return true if self.equal?(o)
|
156
|
+
self.class == o.class &&
|
157
|
+
network_id == o.network_id &&
|
158
|
+
event_type == o.event_type &&
|
159
|
+
event_filters == o.event_filters &&
|
160
|
+
notification_uri == o.notification_uri
|
161
|
+
end
|
162
|
+
|
163
|
+
# @see the `==` method
|
164
|
+
# @param [Object] Object to be compared
|
165
|
+
def eql?(o)
|
166
|
+
self == o
|
167
|
+
end
|
168
|
+
|
169
|
+
# Calculates hash code according to all attributes.
|
170
|
+
# @return [Integer] Hash code
|
171
|
+
def hash
|
172
|
+
[network_id, event_type, event_filters, notification_uri].hash
|
173
|
+
end
|
174
|
+
|
175
|
+
# Builds the object from hash
|
176
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
177
|
+
# @return [Object] Returns the model itself
|
178
|
+
def self.build_from_hash(attributes)
|
179
|
+
return nil unless attributes.is_a?(Hash)
|
180
|
+
attributes = attributes.transform_keys(&:to_sym)
|
181
|
+
transformed_hash = {}
|
182
|
+
openapi_types.each_pair do |key, type|
|
183
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
184
|
+
transformed_hash["#{key}"] = nil
|
185
|
+
elsif type =~ /\AArray<(.*)>/i
|
186
|
+
# check to ensure the input is an array given that the attribute
|
187
|
+
# is documented as an array but the input is not
|
188
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
189
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
190
|
+
end
|
191
|
+
elsif !attributes[attribute_map[key]].nil?
|
192
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
193
|
+
end
|
194
|
+
end
|
195
|
+
new(transformed_hash)
|
196
|
+
end
|
197
|
+
|
198
|
+
# Deserializes the data based on type
|
199
|
+
# @param string type Data type
|
200
|
+
# @param string value Value to be deserialized
|
201
|
+
# @return [Object] Deserialized data
|
202
|
+
def self._deserialize(type, value)
|
203
|
+
case type.to_sym
|
204
|
+
when :Time
|
205
|
+
Time.parse(value)
|
206
|
+
when :Date
|
207
|
+
Date.parse(value)
|
208
|
+
when :String
|
209
|
+
value.to_s
|
210
|
+
when :Integer
|
211
|
+
value.to_i
|
212
|
+
when :Float
|
213
|
+
value.to_f
|
214
|
+
when :Boolean
|
215
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
216
|
+
true
|
217
|
+
else
|
218
|
+
false
|
219
|
+
end
|
220
|
+
when :Object
|
221
|
+
# generic object (usually a Hash), return directly
|
222
|
+
value
|
223
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
224
|
+
inner_type = Regexp.last_match[:inner_type]
|
225
|
+
value.map { |v| _deserialize(inner_type, v) }
|
226
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
227
|
+
k_type = Regexp.last_match[:k_type]
|
228
|
+
v_type = Regexp.last_match[:v_type]
|
229
|
+
{}.tap do |hash|
|
230
|
+
value.each do |k, v|
|
231
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
else # model
|
235
|
+
# models (e.g. Pet) or oneOf
|
236
|
+
klass = Coinbase::Client.const_get(type)
|
237
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
# Returns the string representation of the object
|
242
|
+
# @return [String] String presentation of the object
|
243
|
+
def to_s
|
244
|
+
to_hash.to_s
|
245
|
+
end
|
246
|
+
|
247
|
+
# to_body is an alias to to_hash (backward compatibility)
|
248
|
+
# @return [Hash] Returns the object in the form of hash
|
249
|
+
def to_body
|
250
|
+
to_hash
|
251
|
+
end
|
252
|
+
|
253
|
+
# Returns the object in the form of hash
|
254
|
+
# @return [Hash] Returns the object in the form of hash
|
255
|
+
def to_hash
|
256
|
+
hash = {}
|
257
|
+
self.class.attribute_map.each_pair do |attr, param|
|
258
|
+
value = self.send(attr)
|
259
|
+
if value.nil?
|
260
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
261
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
262
|
+
end
|
263
|
+
|
264
|
+
hash[param] = _to_hash(value)
|
265
|
+
end
|
266
|
+
hash
|
267
|
+
end
|
268
|
+
|
269
|
+
# Outputs non-array value in the form of hash
|
270
|
+
# For object, use to_hash. Otherwise, just return the value
|
271
|
+
# @param [Object] value Any valid value
|
272
|
+
# @return [Hash] Returns the value in the form of hash
|
273
|
+
def _to_hash(value)
|
274
|
+
if value.is_a?(Array)
|
275
|
+
value.compact.map { |v| _to_hash(v) }
|
276
|
+
elsif value.is_a?(Hash)
|
277
|
+
{}.tap do |hash|
|
278
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
279
|
+
end
|
280
|
+
elsif value.respond_to? :to_hash
|
281
|
+
value.to_hash
|
282
|
+
else
|
283
|
+
value
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
end
|
288
|
+
|
289
|
+
end
|