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