coinbase-sdk 0.0.14 → 0.1.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 +31 -21
- data/lib/coinbase/address.rb +51 -17
- data/lib/coinbase/asset.rb +11 -8
- data/lib/coinbase/client/api/contract_events_api.rb +17 -9
- data/lib/coinbase/client/api/external_addresses_api.rb +85 -0
- data/lib/coinbase/client/api/networks_api.rb +85 -0
- data/lib/coinbase/client/api/stake_api.rb +74 -195
- data/lib/coinbase/client/api/validators_api.rb +2 -2
- data/lib/coinbase/client/api/wallet_stake_api.rb +263 -0
- data/lib/coinbase/client/models/address.rb +21 -4
- data/lib/coinbase/client/models/{native_eth_staking_context.rb → address_historical_balance_list.rb} +39 -35
- data/lib/coinbase/client/models/contract_event.rb +99 -8
- data/lib/coinbase/client/models/create_address_request.rb +14 -4
- data/lib/coinbase/client/models/create_transfer_request.rb +14 -4
- data/lib/coinbase/client/models/ethereum_validator_metadata.rb +11 -11
- data/lib/coinbase/client/models/feature.rb +2 -1
- data/lib/coinbase/client/models/feature_set.rb +307 -0
- data/lib/coinbase/client/models/{partial_eth_staking_context.rb → fetch_historical_staking_balances200_response.rb} +39 -35
- data/lib/coinbase/client/models/historical_balance.rb +273 -0
- data/lib/coinbase/client/models/network.rb +365 -0
- data/lib/coinbase/client/models/network_identifier.rb +44 -0
- data/lib/coinbase/client/models/sponsored_send.rb +338 -0
- data/lib/coinbase/client/models/staking_balance.rb +289 -0
- data/lib/coinbase/client/models/staking_context_context.rb +222 -74
- data/lib/coinbase/client/models/staking_operation.rb +2 -2
- data/lib/coinbase/client/models/staking_reward.rb +22 -6
- data/lib/coinbase/client/models/staking_reward_format.rb +2 -1
- data/lib/coinbase/client/models/staking_reward_usd_value.rb +257 -0
- data/lib/coinbase/client/models/transaction.rb +17 -7
- data/lib/coinbase/client/models/transaction_type.rb +2 -1
- data/lib/coinbase/client/models/transfer.rb +101 -8
- data/lib/coinbase/client/models/validator.rb +23 -2
- data/lib/coinbase/client/models/validator_status.rb +52 -0
- data/lib/coinbase/client/models/wallet.rb +13 -16
- data/lib/coinbase/client/models/webhook_event_type.rb +2 -1
- data/lib/coinbase/client.rb +12 -3
- data/lib/coinbase/constants.rb +0 -10
- data/lib/coinbase/contract_event.rb +104 -0
- data/lib/coinbase/correlation.rb +30 -0
- data/lib/coinbase/destination.rb +11 -9
- data/lib/coinbase/errors.rb +14 -0
- data/lib/coinbase/historical_balance.rb +53 -0
- data/lib/coinbase/middleware.rb +2 -0
- data/lib/coinbase/network.rb +103 -20
- data/lib/coinbase/server_signer.rb +14 -3
- data/lib/coinbase/smart_contract.rb +106 -0
- data/lib/coinbase/sponsored_send.rb +110 -0
- data/lib/coinbase/staking_balance.rb +92 -0
- data/lib/coinbase/staking_operation.rb +134 -36
- data/lib/coinbase/staking_reward.rb +18 -0
- data/lib/coinbase/trade.rb +10 -9
- data/lib/coinbase/transaction.rb +13 -3
- data/lib/coinbase/transfer.rb +65 -36
- data/lib/coinbase/validator.rb +18 -10
- data/lib/coinbase/version.rb +5 -0
- data/lib/coinbase/wallet/data.rb +31 -0
- data/lib/coinbase/wallet.rb +143 -182
- data/lib/coinbase/webhook.rb +181 -0
- data/lib/coinbase.rb +64 -21
- metadata +51 -5
- data/lib/coinbase/user.rb +0 -65
@@ -0,0 +1,273 @@
|
|
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
|
+
# The balance of an asset onchain at a particular block
|
18
|
+
class HistoricalBalance
|
19
|
+
# The amount in the atomic units of the asset
|
20
|
+
attr_accessor :amount
|
21
|
+
|
22
|
+
# The hash of the block at which the balance was recorded
|
23
|
+
attr_accessor :block_hash
|
24
|
+
|
25
|
+
# The block height at which the balance was recorded
|
26
|
+
attr_accessor :block_height
|
27
|
+
|
28
|
+
attr_accessor :asset
|
29
|
+
|
30
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
31
|
+
def self.attribute_map
|
32
|
+
{
|
33
|
+
:'amount' => :'amount',
|
34
|
+
:'block_hash' => :'block_hash',
|
35
|
+
:'block_height' => :'block_height',
|
36
|
+
:'asset' => :'asset'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns all the JSON keys this model knows about
|
41
|
+
def self.acceptable_attributes
|
42
|
+
attribute_map.values
|
43
|
+
end
|
44
|
+
|
45
|
+
# Attribute type mapping.
|
46
|
+
def self.openapi_types
|
47
|
+
{
|
48
|
+
:'amount' => :'String',
|
49
|
+
:'block_hash' => :'String',
|
50
|
+
:'block_height' => :'String',
|
51
|
+
:'asset' => :'Asset'
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# List of attributes with nullable: true
|
56
|
+
def self.openapi_nullable
|
57
|
+
Set.new([
|
58
|
+
])
|
59
|
+
end
|
60
|
+
|
61
|
+
# Initializes the object
|
62
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
63
|
+
def initialize(attributes = {})
|
64
|
+
if (!attributes.is_a?(Hash))
|
65
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::HistoricalBalance` initialize method"
|
66
|
+
end
|
67
|
+
|
68
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
69
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
70
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
71
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::HistoricalBalance`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
72
|
+
end
|
73
|
+
h[k.to_sym] = v
|
74
|
+
}
|
75
|
+
|
76
|
+
if attributes.key?(:'amount')
|
77
|
+
self.amount = attributes[:'amount']
|
78
|
+
else
|
79
|
+
self.amount = nil
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.key?(:'block_hash')
|
83
|
+
self.block_hash = attributes[:'block_hash']
|
84
|
+
else
|
85
|
+
self.block_hash = nil
|
86
|
+
end
|
87
|
+
|
88
|
+
if attributes.key?(:'block_height')
|
89
|
+
self.block_height = attributes[:'block_height']
|
90
|
+
else
|
91
|
+
self.block_height = nil
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'asset')
|
95
|
+
self.asset = attributes[:'asset']
|
96
|
+
else
|
97
|
+
self.asset = nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
102
|
+
# @return Array for valid properties with the reasons
|
103
|
+
def list_invalid_properties
|
104
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
105
|
+
invalid_properties = Array.new
|
106
|
+
if @amount.nil?
|
107
|
+
invalid_properties.push('invalid value for "amount", amount cannot be nil.')
|
108
|
+
end
|
109
|
+
|
110
|
+
if @block_hash.nil?
|
111
|
+
invalid_properties.push('invalid value for "block_hash", block_hash cannot be nil.')
|
112
|
+
end
|
113
|
+
|
114
|
+
if @block_height.nil?
|
115
|
+
invalid_properties.push('invalid value for "block_height", block_height cannot be nil.')
|
116
|
+
end
|
117
|
+
|
118
|
+
if @asset.nil?
|
119
|
+
invalid_properties.push('invalid value for "asset", asset cannot be nil.')
|
120
|
+
end
|
121
|
+
|
122
|
+
invalid_properties
|
123
|
+
end
|
124
|
+
|
125
|
+
# Check to see if the all the properties in the model are valid
|
126
|
+
# @return true if the model is valid
|
127
|
+
def valid?
|
128
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
129
|
+
return false if @amount.nil?
|
130
|
+
return false if @block_hash.nil?
|
131
|
+
return false if @block_height.nil?
|
132
|
+
return false if @asset.nil?
|
133
|
+
true
|
134
|
+
end
|
135
|
+
|
136
|
+
# Checks equality by comparing each attribute.
|
137
|
+
# @param [Object] Object to be compared
|
138
|
+
def ==(o)
|
139
|
+
return true if self.equal?(o)
|
140
|
+
self.class == o.class &&
|
141
|
+
amount == o.amount &&
|
142
|
+
block_hash == o.block_hash &&
|
143
|
+
block_height == o.block_height &&
|
144
|
+
asset == o.asset
|
145
|
+
end
|
146
|
+
|
147
|
+
# @see the `==` method
|
148
|
+
# @param [Object] Object to be compared
|
149
|
+
def eql?(o)
|
150
|
+
self == o
|
151
|
+
end
|
152
|
+
|
153
|
+
# Calculates hash code according to all attributes.
|
154
|
+
# @return [Integer] Hash code
|
155
|
+
def hash
|
156
|
+
[amount, block_hash, block_height, asset].hash
|
157
|
+
end
|
158
|
+
|
159
|
+
# Builds the object from hash
|
160
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
161
|
+
# @return [Object] Returns the model itself
|
162
|
+
def self.build_from_hash(attributes)
|
163
|
+
return nil unless attributes.is_a?(Hash)
|
164
|
+
attributes = attributes.transform_keys(&:to_sym)
|
165
|
+
transformed_hash = {}
|
166
|
+
openapi_types.each_pair do |key, type|
|
167
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
168
|
+
transformed_hash["#{key}"] = nil
|
169
|
+
elsif type =~ /\AArray<(.*)>/i
|
170
|
+
# check to ensure the input is an array given that the attribute
|
171
|
+
# is documented as an array but the input is not
|
172
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
173
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
174
|
+
end
|
175
|
+
elsif !attributes[attribute_map[key]].nil?
|
176
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
177
|
+
end
|
178
|
+
end
|
179
|
+
new(transformed_hash)
|
180
|
+
end
|
181
|
+
|
182
|
+
# Deserializes the data based on type
|
183
|
+
# @param string type Data type
|
184
|
+
# @param string value Value to be deserialized
|
185
|
+
# @return [Object] Deserialized data
|
186
|
+
def self._deserialize(type, value)
|
187
|
+
case type.to_sym
|
188
|
+
when :Time
|
189
|
+
Time.parse(value)
|
190
|
+
when :Date
|
191
|
+
Date.parse(value)
|
192
|
+
when :String
|
193
|
+
value.to_s
|
194
|
+
when :Integer
|
195
|
+
value.to_i
|
196
|
+
when :Float
|
197
|
+
value.to_f
|
198
|
+
when :Boolean
|
199
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
200
|
+
true
|
201
|
+
else
|
202
|
+
false
|
203
|
+
end
|
204
|
+
when :Object
|
205
|
+
# generic object (usually a Hash), return directly
|
206
|
+
value
|
207
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
208
|
+
inner_type = Regexp.last_match[:inner_type]
|
209
|
+
value.map { |v| _deserialize(inner_type, v) }
|
210
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
211
|
+
k_type = Regexp.last_match[:k_type]
|
212
|
+
v_type = Regexp.last_match[:v_type]
|
213
|
+
{}.tap do |hash|
|
214
|
+
value.each do |k, v|
|
215
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
else # model
|
219
|
+
# models (e.g. Pet) or oneOf
|
220
|
+
klass = Coinbase::Client.const_get(type)
|
221
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
# Returns the string representation of the object
|
226
|
+
# @return [String] String presentation of the object
|
227
|
+
def to_s
|
228
|
+
to_hash.to_s
|
229
|
+
end
|
230
|
+
|
231
|
+
# to_body is an alias to to_hash (backward compatibility)
|
232
|
+
# @return [Hash] Returns the object in the form of hash
|
233
|
+
def to_body
|
234
|
+
to_hash
|
235
|
+
end
|
236
|
+
|
237
|
+
# Returns the object in the form of hash
|
238
|
+
# @return [Hash] Returns the object in the form of hash
|
239
|
+
def to_hash
|
240
|
+
hash = {}
|
241
|
+
self.class.attribute_map.each_pair do |attr, param|
|
242
|
+
value = self.send(attr)
|
243
|
+
if value.nil?
|
244
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
245
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
246
|
+
end
|
247
|
+
|
248
|
+
hash[param] = _to_hash(value)
|
249
|
+
end
|
250
|
+
hash
|
251
|
+
end
|
252
|
+
|
253
|
+
# Outputs non-array value in the form of hash
|
254
|
+
# For object, use to_hash. Otherwise, just return the value
|
255
|
+
# @param [Object] value Any valid value
|
256
|
+
# @return [Hash] Returns the value in the form of hash
|
257
|
+
def _to_hash(value)
|
258
|
+
if value.is_a?(Array)
|
259
|
+
value.compact.map { |v| _to_hash(v) }
|
260
|
+
elsif value.is_a?(Hash)
|
261
|
+
{}.tap do |hash|
|
262
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
263
|
+
end
|
264
|
+
elsif value.respond_to? :to_hash
|
265
|
+
value.to_hash
|
266
|
+
else
|
267
|
+
value
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
272
|
+
|
273
|
+
end
|
@@ -0,0 +1,365 @@
|
|
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 Network
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
# The human-readable name of the blockchain network
|
21
|
+
attr_accessor :display_name
|
22
|
+
|
23
|
+
# The chain ID of the blockchain network
|
24
|
+
attr_accessor :chain_id
|
25
|
+
|
26
|
+
# The protocol family of the blockchain network
|
27
|
+
attr_accessor :protocol_family
|
28
|
+
|
29
|
+
# Whether the network is a testnet or not
|
30
|
+
attr_accessor :is_testnet
|
31
|
+
|
32
|
+
attr_accessor :native_asset
|
33
|
+
|
34
|
+
attr_accessor :feature_set
|
35
|
+
|
36
|
+
# The BIP44 path prefix for the network
|
37
|
+
attr_accessor :address_path_prefix
|
38
|
+
|
39
|
+
class EnumAttributeValidator
|
40
|
+
attr_reader :datatype
|
41
|
+
attr_reader :allowable_values
|
42
|
+
|
43
|
+
def initialize(datatype, allowable_values)
|
44
|
+
@allowable_values = allowable_values.map do |value|
|
45
|
+
case datatype.to_s
|
46
|
+
when /Integer/i
|
47
|
+
value.to_i
|
48
|
+
when /Float/i
|
49
|
+
value.to_f
|
50
|
+
else
|
51
|
+
value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def valid?(value)
|
57
|
+
!value || allowable_values.include?(value)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
62
|
+
def self.attribute_map
|
63
|
+
{
|
64
|
+
:'id' => :'id',
|
65
|
+
:'display_name' => :'display_name',
|
66
|
+
:'chain_id' => :'chain_id',
|
67
|
+
:'protocol_family' => :'protocol_family',
|
68
|
+
:'is_testnet' => :'is_testnet',
|
69
|
+
:'native_asset' => :'native_asset',
|
70
|
+
:'feature_set' => :'feature_set',
|
71
|
+
:'address_path_prefix' => :'address_path_prefix'
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
# Returns all the JSON keys this model knows about
|
76
|
+
def self.acceptable_attributes
|
77
|
+
attribute_map.values
|
78
|
+
end
|
79
|
+
|
80
|
+
# Attribute type mapping.
|
81
|
+
def self.openapi_types
|
82
|
+
{
|
83
|
+
:'id' => :'NetworkIdentifier',
|
84
|
+
:'display_name' => :'String',
|
85
|
+
:'chain_id' => :'Integer',
|
86
|
+
:'protocol_family' => :'String',
|
87
|
+
:'is_testnet' => :'Boolean',
|
88
|
+
:'native_asset' => :'Asset',
|
89
|
+
:'feature_set' => :'FeatureSet',
|
90
|
+
:'address_path_prefix' => :'String'
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
# List of attributes with nullable: true
|
95
|
+
def self.openapi_nullable
|
96
|
+
Set.new([
|
97
|
+
])
|
98
|
+
end
|
99
|
+
|
100
|
+
# Initializes the object
|
101
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
102
|
+
def initialize(attributes = {})
|
103
|
+
if (!attributes.is_a?(Hash))
|
104
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::Network` initialize method"
|
105
|
+
end
|
106
|
+
|
107
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
108
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
109
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
110
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::Network`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
111
|
+
end
|
112
|
+
h[k.to_sym] = v
|
113
|
+
}
|
114
|
+
|
115
|
+
if attributes.key?(:'id')
|
116
|
+
self.id = attributes[:'id']
|
117
|
+
else
|
118
|
+
self.id = nil
|
119
|
+
end
|
120
|
+
|
121
|
+
if attributes.key?(:'display_name')
|
122
|
+
self.display_name = attributes[:'display_name']
|
123
|
+
else
|
124
|
+
self.display_name = nil
|
125
|
+
end
|
126
|
+
|
127
|
+
if attributes.key?(:'chain_id')
|
128
|
+
self.chain_id = attributes[:'chain_id']
|
129
|
+
else
|
130
|
+
self.chain_id = nil
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.key?(:'protocol_family')
|
134
|
+
self.protocol_family = attributes[:'protocol_family']
|
135
|
+
else
|
136
|
+
self.protocol_family = nil
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.key?(:'is_testnet')
|
140
|
+
self.is_testnet = attributes[:'is_testnet']
|
141
|
+
else
|
142
|
+
self.is_testnet = nil
|
143
|
+
end
|
144
|
+
|
145
|
+
if attributes.key?(:'native_asset')
|
146
|
+
self.native_asset = attributes[:'native_asset']
|
147
|
+
else
|
148
|
+
self.native_asset = nil
|
149
|
+
end
|
150
|
+
|
151
|
+
if attributes.key?(:'feature_set')
|
152
|
+
self.feature_set = attributes[:'feature_set']
|
153
|
+
else
|
154
|
+
self.feature_set = nil
|
155
|
+
end
|
156
|
+
|
157
|
+
if attributes.key?(:'address_path_prefix')
|
158
|
+
self.address_path_prefix = attributes[:'address_path_prefix']
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
163
|
+
# @return Array for valid properties with the reasons
|
164
|
+
def list_invalid_properties
|
165
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
166
|
+
invalid_properties = Array.new
|
167
|
+
if @id.nil?
|
168
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
169
|
+
end
|
170
|
+
|
171
|
+
if @display_name.nil?
|
172
|
+
invalid_properties.push('invalid value for "display_name", display_name cannot be nil.')
|
173
|
+
end
|
174
|
+
|
175
|
+
if @chain_id.nil?
|
176
|
+
invalid_properties.push('invalid value for "chain_id", chain_id cannot be nil.')
|
177
|
+
end
|
178
|
+
|
179
|
+
if @protocol_family.nil?
|
180
|
+
invalid_properties.push('invalid value for "protocol_family", protocol_family cannot be nil.')
|
181
|
+
end
|
182
|
+
|
183
|
+
if @is_testnet.nil?
|
184
|
+
invalid_properties.push('invalid value for "is_testnet", is_testnet cannot be nil.')
|
185
|
+
end
|
186
|
+
|
187
|
+
if @native_asset.nil?
|
188
|
+
invalid_properties.push('invalid value for "native_asset", native_asset cannot be nil.')
|
189
|
+
end
|
190
|
+
|
191
|
+
if @feature_set.nil?
|
192
|
+
invalid_properties.push('invalid value for "feature_set", feature_set cannot be nil.')
|
193
|
+
end
|
194
|
+
|
195
|
+
invalid_properties
|
196
|
+
end
|
197
|
+
|
198
|
+
# Check to see if the all the properties in the model are valid
|
199
|
+
# @return true if the model is valid
|
200
|
+
def valid?
|
201
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
202
|
+
return false if @id.nil?
|
203
|
+
return false if @display_name.nil?
|
204
|
+
return false if @chain_id.nil?
|
205
|
+
return false if @protocol_family.nil?
|
206
|
+
protocol_family_validator = EnumAttributeValidator.new('String', ["evm", "unknown_default_open_api"])
|
207
|
+
return false unless protocol_family_validator.valid?(@protocol_family)
|
208
|
+
return false if @is_testnet.nil?
|
209
|
+
return false if @native_asset.nil?
|
210
|
+
return false if @feature_set.nil?
|
211
|
+
true
|
212
|
+
end
|
213
|
+
|
214
|
+
# Custom attribute writer method checking allowed values (enum).
|
215
|
+
# @param [Object] protocol_family Object to be assigned
|
216
|
+
def protocol_family=(protocol_family)
|
217
|
+
validator = EnumAttributeValidator.new('String', ["evm", "unknown_default_open_api"])
|
218
|
+
unless validator.valid?(protocol_family)
|
219
|
+
fail ArgumentError, "invalid value for \"protocol_family\", must be one of #{validator.allowable_values}."
|
220
|
+
end
|
221
|
+
@protocol_family = protocol_family
|
222
|
+
end
|
223
|
+
|
224
|
+
# Checks equality by comparing each attribute.
|
225
|
+
# @param [Object] Object to be compared
|
226
|
+
def ==(o)
|
227
|
+
return true if self.equal?(o)
|
228
|
+
self.class == o.class &&
|
229
|
+
id == o.id &&
|
230
|
+
display_name == o.display_name &&
|
231
|
+
chain_id == o.chain_id &&
|
232
|
+
protocol_family == o.protocol_family &&
|
233
|
+
is_testnet == o.is_testnet &&
|
234
|
+
native_asset == o.native_asset &&
|
235
|
+
feature_set == o.feature_set &&
|
236
|
+
address_path_prefix == o.address_path_prefix
|
237
|
+
end
|
238
|
+
|
239
|
+
# @see the `==` method
|
240
|
+
# @param [Object] Object to be compared
|
241
|
+
def eql?(o)
|
242
|
+
self == o
|
243
|
+
end
|
244
|
+
|
245
|
+
# Calculates hash code according to all attributes.
|
246
|
+
# @return [Integer] Hash code
|
247
|
+
def hash
|
248
|
+
[id, display_name, chain_id, protocol_family, is_testnet, native_asset, feature_set, address_path_prefix].hash
|
249
|
+
end
|
250
|
+
|
251
|
+
# Builds the object from hash
|
252
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
253
|
+
# @return [Object] Returns the model itself
|
254
|
+
def self.build_from_hash(attributes)
|
255
|
+
return nil unless attributes.is_a?(Hash)
|
256
|
+
attributes = attributes.transform_keys(&:to_sym)
|
257
|
+
transformed_hash = {}
|
258
|
+
openapi_types.each_pair do |key, type|
|
259
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
260
|
+
transformed_hash["#{key}"] = nil
|
261
|
+
elsif type =~ /\AArray<(.*)>/i
|
262
|
+
# check to ensure the input is an array given that the attribute
|
263
|
+
# is documented as an array but the input is not
|
264
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
265
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
266
|
+
end
|
267
|
+
elsif !attributes[attribute_map[key]].nil?
|
268
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
269
|
+
end
|
270
|
+
end
|
271
|
+
new(transformed_hash)
|
272
|
+
end
|
273
|
+
|
274
|
+
# Deserializes the data based on type
|
275
|
+
# @param string type Data type
|
276
|
+
# @param string value Value to be deserialized
|
277
|
+
# @return [Object] Deserialized data
|
278
|
+
def self._deserialize(type, value)
|
279
|
+
case type.to_sym
|
280
|
+
when :Time
|
281
|
+
Time.parse(value)
|
282
|
+
when :Date
|
283
|
+
Date.parse(value)
|
284
|
+
when :String
|
285
|
+
value.to_s
|
286
|
+
when :Integer
|
287
|
+
value.to_i
|
288
|
+
when :Float
|
289
|
+
value.to_f
|
290
|
+
when :Boolean
|
291
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
292
|
+
true
|
293
|
+
else
|
294
|
+
false
|
295
|
+
end
|
296
|
+
when :Object
|
297
|
+
# generic object (usually a Hash), return directly
|
298
|
+
value
|
299
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
300
|
+
inner_type = Regexp.last_match[:inner_type]
|
301
|
+
value.map { |v| _deserialize(inner_type, v) }
|
302
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
303
|
+
k_type = Regexp.last_match[:k_type]
|
304
|
+
v_type = Regexp.last_match[:v_type]
|
305
|
+
{}.tap do |hash|
|
306
|
+
value.each do |k, v|
|
307
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
else # model
|
311
|
+
# models (e.g. Pet) or oneOf
|
312
|
+
klass = Coinbase::Client.const_get(type)
|
313
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
# Returns the string representation of the object
|
318
|
+
# @return [String] String presentation of the object
|
319
|
+
def to_s
|
320
|
+
to_hash.to_s
|
321
|
+
end
|
322
|
+
|
323
|
+
# to_body is an alias to to_hash (backward compatibility)
|
324
|
+
# @return [Hash] Returns the object in the form of hash
|
325
|
+
def to_body
|
326
|
+
to_hash
|
327
|
+
end
|
328
|
+
|
329
|
+
# Returns the object in the form of hash
|
330
|
+
# @return [Hash] Returns the object in the form of hash
|
331
|
+
def to_hash
|
332
|
+
hash = {}
|
333
|
+
self.class.attribute_map.each_pair do |attr, param|
|
334
|
+
value = self.send(attr)
|
335
|
+
if value.nil?
|
336
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
337
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
338
|
+
end
|
339
|
+
|
340
|
+
hash[param] = _to_hash(value)
|
341
|
+
end
|
342
|
+
hash
|
343
|
+
end
|
344
|
+
|
345
|
+
# Outputs non-array value in the form of hash
|
346
|
+
# For object, use to_hash. Otherwise, just return the value
|
347
|
+
# @param [Object] value Any valid value
|
348
|
+
# @return [Hash] Returns the value in the form of hash
|
349
|
+
def _to_hash(value)
|
350
|
+
if value.is_a?(Array)
|
351
|
+
value.compact.map { |v| _to_hash(v) }
|
352
|
+
elsif value.is_a?(Hash)
|
353
|
+
{}.tap do |hash|
|
354
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
355
|
+
end
|
356
|
+
elsif value.respond_to? :to_hash
|
357
|
+
value.to_hash
|
358
|
+
else
|
359
|
+
value
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
end
|
364
|
+
|
365
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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 NetworkIdentifier
|
18
|
+
BASE_SEPOLIA = "base-sepolia".freeze
|
19
|
+
BASE_MAINNET = "base-mainnet".freeze
|
20
|
+
ETHEREUM_HOLESKY = "ethereum-holesky".freeze
|
21
|
+
ETHEREUM_MAINNET = "ethereum-mainnet".freeze
|
22
|
+
POLYGON_MAINNET = "polygon-mainnet".freeze
|
23
|
+
UNKNOWN_DEFAULT_OPEN_API = "unknown_default_open_api".freeze
|
24
|
+
|
25
|
+
def self.all_vars
|
26
|
+
@all_vars ||= [BASE_SEPOLIA, BASE_MAINNET, ETHEREUM_HOLESKY, ETHEREUM_MAINNET, POLYGON_MAINNET, UNKNOWN_DEFAULT_OPEN_API].freeze
|
27
|
+
end
|
28
|
+
|
29
|
+
# Builds the enum from string
|
30
|
+
# @param [String] The enum value in the form of the string
|
31
|
+
# @return [String] The enum value
|
32
|
+
def self.build_from_hash(value)
|
33
|
+
new.build_from_hash(value)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Builds the enum from string
|
37
|
+
# @param [String] The enum value in the form of the string
|
38
|
+
# @return [String] The enum value
|
39
|
+
def build_from_hash(value)
|
40
|
+
return value if NetworkIdentifier.all_vars.include?(value)
|
41
|
+
raise "Invalid ENUM value #{value} for class #NetworkIdentifier"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|