coinbase-sdk 0.0.6 → 0.0.8
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.rb +73 -19
- data/lib/coinbase/asset.rb +80 -56
- data/lib/coinbase/balance.rb +10 -6
- data/lib/coinbase/client/api/assets_api.rb +91 -0
- data/lib/coinbase/client/api/balances_api.rb +97 -0
- data/lib/coinbase/client/api/external_addresses_api.rb +242 -0
- data/lib/coinbase/client/api/server_signers_api.rb +13 -3
- data/lib/coinbase/client/api/stake_api.rb +236 -0
- data/lib/coinbase/client/api/transfer_api.rb +114 -0
- data/lib/coinbase/client/models/broadcast_trade_request.rb +14 -4
- data/lib/coinbase/client/models/build_staking_operation_request.rb +291 -0
- data/lib/coinbase/client/models/feature.rb +42 -0
- data/lib/coinbase/client/models/fetch_staking_rewards200_response.rb +258 -0
- data/lib/coinbase/client/models/fetch_staking_rewards_request.rb +343 -0
- data/lib/coinbase/client/models/get_staking_context_request.rb +274 -0
- data/lib/coinbase/client/models/partial_eth_staking_context.rb +257 -0
- data/lib/coinbase/client/models/request_faucet_funds200_response.rb +222 -0
- data/lib/coinbase/client/models/server_signer_list.rb +275 -0
- data/lib/coinbase/client/models/staking_context.rb +222 -0
- data/lib/coinbase/client/models/staking_context_context.rb +104 -0
- data/lib/coinbase/client/models/staking_operation.rb +222 -0
- data/lib/coinbase/client/models/staking_reward.rb +308 -0
- data/lib/coinbase/client/models/trade.rb +13 -4
- data/lib/coinbase/client/models/transaction.rb +45 -1
- data/lib/coinbase/client/models/transfer.rb +33 -1
- data/lib/coinbase/client/models/wallet.rb +20 -1
- data/lib/coinbase/client.rb +14 -0
- data/lib/coinbase/constants.rb +2 -27
- data/lib/coinbase/errors.rb +50 -62
- data/lib/coinbase/network.rb +6 -20
- data/lib/coinbase/server_signer.rb +57 -0
- data/lib/coinbase/trade.rb +147 -0
- data/lib/coinbase/transaction.rb +125 -0
- data/lib/coinbase/transfer.rb +22 -55
- data/lib/coinbase/wallet.rb +14 -3
- data/lib/coinbase.rb +11 -11
- metadata +22 -2
@@ -18,10 +18,14 @@ module Coinbase::Client
|
|
18
18
|
# The hex-encoded signed payload of the trade
|
19
19
|
attr_accessor :signed_payload
|
20
20
|
|
21
|
+
# The hex-encoded signed payload of the approval transaction
|
22
|
+
attr_accessor :approve_transaction_signed_payload
|
23
|
+
|
21
24
|
# Attribute mapping from ruby-style variable name to JSON key.
|
22
25
|
def self.attribute_map
|
23
26
|
{
|
24
|
-
:'signed_payload' => :'signed_payload'
|
27
|
+
:'signed_payload' => :'signed_payload',
|
28
|
+
:'approve_transaction_signed_payload' => :'approve_transaction_signed_payload'
|
25
29
|
}
|
26
30
|
end
|
27
31
|
|
@@ -33,7 +37,8 @@ module Coinbase::Client
|
|
33
37
|
# Attribute type mapping.
|
34
38
|
def self.openapi_types
|
35
39
|
{
|
36
|
-
:'signed_payload' => :'String'
|
40
|
+
:'signed_payload' => :'String',
|
41
|
+
:'approve_transaction_signed_payload' => :'String'
|
37
42
|
}
|
38
43
|
end
|
39
44
|
|
@@ -63,6 +68,10 @@ module Coinbase::Client
|
|
63
68
|
else
|
64
69
|
self.signed_payload = nil
|
65
70
|
end
|
71
|
+
|
72
|
+
if attributes.key?(:'approve_transaction_signed_payload')
|
73
|
+
self.approve_transaction_signed_payload = attributes[:'approve_transaction_signed_payload']
|
74
|
+
end
|
66
75
|
end
|
67
76
|
|
68
77
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -90,7 +99,8 @@ module Coinbase::Client
|
|
90
99
|
def ==(o)
|
91
100
|
return true if self.equal?(o)
|
92
101
|
self.class == o.class &&
|
93
|
-
signed_payload == o.signed_payload
|
102
|
+
signed_payload == o.signed_payload &&
|
103
|
+
approve_transaction_signed_payload == o.approve_transaction_signed_payload
|
94
104
|
end
|
95
105
|
|
96
106
|
# @see the `==` method
|
@@ -102,7 +112,7 @@ module Coinbase::Client
|
|
102
112
|
# Calculates hash code according to all attributes.
|
103
113
|
# @return [Integer] Hash code
|
104
114
|
def hash
|
105
|
-
[signed_payload].hash
|
115
|
+
[signed_payload, approve_transaction_signed_payload].hash
|
106
116
|
end
|
107
117
|
|
108
118
|
# Builds the object from hash
|
@@ -0,0 +1,291 @@
|
|
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 BuildStakingOperationRequest
|
18
|
+
# The ID of the blockchain network
|
19
|
+
attr_accessor :network_id
|
20
|
+
|
21
|
+
# The ID of the asset being staked
|
22
|
+
attr_accessor :asset_id
|
23
|
+
|
24
|
+
# The onchain address from which the staking transaction originates and is responsible for signing the transaction.
|
25
|
+
attr_accessor :address_id
|
26
|
+
|
27
|
+
# The type of staking operation
|
28
|
+
attr_accessor :action
|
29
|
+
|
30
|
+
attr_accessor :options
|
31
|
+
|
32
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
33
|
+
def self.attribute_map
|
34
|
+
{
|
35
|
+
:'network_id' => :'network_id',
|
36
|
+
:'asset_id' => :'asset_id',
|
37
|
+
:'address_id' => :'address_id',
|
38
|
+
:'action' => :'action',
|
39
|
+
:'options' => :'options'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns all the JSON keys this model knows about
|
44
|
+
def self.acceptable_attributes
|
45
|
+
attribute_map.values
|
46
|
+
end
|
47
|
+
|
48
|
+
# Attribute type mapping.
|
49
|
+
def self.openapi_types
|
50
|
+
{
|
51
|
+
:'network_id' => :'String',
|
52
|
+
:'asset_id' => :'String',
|
53
|
+
:'address_id' => :'String',
|
54
|
+
:'action' => :'String',
|
55
|
+
:'options' => :'Hash<String, String>'
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
# List of attributes with nullable: true
|
60
|
+
def self.openapi_nullable
|
61
|
+
Set.new([
|
62
|
+
])
|
63
|
+
end
|
64
|
+
|
65
|
+
# Initializes the object
|
66
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
67
|
+
def initialize(attributes = {})
|
68
|
+
if (!attributes.is_a?(Hash))
|
69
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::BuildStakingOperationRequest` initialize method"
|
70
|
+
end
|
71
|
+
|
72
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
73
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
74
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
75
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::BuildStakingOperationRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
76
|
+
end
|
77
|
+
h[k.to_sym] = v
|
78
|
+
}
|
79
|
+
|
80
|
+
if attributes.key?(:'network_id')
|
81
|
+
self.network_id = attributes[:'network_id']
|
82
|
+
else
|
83
|
+
self.network_id = nil
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.key?(:'asset_id')
|
87
|
+
self.asset_id = attributes[:'asset_id']
|
88
|
+
else
|
89
|
+
self.asset_id = nil
|
90
|
+
end
|
91
|
+
|
92
|
+
if attributes.key?(:'address_id')
|
93
|
+
self.address_id = attributes[:'address_id']
|
94
|
+
else
|
95
|
+
self.address_id = nil
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.key?(:'action')
|
99
|
+
self.action = attributes[:'action']
|
100
|
+
else
|
101
|
+
self.action = nil
|
102
|
+
end
|
103
|
+
|
104
|
+
if attributes.key?(:'options')
|
105
|
+
if (value = attributes[:'options']).is_a?(Hash)
|
106
|
+
self.options = value
|
107
|
+
end
|
108
|
+
else
|
109
|
+
self.options = nil
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
114
|
+
# @return Array for valid properties with the reasons
|
115
|
+
def list_invalid_properties
|
116
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
117
|
+
invalid_properties = Array.new
|
118
|
+
if @network_id.nil?
|
119
|
+
invalid_properties.push('invalid value for "network_id", network_id cannot be nil.')
|
120
|
+
end
|
121
|
+
|
122
|
+
if @asset_id.nil?
|
123
|
+
invalid_properties.push('invalid value for "asset_id", asset_id cannot be nil.')
|
124
|
+
end
|
125
|
+
|
126
|
+
if @address_id.nil?
|
127
|
+
invalid_properties.push('invalid value for "address_id", address_id cannot be nil.')
|
128
|
+
end
|
129
|
+
|
130
|
+
if @action.nil?
|
131
|
+
invalid_properties.push('invalid value for "action", action cannot be nil.')
|
132
|
+
end
|
133
|
+
|
134
|
+
if @options.nil?
|
135
|
+
invalid_properties.push('invalid value for "options", options cannot be nil.')
|
136
|
+
end
|
137
|
+
|
138
|
+
invalid_properties
|
139
|
+
end
|
140
|
+
|
141
|
+
# Check to see if the all the properties in the model are valid
|
142
|
+
# @return true if the model is valid
|
143
|
+
def valid?
|
144
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
145
|
+
return false if @network_id.nil?
|
146
|
+
return false if @asset_id.nil?
|
147
|
+
return false if @address_id.nil?
|
148
|
+
return false if @action.nil?
|
149
|
+
return false if @options.nil?
|
150
|
+
true
|
151
|
+
end
|
152
|
+
|
153
|
+
# Checks equality by comparing each attribute.
|
154
|
+
# @param [Object] Object to be compared
|
155
|
+
def ==(o)
|
156
|
+
return true if self.equal?(o)
|
157
|
+
self.class == o.class &&
|
158
|
+
network_id == o.network_id &&
|
159
|
+
asset_id == o.asset_id &&
|
160
|
+
address_id == o.address_id &&
|
161
|
+
action == o.action &&
|
162
|
+
options == o.options
|
163
|
+
end
|
164
|
+
|
165
|
+
# @see the `==` method
|
166
|
+
# @param [Object] Object to be compared
|
167
|
+
def eql?(o)
|
168
|
+
self == o
|
169
|
+
end
|
170
|
+
|
171
|
+
# Calculates hash code according to all attributes.
|
172
|
+
# @return [Integer] Hash code
|
173
|
+
def hash
|
174
|
+
[network_id, asset_id, address_id, action, options].hash
|
175
|
+
end
|
176
|
+
|
177
|
+
# Builds the object from hash
|
178
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
179
|
+
# @return [Object] Returns the model itself
|
180
|
+
def self.build_from_hash(attributes)
|
181
|
+
return nil unless attributes.is_a?(Hash)
|
182
|
+
attributes = attributes.transform_keys(&:to_sym)
|
183
|
+
transformed_hash = {}
|
184
|
+
openapi_types.each_pair do |key, type|
|
185
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
186
|
+
transformed_hash["#{key}"] = nil
|
187
|
+
elsif type =~ /\AArray<(.*)>/i
|
188
|
+
# check to ensure the input is an array given that the attribute
|
189
|
+
# is documented as an array but the input is not
|
190
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
191
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
192
|
+
end
|
193
|
+
elsif !attributes[attribute_map[key]].nil?
|
194
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
195
|
+
end
|
196
|
+
end
|
197
|
+
new(transformed_hash)
|
198
|
+
end
|
199
|
+
|
200
|
+
# Deserializes the data based on type
|
201
|
+
# @param string type Data type
|
202
|
+
# @param string value Value to be deserialized
|
203
|
+
# @return [Object] Deserialized data
|
204
|
+
def self._deserialize(type, value)
|
205
|
+
case type.to_sym
|
206
|
+
when :Time
|
207
|
+
Time.parse(value)
|
208
|
+
when :Date
|
209
|
+
Date.parse(value)
|
210
|
+
when :String
|
211
|
+
value.to_s
|
212
|
+
when :Integer
|
213
|
+
value.to_i
|
214
|
+
when :Float
|
215
|
+
value.to_f
|
216
|
+
when :Boolean
|
217
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
218
|
+
true
|
219
|
+
else
|
220
|
+
false
|
221
|
+
end
|
222
|
+
when :Object
|
223
|
+
# generic object (usually a Hash), return directly
|
224
|
+
value
|
225
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
226
|
+
inner_type = Regexp.last_match[:inner_type]
|
227
|
+
value.map { |v| _deserialize(inner_type, v) }
|
228
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
229
|
+
k_type = Regexp.last_match[:k_type]
|
230
|
+
v_type = Regexp.last_match[:v_type]
|
231
|
+
{}.tap do |hash|
|
232
|
+
value.each do |k, v|
|
233
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
else # model
|
237
|
+
# models (e.g. Pet) or oneOf
|
238
|
+
klass = Coinbase::Client.const_get(type)
|
239
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
# Returns the string representation of the object
|
244
|
+
# @return [String] String presentation of the object
|
245
|
+
def to_s
|
246
|
+
to_hash.to_s
|
247
|
+
end
|
248
|
+
|
249
|
+
# to_body is an alias to to_hash (backward compatibility)
|
250
|
+
# @return [Hash] Returns the object in the form of hash
|
251
|
+
def to_body
|
252
|
+
to_hash
|
253
|
+
end
|
254
|
+
|
255
|
+
# Returns the object in the form of hash
|
256
|
+
# @return [Hash] Returns the object in the form of hash
|
257
|
+
def to_hash
|
258
|
+
hash = {}
|
259
|
+
self.class.attribute_map.each_pair do |attr, param|
|
260
|
+
value = self.send(attr)
|
261
|
+
if value.nil?
|
262
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
263
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
264
|
+
end
|
265
|
+
|
266
|
+
hash[param] = _to_hash(value)
|
267
|
+
end
|
268
|
+
hash
|
269
|
+
end
|
270
|
+
|
271
|
+
# Outputs non-array value in the form of hash
|
272
|
+
# For object, use to_hash. Otherwise, just return the value
|
273
|
+
# @param [Object] value Any valid value
|
274
|
+
# @return [Hash] Returns the value in the form of hash
|
275
|
+
def _to_hash(value)
|
276
|
+
if value.is_a?(Array)
|
277
|
+
value.compact.map { |v| _to_hash(v) }
|
278
|
+
elsif value.is_a?(Hash)
|
279
|
+
{}.tap do |hash|
|
280
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
281
|
+
end
|
282
|
+
elsif value.respond_to? :to_hash
|
283
|
+
value.to_hash
|
284
|
+
else
|
285
|
+
value
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
@@ -0,0 +1,42 @@
|
|
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 Feature
|
18
|
+
TRANSFER = "transfer".freeze
|
19
|
+
TRADE = "trade".freeze
|
20
|
+
FAUCET = "faucet".freeze
|
21
|
+
SERVER_SIGNER = "server_signer".freeze
|
22
|
+
|
23
|
+
def self.all_vars
|
24
|
+
@all_vars ||= [TRANSFER, TRADE, FAUCET, SERVER_SIGNER].freeze
|
25
|
+
end
|
26
|
+
|
27
|
+
# Builds the enum from string
|
28
|
+
# @param [String] The enum value in the form of the string
|
29
|
+
# @return [String] The enum value
|
30
|
+
def self.build_from_hash(value)
|
31
|
+
new.build_from_hash(value)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Builds the enum from string
|
35
|
+
# @param [String] The enum value in the form of the string
|
36
|
+
# @return [String] The enum value
|
37
|
+
def build_from_hash(value)
|
38
|
+
return value if Feature.all_vars.include?(value)
|
39
|
+
raise "Invalid ENUM value #{value} for class #Feature"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -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.5.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Coinbase::Client
|
17
|
+
#
|
18
|
+
class FetchStakingRewards200Response
|
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<StakingReward>',
|
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::FetchStakingRewards200Response` 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::FetchStakingRewards200Response`. 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
|