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.
- checksums.yaml +4 -4
- data/lib/coinbase/address.rb +20 -20
- data/lib/coinbase/asset.rb +76 -66
- 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/stake_api.rb +156 -6
- data/lib/coinbase/client/api/transfer_api.rb +114 -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/staking_context.rb +222 -0
- data/lib/coinbase/client/models/staking_context_context.rb +104 -0
- data/lib/coinbase/client/models/staking_reward.rb +308 -0
- data/lib/coinbase/client.rb +9 -0
- data/lib/coinbase/constants.rb +2 -27
- data/lib/coinbase/errors.rb +49 -64
- data/lib/coinbase/network.rb +6 -20
- data/lib/coinbase/wallet.rb +2 -2
- data/lib/coinbase.rb +8 -11
- metadata +13 -2
@@ -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
|
+
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
|
+
# Context needed to perform a staking operation
|
18
|
+
class StakingContext
|
19
|
+
attr_accessor :context
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'context' => :'context'
|
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
|
+
:'context' => :'StakingContextContext'
|
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::StakingContext` 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::StakingContext`. 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?(:'context')
|
62
|
+
self.context = attributes[:'context']
|
63
|
+
else
|
64
|
+
self.context = 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 @context.nil?
|
74
|
+
invalid_properties.push('invalid value for "context", context 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 @context.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
|
+
context == o.context
|
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
|
+
[context].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
|
@@ -0,0 +1,104 @@
|
|
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
|
+
module StakingContextContext
|
18
|
+
class << self
|
19
|
+
# List of class defined in oneOf (OpenAPI v3)
|
20
|
+
def openapi_one_of
|
21
|
+
[
|
22
|
+
:'PartialEthStakingContext'
|
23
|
+
]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Builds the object
|
27
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
28
|
+
# @return [Object] Returns the model or the data itself
|
29
|
+
def build(data)
|
30
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
31
|
+
# Note:
|
32
|
+
# - We do not attempt to check whether exactly one item matches.
|
33
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
34
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
35
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
36
|
+
# - TODO: logging when debugging is set.
|
37
|
+
openapi_one_of.each do |klass|
|
38
|
+
begin
|
39
|
+
next if klass == :AnyType # "nullable: true"
|
40
|
+
typed_data = find_and_cast_into_type(klass, data)
|
41
|
+
return typed_data if typed_data
|
42
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
SchemaMismatchError = Class.new(StandardError)
|
52
|
+
|
53
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
54
|
+
def find_and_cast_into_type(klass, data)
|
55
|
+
return if data.nil?
|
56
|
+
|
57
|
+
case klass.to_s
|
58
|
+
when 'Boolean'
|
59
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
60
|
+
when 'Float'
|
61
|
+
return data if data.instance_of?(Float)
|
62
|
+
when 'Integer'
|
63
|
+
return data if data.instance_of?(Integer)
|
64
|
+
when 'Time'
|
65
|
+
return Time.parse(data)
|
66
|
+
when 'Date'
|
67
|
+
return Date.parse(data)
|
68
|
+
when 'String'
|
69
|
+
return data if data.instance_of?(String)
|
70
|
+
when 'Object' # "type: object"
|
71
|
+
return data if data.instance_of?(Hash)
|
72
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
73
|
+
if data.instance_of?(Array)
|
74
|
+
sub_type = Regexp.last_match[:sub_type]
|
75
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
76
|
+
end
|
77
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
78
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
79
|
+
sub_type = Regexp.last_match[:sub_type]
|
80
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
81
|
+
end
|
82
|
+
else # model
|
83
|
+
const = Coinbase::Client.const_get(klass)
|
84
|
+
if const
|
85
|
+
if const.respond_to?(:openapi_one_of) # nested oneOf model
|
86
|
+
model = const.build(data)
|
87
|
+
return model if model
|
88
|
+
else
|
89
|
+
# raise if data contains keys that are not known to the model
|
90
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
91
|
+
model = const.build_from_hash(data)
|
92
|
+
return model if model
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
raise # if no match by now, raise
|
98
|
+
rescue
|
99
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
@@ -0,0 +1,308 @@
|
|
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 staking rewards for an address
|
18
|
+
class StakingReward
|
19
|
+
# The onchain address for which the staking rewards are being fetched
|
20
|
+
attr_accessor :address_id
|
21
|
+
|
22
|
+
# The date of the reward in format 'YYYY-MM-DD' in UTC.
|
23
|
+
attr_accessor :date
|
24
|
+
|
25
|
+
# The reward amount in requested \"format\". Default is USD.
|
26
|
+
attr_accessor :amount
|
27
|
+
|
28
|
+
# The state of the reward
|
29
|
+
attr_accessor :state
|
30
|
+
|
31
|
+
class EnumAttributeValidator
|
32
|
+
attr_reader :datatype
|
33
|
+
attr_reader :allowable_values
|
34
|
+
|
35
|
+
def initialize(datatype, allowable_values)
|
36
|
+
@allowable_values = allowable_values.map do |value|
|
37
|
+
case datatype.to_s
|
38
|
+
when /Integer/i
|
39
|
+
value.to_i
|
40
|
+
when /Float/i
|
41
|
+
value.to_f
|
42
|
+
else
|
43
|
+
value
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def valid?(value)
|
49
|
+
!value || allowable_values.include?(value)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
54
|
+
def self.attribute_map
|
55
|
+
{
|
56
|
+
:'address_id' => :'address_id',
|
57
|
+
:'date' => :'date',
|
58
|
+
:'amount' => :'amount',
|
59
|
+
:'state' => :'state'
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
# Returns all the JSON keys this model knows about
|
64
|
+
def self.acceptable_attributes
|
65
|
+
attribute_map.values
|
66
|
+
end
|
67
|
+
|
68
|
+
# Attribute type mapping.
|
69
|
+
def self.openapi_types
|
70
|
+
{
|
71
|
+
:'address_id' => :'String',
|
72
|
+
:'date' => :'Date',
|
73
|
+
:'amount' => :'String',
|
74
|
+
:'state' => :'String'
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
# List of attributes with nullable: true
|
79
|
+
def self.openapi_nullable
|
80
|
+
Set.new([
|
81
|
+
])
|
82
|
+
end
|
83
|
+
|
84
|
+
# Initializes the object
|
85
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
86
|
+
def initialize(attributes = {})
|
87
|
+
if (!attributes.is_a?(Hash))
|
88
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Coinbase::Client::StakingReward` initialize method"
|
89
|
+
end
|
90
|
+
|
91
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
92
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
93
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
94
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Coinbase::Client::StakingReward`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
95
|
+
end
|
96
|
+
h[k.to_sym] = v
|
97
|
+
}
|
98
|
+
|
99
|
+
if attributes.key?(:'address_id')
|
100
|
+
self.address_id = attributes[:'address_id']
|
101
|
+
else
|
102
|
+
self.address_id = nil
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.key?(:'date')
|
106
|
+
self.date = attributes[:'date']
|
107
|
+
else
|
108
|
+
self.date = nil
|
109
|
+
end
|
110
|
+
|
111
|
+
if attributes.key?(:'amount')
|
112
|
+
self.amount = attributes[:'amount']
|
113
|
+
else
|
114
|
+
self.amount = nil
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.key?(:'state')
|
118
|
+
self.state = attributes[:'state']
|
119
|
+
else
|
120
|
+
self.state = nil
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
125
|
+
# @return Array for valid properties with the reasons
|
126
|
+
def list_invalid_properties
|
127
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
128
|
+
invalid_properties = Array.new
|
129
|
+
if @address_id.nil?
|
130
|
+
invalid_properties.push('invalid value for "address_id", address_id cannot be nil.')
|
131
|
+
end
|
132
|
+
|
133
|
+
if @date.nil?
|
134
|
+
invalid_properties.push('invalid value for "date", date cannot be nil.')
|
135
|
+
end
|
136
|
+
|
137
|
+
if @amount.nil?
|
138
|
+
invalid_properties.push('invalid value for "amount", amount cannot be nil.')
|
139
|
+
end
|
140
|
+
|
141
|
+
if @state.nil?
|
142
|
+
invalid_properties.push('invalid value for "state", state cannot be nil.')
|
143
|
+
end
|
144
|
+
|
145
|
+
invalid_properties
|
146
|
+
end
|
147
|
+
|
148
|
+
# Check to see if the all the properties in the model are valid
|
149
|
+
# @return true if the model is valid
|
150
|
+
def valid?
|
151
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
152
|
+
return false if @address_id.nil?
|
153
|
+
return false if @date.nil?
|
154
|
+
return false if @amount.nil?
|
155
|
+
return false if @state.nil?
|
156
|
+
state_validator = EnumAttributeValidator.new('String', ["pending", "distributed"])
|
157
|
+
return false unless state_validator.valid?(@state)
|
158
|
+
true
|
159
|
+
end
|
160
|
+
|
161
|
+
# Custom attribute writer method checking allowed values (enum).
|
162
|
+
# @param [Object] state Object to be assigned
|
163
|
+
def state=(state)
|
164
|
+
validator = EnumAttributeValidator.new('String', ["pending", "distributed"])
|
165
|
+
unless validator.valid?(state)
|
166
|
+
fail ArgumentError, "invalid value for \"state\", must be one of #{validator.allowable_values}."
|
167
|
+
end
|
168
|
+
@state = state
|
169
|
+
end
|
170
|
+
|
171
|
+
# Checks equality by comparing each attribute.
|
172
|
+
# @param [Object] Object to be compared
|
173
|
+
def ==(o)
|
174
|
+
return true if self.equal?(o)
|
175
|
+
self.class == o.class &&
|
176
|
+
address_id == o.address_id &&
|
177
|
+
date == o.date &&
|
178
|
+
amount == o.amount &&
|
179
|
+
state == o.state
|
180
|
+
end
|
181
|
+
|
182
|
+
# @see the `==` method
|
183
|
+
# @param [Object] Object to be compared
|
184
|
+
def eql?(o)
|
185
|
+
self == o
|
186
|
+
end
|
187
|
+
|
188
|
+
# Calculates hash code according to all attributes.
|
189
|
+
# @return [Integer] Hash code
|
190
|
+
def hash
|
191
|
+
[address_id, date, amount, state].hash
|
192
|
+
end
|
193
|
+
|
194
|
+
# Builds the object from hash
|
195
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
196
|
+
# @return [Object] Returns the model itself
|
197
|
+
def self.build_from_hash(attributes)
|
198
|
+
return nil unless attributes.is_a?(Hash)
|
199
|
+
attributes = attributes.transform_keys(&:to_sym)
|
200
|
+
transformed_hash = {}
|
201
|
+
openapi_types.each_pair do |key, type|
|
202
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
203
|
+
transformed_hash["#{key}"] = nil
|
204
|
+
elsif type =~ /\AArray<(.*)>/i
|
205
|
+
# check to ensure the input is an array given that the attribute
|
206
|
+
# is documented as an array but the input is not
|
207
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
208
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
209
|
+
end
|
210
|
+
elsif !attributes[attribute_map[key]].nil?
|
211
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
212
|
+
end
|
213
|
+
end
|
214
|
+
new(transformed_hash)
|
215
|
+
end
|
216
|
+
|
217
|
+
# Deserializes the data based on type
|
218
|
+
# @param string type Data type
|
219
|
+
# @param string value Value to be deserialized
|
220
|
+
# @return [Object] Deserialized data
|
221
|
+
def self._deserialize(type, value)
|
222
|
+
case type.to_sym
|
223
|
+
when :Time
|
224
|
+
Time.parse(value)
|
225
|
+
when :Date
|
226
|
+
Date.parse(value)
|
227
|
+
when :String
|
228
|
+
value.to_s
|
229
|
+
when :Integer
|
230
|
+
value.to_i
|
231
|
+
when :Float
|
232
|
+
value.to_f
|
233
|
+
when :Boolean
|
234
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
235
|
+
true
|
236
|
+
else
|
237
|
+
false
|
238
|
+
end
|
239
|
+
when :Object
|
240
|
+
# generic object (usually a Hash), return directly
|
241
|
+
value
|
242
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
243
|
+
inner_type = Regexp.last_match[:inner_type]
|
244
|
+
value.map { |v| _deserialize(inner_type, v) }
|
245
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
246
|
+
k_type = Regexp.last_match[:k_type]
|
247
|
+
v_type = Regexp.last_match[:v_type]
|
248
|
+
{}.tap do |hash|
|
249
|
+
value.each do |k, v|
|
250
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
else # model
|
254
|
+
# models (e.g. Pet) or oneOf
|
255
|
+
klass = Coinbase::Client.const_get(type)
|
256
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
# Returns the string representation of the object
|
261
|
+
# @return [String] String presentation of the object
|
262
|
+
def to_s
|
263
|
+
to_hash.to_s
|
264
|
+
end
|
265
|
+
|
266
|
+
# to_body is an alias to to_hash (backward compatibility)
|
267
|
+
# @return [Hash] Returns the object in the form of hash
|
268
|
+
def to_body
|
269
|
+
to_hash
|
270
|
+
end
|
271
|
+
|
272
|
+
# Returns the object in the form of hash
|
273
|
+
# @return [Hash] Returns the object in the form of hash
|
274
|
+
def to_hash
|
275
|
+
hash = {}
|
276
|
+
self.class.attribute_map.each_pair do |attr, param|
|
277
|
+
value = self.send(attr)
|
278
|
+
if value.nil?
|
279
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
280
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
281
|
+
end
|
282
|
+
|
283
|
+
hash[param] = _to_hash(value)
|
284
|
+
end
|
285
|
+
hash
|
286
|
+
end
|
287
|
+
|
288
|
+
# Outputs non-array value in the form of hash
|
289
|
+
# For object, use to_hash. Otherwise, just return the value
|
290
|
+
# @param [Object] value Any valid value
|
291
|
+
# @return [Hash] Returns the value in the form of hash
|
292
|
+
def _to_hash(value)
|
293
|
+
if value.is_a?(Array)
|
294
|
+
value.compact.map { |v| _to_hash(v) }
|
295
|
+
elsif value.is_a?(Hash)
|
296
|
+
{}.tap do |hash|
|
297
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
298
|
+
end
|
299
|
+
elsif value.respond_to? :to_hash
|
300
|
+
value.to_hash
|
301
|
+
else
|
302
|
+
value
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
end
|
307
|
+
|
308
|
+
end
|
data/lib/coinbase/client.rb
CHANGED
@@ -34,6 +34,10 @@ Coinbase::Client.autoload :CreateWalletRequestWallet, 'coinbase/client/models/cr
|
|
34
34
|
Coinbase::Client.autoload :Error, 'coinbase/client/models/error'
|
35
35
|
Coinbase::Client.autoload :FaucetTransaction, 'coinbase/client/models/faucet_transaction'
|
36
36
|
Coinbase::Client.autoload :Feature, 'coinbase/client/models/feature'
|
37
|
+
Coinbase::Client.autoload :FetchStakingRewards200Response, 'coinbase/client/models/fetch_staking_rewards200_response'
|
38
|
+
Coinbase::Client.autoload :FetchStakingRewardsRequest, 'coinbase/client/models/fetch_staking_rewards_request'
|
39
|
+
Coinbase::Client.autoload :GetStakingContextRequest, 'coinbase/client/models/get_staking_context_request'
|
40
|
+
Coinbase::Client.autoload :PartialEthStakingContext, 'coinbase/client/models/partial_eth_staking_context'
|
37
41
|
Coinbase::Client.autoload :SeedCreationEvent, 'coinbase/client/models/seed_creation_event'
|
38
42
|
Coinbase::Client.autoload :SeedCreationEventResult, 'coinbase/client/models/seed_creation_event_result'
|
39
43
|
Coinbase::Client.autoload :ServerSigner, 'coinbase/client/models/server_signer'
|
@@ -43,7 +47,10 @@ Coinbase::Client.autoload :ServerSignerEventList, 'coinbase/client/models/server
|
|
43
47
|
Coinbase::Client.autoload :ServerSignerList, 'coinbase/client/models/server_signer_list'
|
44
48
|
Coinbase::Client.autoload :SignatureCreationEvent, 'coinbase/client/models/signature_creation_event'
|
45
49
|
Coinbase::Client.autoload :SignatureCreationEventResult, 'coinbase/client/models/signature_creation_event_result'
|
50
|
+
Coinbase::Client.autoload :StakingContext, 'coinbase/client/models/staking_context'
|
51
|
+
Coinbase::Client.autoload :StakingContextContext, 'coinbase/client/models/staking_context_context'
|
46
52
|
Coinbase::Client.autoload :StakingOperation, 'coinbase/client/models/staking_operation'
|
53
|
+
Coinbase::Client.autoload :StakingReward, 'coinbase/client/models/staking_reward'
|
47
54
|
Coinbase::Client.autoload :Trade, 'coinbase/client/models/trade'
|
48
55
|
Coinbase::Client.autoload :TradeList, 'coinbase/client/models/trade_list'
|
49
56
|
Coinbase::Client.autoload :Transaction, 'coinbase/client/models/transaction'
|
@@ -56,6 +63,8 @@ Coinbase::Client.autoload :WalletList, 'coinbase/client/models/wallet_list'
|
|
56
63
|
|
57
64
|
# APIs
|
58
65
|
Coinbase::Client.autoload :AddressesApi, 'coinbase/client/api/addresses_api'
|
66
|
+
Coinbase::Client.autoload :AssetsApi, 'coinbase/client/api/assets_api'
|
67
|
+
Coinbase::Client.autoload :ExternalAddressesApi, 'coinbase/client/api/external_addresses_api'
|
59
68
|
Coinbase::Client.autoload :ServerSignersApi, 'coinbase/client/api/server_signers_api'
|
60
69
|
Coinbase::Client.autoload :StakeApi, 'coinbase/client/api/stake_api'
|
61
70
|
Coinbase::Client.autoload :TradesApi, 'coinbase/client/api/trades_api'
|