coinbase-sdk 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,274 @@
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 GetStakingContextRequest
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 for which the staking context is being fetched
25
+ attr_accessor :address_id
26
+
27
+ attr_accessor :options
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'network_id' => :'network_id',
33
+ :'asset_id' => :'asset_id',
34
+ :'address_id' => :'address_id',
35
+ :'options' => :'options'
36
+ }
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'network_id' => :'String',
48
+ :'asset_id' => :'String',
49
+ :'address_id' => :'String',
50
+ :'options' => :'Hash<String, String>'
51
+ }
52
+ end
53
+
54
+ # List of attributes with nullable: true
55
+ def self.openapi_nullable
56
+ Set.new([
57
+ ])
58
+ end
59
+
60
+ # Initializes the object
61
+ # @param [Hash] attributes Model attributes in the form of hash
62
+ def initialize(attributes = {})
63
+ if (!attributes.is_a?(Hash))
64
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::GetStakingContextRequest` initialize method"
65
+ end
66
+
67
+ # check to see if the attribute exists and convert string to symbol for hash key
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!self.class.attribute_map.key?(k.to_sym))
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::GetStakingContextRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
71
+ end
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:'network_id')
76
+ self.network_id = attributes[:'network_id']
77
+ else
78
+ self.network_id = nil
79
+ end
80
+
81
+ if attributes.key?(:'asset_id')
82
+ self.asset_id = attributes[:'asset_id']
83
+ else
84
+ self.asset_id = nil
85
+ end
86
+
87
+ if attributes.key?(:'address_id')
88
+ self.address_id = attributes[:'address_id']
89
+ else
90
+ self.address_id = nil
91
+ end
92
+
93
+ if attributes.key?(:'options')
94
+ if (value = attributes[:'options']).is_a?(Hash)
95
+ self.options = value
96
+ end
97
+ else
98
+ self.options = nil
99
+ end
100
+ end
101
+
102
+ # Show invalid properties with the reasons. Usually used together with valid?
103
+ # @return Array for valid properties with the reasons
104
+ def list_invalid_properties
105
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
106
+ invalid_properties = Array.new
107
+ if @network_id.nil?
108
+ invalid_properties.push('invalid value for "network_id", network_id cannot be nil.')
109
+ end
110
+
111
+ if @asset_id.nil?
112
+ invalid_properties.push('invalid value for "asset_id", asset_id cannot be nil.')
113
+ end
114
+
115
+ if @address_id.nil?
116
+ invalid_properties.push('invalid value for "address_id", address_id cannot be nil.')
117
+ end
118
+
119
+ if @options.nil?
120
+ invalid_properties.push('invalid value for "options", options cannot be nil.')
121
+ end
122
+
123
+ invalid_properties
124
+ end
125
+
126
+ # Check to see if the all the properties in the model are valid
127
+ # @return true if the model is valid
128
+ def valid?
129
+ warn '[DEPRECATED] the `valid?` method is obsolete'
130
+ return false if @network_id.nil?
131
+ return false if @asset_id.nil?
132
+ return false if @address_id.nil?
133
+ return false if @options.nil?
134
+ true
135
+ end
136
+
137
+ # Checks equality by comparing each attribute.
138
+ # @param [Object] Object to be compared
139
+ def ==(o)
140
+ return true if self.equal?(o)
141
+ self.class == o.class &&
142
+ network_id == o.network_id &&
143
+ asset_id == o.asset_id &&
144
+ address_id == o.address_id &&
145
+ options == o.options
146
+ end
147
+
148
+ # @see the `==` method
149
+ # @param [Object] Object to be compared
150
+ def eql?(o)
151
+ self == o
152
+ end
153
+
154
+ # Calculates hash code according to all attributes.
155
+ # @return [Integer] Hash code
156
+ def hash
157
+ [network_id, asset_id, address_id, options].hash
158
+ end
159
+
160
+ # Builds the object from hash
161
+ # @param [Hash] attributes Model attributes in the form of hash
162
+ # @return [Object] Returns the model itself
163
+ def self.build_from_hash(attributes)
164
+ return nil unless attributes.is_a?(Hash)
165
+ attributes = attributes.transform_keys(&:to_sym)
166
+ transformed_hash = {}
167
+ openapi_types.each_pair do |key, type|
168
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
169
+ transformed_hash["#{key}"] = nil
170
+ elsif type =~ /\AArray<(.*)>/i
171
+ # check to ensure the input is an array given that the attribute
172
+ # is documented as an array but the input is not
173
+ if attributes[attribute_map[key]].is_a?(Array)
174
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
175
+ end
176
+ elsif !attributes[attribute_map[key]].nil?
177
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
178
+ end
179
+ end
180
+ new(transformed_hash)
181
+ end
182
+
183
+ # Deserializes the data based on type
184
+ # @param string type Data type
185
+ # @param string value Value to be deserialized
186
+ # @return [Object] Deserialized data
187
+ def self._deserialize(type, value)
188
+ case type.to_sym
189
+ when :Time
190
+ Time.parse(value)
191
+ when :Date
192
+ Date.parse(value)
193
+ when :String
194
+ value.to_s
195
+ when :Integer
196
+ value.to_i
197
+ when :Float
198
+ value.to_f
199
+ when :Boolean
200
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
201
+ true
202
+ else
203
+ false
204
+ end
205
+ when :Object
206
+ # generic object (usually a Hash), return directly
207
+ value
208
+ when /\AArray<(?<inner_type>.+)>\z/
209
+ inner_type = Regexp.last_match[:inner_type]
210
+ value.map { |v| _deserialize(inner_type, v) }
211
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
212
+ k_type = Regexp.last_match[:k_type]
213
+ v_type = Regexp.last_match[:v_type]
214
+ {}.tap do |hash|
215
+ value.each do |k, v|
216
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
217
+ end
218
+ end
219
+ else # model
220
+ # models (e.g. Pet) or oneOf
221
+ klass = Coinbase::Client.const_get(type)
222
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
223
+ end
224
+ end
225
+
226
+ # Returns the string representation of the object
227
+ # @return [String] String presentation of the object
228
+ def to_s
229
+ to_hash.to_s
230
+ end
231
+
232
+ # to_body is an alias to to_hash (backward compatibility)
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_body
235
+ to_hash
236
+ end
237
+
238
+ # Returns the object in the form of hash
239
+ # @return [Hash] Returns the object in the form of hash
240
+ def to_hash
241
+ hash = {}
242
+ self.class.attribute_map.each_pair do |attr, param|
243
+ value = self.send(attr)
244
+ if value.nil?
245
+ is_nullable = self.class.openapi_nullable.include?(attr)
246
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
247
+ end
248
+
249
+ hash[param] = _to_hash(value)
250
+ end
251
+ hash
252
+ end
253
+
254
+ # Outputs non-array value in the form of hash
255
+ # For object, use to_hash. Otherwise, just return the value
256
+ # @param [Object] value Any valid value
257
+ # @return [Hash] Returns the value in the form of hash
258
+ def _to_hash(value)
259
+ if value.is_a?(Array)
260
+ value.compact.map { |v| _to_hash(v) }
261
+ elsif value.is_a?(Hash)
262
+ {}.tap do |hash|
263
+ value.each { |k, v| hash[k] = _to_hash(v) }
264
+ end
265
+ elsif value.respond_to? :to_hash
266
+ value.to_hash
267
+ else
268
+ value
269
+ end
270
+ end
271
+
272
+ end
273
+
274
+ end
@@ -0,0 +1,257 @@
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
+ # The partial eth staking context
18
+ class PartialEthStakingContext
19
+ # The balance that can be staked. This is typically the wallet balance in atomic units.
20
+ attr_accessor :stakeable_balance
21
+
22
+ # The total staked balance of the wallet that can be unstaked in atomic units.
23
+ attr_accessor :unstakeable_balance
24
+
25
+ # The total unstaked balance that can be claimed in atomic units.
26
+ attr_accessor :claimable_balance
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'stakeable_balance' => :'stakeable_balance',
32
+ :'unstakeable_balance' => :'unstakeable_balance',
33
+ :'claimable_balance' => :'claimable_balance'
34
+ }
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'stakeable_balance' => :'String',
46
+ :'unstakeable_balance' => :'String',
47
+ :'claimable_balance' => :'String'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::PartialEthStakingContext` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::PartialEthStakingContext`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'stakeable_balance')
73
+ self.stakeable_balance = attributes[:'stakeable_balance']
74
+ else
75
+ self.stakeable_balance = nil
76
+ end
77
+
78
+ if attributes.key?(:'unstakeable_balance')
79
+ self.unstakeable_balance = attributes[:'unstakeable_balance']
80
+ else
81
+ self.unstakeable_balance = nil
82
+ end
83
+
84
+ if attributes.key?(:'claimable_balance')
85
+ self.claimable_balance = attributes[:'claimable_balance']
86
+ else
87
+ self.claimable_balance = nil
88
+ end
89
+ end
90
+
91
+ # Show invalid properties with the reasons. Usually used together with valid?
92
+ # @return Array for valid properties with the reasons
93
+ def list_invalid_properties
94
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
95
+ invalid_properties = Array.new
96
+ if @stakeable_balance.nil?
97
+ invalid_properties.push('invalid value for "stakeable_balance", stakeable_balance cannot be nil.')
98
+ end
99
+
100
+ if @unstakeable_balance.nil?
101
+ invalid_properties.push('invalid value for "unstakeable_balance", unstakeable_balance cannot be nil.')
102
+ end
103
+
104
+ if @claimable_balance.nil?
105
+ invalid_properties.push('invalid value for "claimable_balance", claimable_balance cannot be nil.')
106
+ end
107
+
108
+ invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ warn '[DEPRECATED] the `valid?` method is obsolete'
115
+ return false if @stakeable_balance.nil?
116
+ return false if @unstakeable_balance.nil?
117
+ return false if @claimable_balance.nil?
118
+ true
119
+ end
120
+
121
+ # Checks equality by comparing each attribute.
122
+ # @param [Object] Object to be compared
123
+ def ==(o)
124
+ return true if self.equal?(o)
125
+ self.class == o.class &&
126
+ stakeable_balance == o.stakeable_balance &&
127
+ unstakeable_balance == o.unstakeable_balance &&
128
+ claimable_balance == o.claimable_balance
129
+ end
130
+
131
+ # @see the `==` method
132
+ # @param [Object] Object to be compared
133
+ def eql?(o)
134
+ self == o
135
+ end
136
+
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Integer] Hash code
139
+ def hash
140
+ [stakeable_balance, unstakeable_balance, claimable_balance].hash
141
+ end
142
+
143
+ # Builds the object from hash
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ # @return [Object] Returns the model itself
146
+ def self.build_from_hash(attributes)
147
+ return nil unless attributes.is_a?(Hash)
148
+ attributes = attributes.transform_keys(&:to_sym)
149
+ transformed_hash = {}
150
+ openapi_types.each_pair do |key, type|
151
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
152
+ transformed_hash["#{key}"] = nil
153
+ elsif type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[attribute_map[key]].is_a?(Array)
157
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
158
+ end
159
+ elsif !attributes[attribute_map[key]].nil?
160
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
161
+ end
162
+ end
163
+ new(transformed_hash)
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def self._deserialize(type, value)
171
+ case type.to_sym
172
+ when :Time
173
+ Time.parse(value)
174
+ when :Date
175
+ Date.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :Boolean
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ # models (e.g. Pet) or oneOf
204
+ klass = Coinbase::Client.const_get(type)
205
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = self.send(attr)
227
+ if value.nil?
228
+ is_nullable = self.class.openapi_nullable.include?(attr)
229
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
230
+ end
231
+
232
+ hash[param] = _to_hash(value)
233
+ end
234
+ hash
235
+ end
236
+
237
+ # Outputs non-array value in the form of hash
238
+ # For object, use to_hash. Otherwise, just return the value
239
+ # @param [Object] value Any valid value
240
+ # @return [Hash] Returns the value in the form of hash
241
+ def _to_hash(value)
242
+ if value.is_a?(Array)
243
+ value.compact.map { |v| _to_hash(v) }
244
+ elsif value.is_a?(Hash)
245
+ {}.tap do |hash|
246
+ value.each { |k, v| hash[k] = _to_hash(v) }
247
+ end
248
+ elsif value.respond_to? :to_hash
249
+ value.to_hash
250
+ else
251
+ value
252
+ end
253
+ end
254
+
255
+ end
256
+
257
+ end