coinbase-sdk 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,357 @@
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
+ # An Ethereum validator.
18
+ class EthereumValidatorMetadata
19
+ # The index of the validator in the validator set.
20
+ attr_accessor :index
21
+
22
+ # The public key of the validator.
23
+ attr_accessor :public_key
24
+
25
+ # The address to which the validator's rewards are sent.
26
+ attr_accessor :withdrawl_address
27
+
28
+ # Whether the validator has been slashed.
29
+ attr_accessor :slashed
30
+
31
+ # The epoch at which the validator was activated.
32
+ attr_accessor :activation_epoch
33
+
34
+ # The epoch at which the validator exited.
35
+ attr_accessor :exit_epoch
36
+
37
+ # The epoch at which the validator can withdraw.
38
+ attr_accessor :withdrawable_epoch
39
+
40
+ attr_accessor :balance
41
+
42
+ attr_accessor :effective_balance
43
+
44
+ # Attribute mapping from ruby-style variable name to JSON key.
45
+ def self.attribute_map
46
+ {
47
+ :'index' => :'index',
48
+ :'public_key' => :'public_key',
49
+ :'withdrawl_address' => :'withdrawl_address',
50
+ :'slashed' => :'slashed',
51
+ :'activation_epoch' => :'activationEpoch',
52
+ :'exit_epoch' => :'exitEpoch',
53
+ :'withdrawable_epoch' => :'withdrawableEpoch',
54
+ :'balance' => :'balance',
55
+ :'effective_balance' => :'effective_balance'
56
+ }
57
+ end
58
+
59
+ # Returns all the JSON keys this model knows about
60
+ def self.acceptable_attributes
61
+ attribute_map.values
62
+ end
63
+
64
+ # Attribute type mapping.
65
+ def self.openapi_types
66
+ {
67
+ :'index' => :'String',
68
+ :'public_key' => :'String',
69
+ :'withdrawl_address' => :'String',
70
+ :'slashed' => :'Boolean',
71
+ :'activation_epoch' => :'String',
72
+ :'exit_epoch' => :'String',
73
+ :'withdrawable_epoch' => :'String',
74
+ :'balance' => :'Balance',
75
+ :'effective_balance' => :'Balance'
76
+ }
77
+ end
78
+
79
+ # List of attributes with nullable: true
80
+ def self.openapi_nullable
81
+ Set.new([
82
+ ])
83
+ end
84
+
85
+ # Initializes the object
86
+ # @param [Hash] attributes Model attributes in the form of hash
87
+ def initialize(attributes = {})
88
+ if (!attributes.is_a?(Hash))
89
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::EthereumValidatorMetadata` initialize method"
90
+ end
91
+
92
+ # check to see if the attribute exists and convert string to symbol for hash key
93
+ attributes = attributes.each_with_object({}) { |(k, v), h|
94
+ if (!self.class.attribute_map.key?(k.to_sym))
95
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::EthereumValidatorMetadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
96
+ end
97
+ h[k.to_sym] = v
98
+ }
99
+
100
+ if attributes.key?(:'index')
101
+ self.index = attributes[:'index']
102
+ else
103
+ self.index = nil
104
+ end
105
+
106
+ if attributes.key?(:'public_key')
107
+ self.public_key = attributes[:'public_key']
108
+ else
109
+ self.public_key = nil
110
+ end
111
+
112
+ if attributes.key?(:'withdrawl_address')
113
+ self.withdrawl_address = attributes[:'withdrawl_address']
114
+ else
115
+ self.withdrawl_address = nil
116
+ end
117
+
118
+ if attributes.key?(:'slashed')
119
+ self.slashed = attributes[:'slashed']
120
+ else
121
+ self.slashed = nil
122
+ end
123
+
124
+ if attributes.key?(:'activation_epoch')
125
+ self.activation_epoch = attributes[:'activation_epoch']
126
+ else
127
+ self.activation_epoch = nil
128
+ end
129
+
130
+ if attributes.key?(:'exit_epoch')
131
+ self.exit_epoch = attributes[:'exit_epoch']
132
+ else
133
+ self.exit_epoch = nil
134
+ end
135
+
136
+ if attributes.key?(:'withdrawable_epoch')
137
+ self.withdrawable_epoch = attributes[:'withdrawable_epoch']
138
+ else
139
+ self.withdrawable_epoch = nil
140
+ end
141
+
142
+ if attributes.key?(:'balance')
143
+ self.balance = attributes[:'balance']
144
+ else
145
+ self.balance = nil
146
+ end
147
+
148
+ if attributes.key?(:'effective_balance')
149
+ self.effective_balance = attributes[:'effective_balance']
150
+ else
151
+ self.effective_balance = nil
152
+ end
153
+ end
154
+
155
+ # Show invalid properties with the reasons. Usually used together with valid?
156
+ # @return Array for valid properties with the reasons
157
+ def list_invalid_properties
158
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
159
+ invalid_properties = Array.new
160
+ if @index.nil?
161
+ invalid_properties.push('invalid value for "index", index cannot be nil.')
162
+ end
163
+
164
+ if @public_key.nil?
165
+ invalid_properties.push('invalid value for "public_key", public_key cannot be nil.')
166
+ end
167
+
168
+ if @withdrawl_address.nil?
169
+ invalid_properties.push('invalid value for "withdrawl_address", withdrawl_address cannot be nil.')
170
+ end
171
+
172
+ if @slashed.nil?
173
+ invalid_properties.push('invalid value for "slashed", slashed cannot be nil.')
174
+ end
175
+
176
+ if @activation_epoch.nil?
177
+ invalid_properties.push('invalid value for "activation_epoch", activation_epoch cannot be nil.')
178
+ end
179
+
180
+ if @exit_epoch.nil?
181
+ invalid_properties.push('invalid value for "exit_epoch", exit_epoch cannot be nil.')
182
+ end
183
+
184
+ if @withdrawable_epoch.nil?
185
+ invalid_properties.push('invalid value for "withdrawable_epoch", withdrawable_epoch cannot be nil.')
186
+ end
187
+
188
+ if @balance.nil?
189
+ invalid_properties.push('invalid value for "balance", balance cannot be nil.')
190
+ end
191
+
192
+ if @effective_balance.nil?
193
+ invalid_properties.push('invalid value for "effective_balance", effective_balance cannot be nil.')
194
+ end
195
+
196
+ invalid_properties
197
+ end
198
+
199
+ # Check to see if the all the properties in the model are valid
200
+ # @return true if the model is valid
201
+ def valid?
202
+ warn '[DEPRECATED] the `valid?` method is obsolete'
203
+ return false if @index.nil?
204
+ return false if @public_key.nil?
205
+ return false if @withdrawl_address.nil?
206
+ return false if @slashed.nil?
207
+ return false if @activation_epoch.nil?
208
+ return false if @exit_epoch.nil?
209
+ return false if @withdrawable_epoch.nil?
210
+ return false if @balance.nil?
211
+ return false if @effective_balance.nil?
212
+ true
213
+ end
214
+
215
+ # Checks equality by comparing each attribute.
216
+ # @param [Object] Object to be compared
217
+ def ==(o)
218
+ return true if self.equal?(o)
219
+ self.class == o.class &&
220
+ index == o.index &&
221
+ public_key == o.public_key &&
222
+ withdrawl_address == o.withdrawl_address &&
223
+ slashed == o.slashed &&
224
+ activation_epoch == o.activation_epoch &&
225
+ exit_epoch == o.exit_epoch &&
226
+ withdrawable_epoch == o.withdrawable_epoch &&
227
+ balance == o.balance &&
228
+ effective_balance == o.effective_balance
229
+ end
230
+
231
+ # @see the `==` method
232
+ # @param [Object] Object to be compared
233
+ def eql?(o)
234
+ self == o
235
+ end
236
+
237
+ # Calculates hash code according to all attributes.
238
+ # @return [Integer] Hash code
239
+ def hash
240
+ [index, public_key, withdrawl_address, slashed, activation_epoch, exit_epoch, withdrawable_epoch, balance, effective_balance].hash
241
+ end
242
+
243
+ # Builds the object from hash
244
+ # @param [Hash] attributes Model attributes in the form of hash
245
+ # @return [Object] Returns the model itself
246
+ def self.build_from_hash(attributes)
247
+ return nil unless attributes.is_a?(Hash)
248
+ attributes = attributes.transform_keys(&:to_sym)
249
+ transformed_hash = {}
250
+ openapi_types.each_pair do |key, type|
251
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
252
+ transformed_hash["#{key}"] = nil
253
+ elsif type =~ /\AArray<(.*)>/i
254
+ # check to ensure the input is an array given that the attribute
255
+ # is documented as an array but the input is not
256
+ if attributes[attribute_map[key]].is_a?(Array)
257
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
258
+ end
259
+ elsif !attributes[attribute_map[key]].nil?
260
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
261
+ end
262
+ end
263
+ new(transformed_hash)
264
+ end
265
+
266
+ # Deserializes the data based on type
267
+ # @param string type Data type
268
+ # @param string value Value to be deserialized
269
+ # @return [Object] Deserialized data
270
+ def self._deserialize(type, value)
271
+ case type.to_sym
272
+ when :Time
273
+ Time.parse(value)
274
+ when :Date
275
+ Date.parse(value)
276
+ when :String
277
+ value.to_s
278
+ when :Integer
279
+ value.to_i
280
+ when :Float
281
+ value.to_f
282
+ when :Boolean
283
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
284
+ true
285
+ else
286
+ false
287
+ end
288
+ when :Object
289
+ # generic object (usually a Hash), return directly
290
+ value
291
+ when /\AArray<(?<inner_type>.+)>\z/
292
+ inner_type = Regexp.last_match[:inner_type]
293
+ value.map { |v| _deserialize(inner_type, v) }
294
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
295
+ k_type = Regexp.last_match[:k_type]
296
+ v_type = Regexp.last_match[:v_type]
297
+ {}.tap do |hash|
298
+ value.each do |k, v|
299
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
300
+ end
301
+ end
302
+ else # model
303
+ # models (e.g. Pet) or oneOf
304
+ klass = Coinbase::Client.const_get(type)
305
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
306
+ end
307
+ end
308
+
309
+ # Returns the string representation of the object
310
+ # @return [String] String presentation of the object
311
+ def to_s
312
+ to_hash.to_s
313
+ end
314
+
315
+ # to_body is an alias to to_hash (backward compatibility)
316
+ # @return [Hash] Returns the object in the form of hash
317
+ def to_body
318
+ to_hash
319
+ end
320
+
321
+ # Returns the object in the form of hash
322
+ # @return [Hash] Returns the object in the form of hash
323
+ def to_hash
324
+ hash = {}
325
+ self.class.attribute_map.each_pair do |attr, param|
326
+ value = self.send(attr)
327
+ if value.nil?
328
+ is_nullable = self.class.openapi_nullable.include?(attr)
329
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
330
+ end
331
+
332
+ hash[param] = _to_hash(value)
333
+ end
334
+ hash
335
+ end
336
+
337
+ # Outputs non-array value in the form of hash
338
+ # For object, use to_hash. Otherwise, just return the value
339
+ # @param [Object] value Any valid value
340
+ # @return [Hash] Returns the value in the form of hash
341
+ def _to_hash(value)
342
+ if value.is_a?(Array)
343
+ value.compact.map { |v| _to_hash(v) }
344
+ elsif value.is_a?(Hash)
345
+ {}.tap do |hash|
346
+ value.each { |k, v| hash[k] = _to_hash(v) }
347
+ end
348
+ elsif value.respond_to? :to_hash
349
+ value.to_hash
350
+ else
351
+ value
352
+ end
353
+ end
354
+
355
+ end
356
+
357
+ end
@@ -0,0 +1,254 @@
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
+ # The native eth staking context.
18
+ class NativeEthStakingContext
19
+ attr_accessor :stakeable_balance
20
+
21
+ attr_accessor :unstakeable_balance
22
+
23
+ attr_accessor :claimable_balance
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'stakeable_balance' => :'stakeable_balance',
29
+ :'unstakeable_balance' => :'unstakeable_balance',
30
+ :'claimable_balance' => :'claimable_balance'
31
+ }
32
+ end
33
+
34
+ # Returns all the JSON keys this model knows about
35
+ def self.acceptable_attributes
36
+ attribute_map.values
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'stakeable_balance' => :'Balance',
43
+ :'unstakeable_balance' => :'Balance',
44
+ :'claimable_balance' => :'Balance'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::NativeEthStakingContext` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::NativeEthStakingContext`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'stakeable_balance')
70
+ self.stakeable_balance = attributes[:'stakeable_balance']
71
+ else
72
+ self.stakeable_balance = nil
73
+ end
74
+
75
+ if attributes.key?(:'unstakeable_balance')
76
+ self.unstakeable_balance = attributes[:'unstakeable_balance']
77
+ else
78
+ self.unstakeable_balance = nil
79
+ end
80
+
81
+ if attributes.key?(:'claimable_balance')
82
+ self.claimable_balance = attributes[:'claimable_balance']
83
+ else
84
+ self.claimable_balance = nil
85
+ end
86
+ end
87
+
88
+ # Show invalid properties with the reasons. Usually used together with valid?
89
+ # @return Array for valid properties with the reasons
90
+ def list_invalid_properties
91
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
92
+ invalid_properties = Array.new
93
+ if @stakeable_balance.nil?
94
+ invalid_properties.push('invalid value for "stakeable_balance", stakeable_balance cannot be nil.')
95
+ end
96
+
97
+ if @unstakeable_balance.nil?
98
+ invalid_properties.push('invalid value for "unstakeable_balance", unstakeable_balance cannot be nil.')
99
+ end
100
+
101
+ if @claimable_balance.nil?
102
+ invalid_properties.push('invalid value for "claimable_balance", claimable_balance cannot be nil.')
103
+ end
104
+
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ warn '[DEPRECATED] the `valid?` method is obsolete'
112
+ return false if @stakeable_balance.nil?
113
+ return false if @unstakeable_balance.nil?
114
+ return false if @claimable_balance.nil?
115
+ true
116
+ end
117
+
118
+ # Checks equality by comparing each attribute.
119
+ # @param [Object] Object to be compared
120
+ def ==(o)
121
+ return true if self.equal?(o)
122
+ self.class == o.class &&
123
+ stakeable_balance == o.stakeable_balance &&
124
+ unstakeable_balance == o.unstakeable_balance &&
125
+ claimable_balance == o.claimable_balance
126
+ end
127
+
128
+ # @see the `==` method
129
+ # @param [Object] Object to be compared
130
+ def eql?(o)
131
+ self == o
132
+ end
133
+
134
+ # Calculates hash code according to all attributes.
135
+ # @return [Integer] Hash code
136
+ def hash
137
+ [stakeable_balance, unstakeable_balance, claimable_balance].hash
138
+ end
139
+
140
+ # Builds the object from hash
141
+ # @param [Hash] attributes Model attributes in the form of hash
142
+ # @return [Object] Returns the model itself
143
+ def self.build_from_hash(attributes)
144
+ return nil unless attributes.is_a?(Hash)
145
+ attributes = attributes.transform_keys(&:to_sym)
146
+ transformed_hash = {}
147
+ openapi_types.each_pair do |key, type|
148
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
149
+ transformed_hash["#{key}"] = nil
150
+ elsif type =~ /\AArray<(.*)>/i
151
+ # check to ensure the input is an array given that the attribute
152
+ # is documented as an array but the input is not
153
+ if attributes[attribute_map[key]].is_a?(Array)
154
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
155
+ end
156
+ elsif !attributes[attribute_map[key]].nil?
157
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
158
+ end
159
+ end
160
+ new(transformed_hash)
161
+ end
162
+
163
+ # Deserializes the data based on type
164
+ # @param string type Data type
165
+ # @param string value Value to be deserialized
166
+ # @return [Object] Deserialized data
167
+ def self._deserialize(type, value)
168
+ case type.to_sym
169
+ when :Time
170
+ Time.parse(value)
171
+ when :Date
172
+ Date.parse(value)
173
+ when :String
174
+ value.to_s
175
+ when :Integer
176
+ value.to_i
177
+ when :Float
178
+ value.to_f
179
+ when :Boolean
180
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
181
+ true
182
+ else
183
+ false
184
+ end
185
+ when :Object
186
+ # generic object (usually a Hash), return directly
187
+ value
188
+ when /\AArray<(?<inner_type>.+)>\z/
189
+ inner_type = Regexp.last_match[:inner_type]
190
+ value.map { |v| _deserialize(inner_type, v) }
191
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
192
+ k_type = Regexp.last_match[:k_type]
193
+ v_type = Regexp.last_match[:v_type]
194
+ {}.tap do |hash|
195
+ value.each do |k, v|
196
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
197
+ end
198
+ end
199
+ else # model
200
+ # models (e.g. Pet) or oneOf
201
+ klass = Coinbase::Client.const_get(type)
202
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
203
+ end
204
+ end
205
+
206
+ # Returns the string representation of the object
207
+ # @return [String] String presentation of the object
208
+ def to_s
209
+ to_hash.to_s
210
+ end
211
+
212
+ # to_body is an alias to to_hash (backward compatibility)
213
+ # @return [Hash] Returns the object in the form of hash
214
+ def to_body
215
+ to_hash
216
+ end
217
+
218
+ # Returns the object in the form of hash
219
+ # @return [Hash] Returns the object in the form of hash
220
+ def to_hash
221
+ hash = {}
222
+ self.class.attribute_map.each_pair do |attr, param|
223
+ value = self.send(attr)
224
+ if value.nil?
225
+ is_nullable = self.class.openapi_nullable.include?(attr)
226
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
227
+ end
228
+
229
+ hash[param] = _to_hash(value)
230
+ end
231
+ hash
232
+ end
233
+
234
+ # Outputs non-array value in the form of hash
235
+ # For object, use to_hash. Otherwise, just return the value
236
+ # @param [Object] value Any valid value
237
+ # @return [Hash] Returns the value in the form of hash
238
+ def _to_hash(value)
239
+ if value.is_a?(Array)
240
+ value.compact.map { |v| _to_hash(v) }
241
+ elsif value.is_a?(Hash)
242
+ {}.tap do |hash|
243
+ value.each { |k, v| hash[k] = _to_hash(v) }
244
+ end
245
+ elsif value.respond_to? :to_hash
246
+ value.to_hash
247
+ else
248
+ value
249
+ end
250
+ end
251
+
252
+ end
253
+
254
+ end
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Coinbase::Client
17
- # The partial eth staking context
17
+ # The partial eth staking context.
18
18
  class PartialEthStakingContext
19
19
  attr_accessor :stakeable_balance
20
20