snaptrade 2.0.185 → 2.0.186
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +52 -2
- data/lib/snaptrade/api/experimental_endpoints_api.rb +141 -0
- data/lib/snaptrade/models/account_order_record_option_symbol.rb +1 -1
- data/lib/snaptrade/models/account_order_record_quote_universal_symbol.rb +1 -1
- data/lib/snaptrade/models/account_order_record_universal_symbol.rb +1 -1
- data/lib/snaptrade/models/account_position.rb +288 -0
- data/lib/snaptrade/models/account_universal_activity_option_symbol.rb +1 -1
- data/lib/snaptrade/models/account_universal_activity_symbol.rb +1 -1
- data/lib/snaptrade/models/all_account_positions_response.rb +262 -0
- data/lib/snaptrade/models/crypto_instrument.rb +311 -0
- data/lib/snaptrade/models/crypto_instrument_kind.rb +36 -0
- data/lib/snaptrade/models/etf_instrument.rb +311 -0
- data/lib/snaptrade/models/etf_instrument_kind.rb +36 -0
- data/lib/snaptrade/models/future_instrument.rb +326 -0
- data/lib/snaptrade/models/future_instrument_kind.rb +36 -0
- data/lib/snaptrade/models/instrument.rb +61 -0
- data/lib/snaptrade/models/kind.rb +36 -0
- data/lib/snaptrade/models/option_instrument.rb +322 -0
- data/lib/snaptrade/models/option_instrument_kind.rb +36 -0
- data/lib/snaptrade/models/options_symbol.rb +1 -1
- data/lib/snaptrade/models/options_symbol_option_type.rb +37 -0
- data/lib/snaptrade/models/other_instrument.rb +311 -0
- data/lib/snaptrade/models/other_instrument_kind.rb +36 -0
- data/lib/snaptrade/models/stock_instrument.rb +311 -0
- data/lib/snaptrade/models/{symbol_figi_instrument.rb → stock_instrument_figi_instrument.rb} +3 -3
- data/lib/snaptrade/models/symbol.rb +1 -1
- data/lib/snaptrade/models/underlying_option_instrument.rb +57 -0
- data/lib/snaptrade/models/underlying_symbol.rb +1 -1
- data/lib/snaptrade/models/universal_symbol.rb +1 -1
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +18 -1
- data/spec/api/experimental_endpoints_api_spec.rb +16 -0
- data/spec/models/account_position_spec.rb +65 -0
- data/spec/models/all_account_positions_response_spec.rb +47 -0
- data/spec/models/crypto_instrument_kind_spec.rb +23 -0
- data/spec/models/crypto_instrument_spec.rb +71 -0
- data/spec/models/etf_instrument_kind_spec.rb +23 -0
- data/spec/models/etf_instrument_spec.rb +71 -0
- data/spec/models/future_instrument_kind_spec.rb +23 -0
- data/spec/models/future_instrument_spec.rb +77 -0
- data/spec/models/instrument_spec.rb +38 -0
- data/spec/models/kind_spec.rb +23 -0
- data/spec/models/option_instrument_kind_spec.rb +23 -0
- data/spec/models/option_instrument_spec.rb +71 -0
- data/spec/models/options_symbol_option_type_spec.rb +23 -0
- data/spec/models/other_instrument_kind_spec.rb +23 -0
- data/spec/models/other_instrument_spec.rb +71 -0
- data/spec/models/{symbol_figi_instrument_spec.rb → stock_instrument_figi_instrument_spec.rb} +6 -6
- data/spec/models/stock_instrument_spec.rb +71 -0
- data/spec/models/underlying_option_instrument_spec.rb +38 -0
- metadata +56 -5
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#SnapTrade
|
|
3
|
+
|
|
4
|
+
#Connect brokerage accounts to your app for live positions and trading
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
Contact: api@snaptrade.com
|
|
8
|
+
=end
|
|
9
|
+
|
|
10
|
+
require 'date'
|
|
11
|
+
require 'time'
|
|
12
|
+
|
|
13
|
+
module SnapTrade
|
|
14
|
+
# A paginated list of all account positions.
|
|
15
|
+
class AllAccountPositionsResponse
|
|
16
|
+
# The total number of positions available across all pages.
|
|
17
|
+
attr_accessor :count
|
|
18
|
+
|
|
19
|
+
# The URL for the next page of results, or `null` if there is no next page.
|
|
20
|
+
attr_accessor :_next
|
|
21
|
+
|
|
22
|
+
# The URL for the previous page of results, or `null` if there is no previous page.
|
|
23
|
+
attr_accessor :previous
|
|
24
|
+
|
|
25
|
+
# Positions returned for the current page.
|
|
26
|
+
attr_accessor :results
|
|
27
|
+
|
|
28
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
29
|
+
def self.attribute_map
|
|
30
|
+
{
|
|
31
|
+
:'count' => :'count',
|
|
32
|
+
:'_next' => :'next',
|
|
33
|
+
:'previous' => :'previous',
|
|
34
|
+
:'results' => :'results'
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Returns all the JSON keys this model knows about
|
|
39
|
+
def self.acceptable_attributes
|
|
40
|
+
attribute_map.values
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Attribute type mapping.
|
|
44
|
+
def self.openapi_types
|
|
45
|
+
{
|
|
46
|
+
:'count' => :'Integer',
|
|
47
|
+
:'_next' => :'String',
|
|
48
|
+
:'previous' => :'String',
|
|
49
|
+
:'results' => :'Array<AccountPosition>'
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# List of attributes with nullable: true
|
|
54
|
+
def self.openapi_nullable
|
|
55
|
+
Set.new([
|
|
56
|
+
:'_next',
|
|
57
|
+
:'previous',
|
|
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 `SnapTrade::AllAccountPositionsResponse` 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 `SnapTrade::AllAccountPositionsResponse`. 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?(:'count')
|
|
77
|
+
self.count = attributes[:'count']
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
if attributes.key?(:'_next')
|
|
81
|
+
self._next = attributes[:'_next']
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
if attributes.key?(:'previous')
|
|
85
|
+
self.previous = attributes[:'previous']
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
if attributes.key?(:'results')
|
|
89
|
+
if (value = attributes[:'results']).is_a?(Array)
|
|
90
|
+
self.results = value
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
96
|
+
# @return Array for valid properties with the reasons
|
|
97
|
+
def list_invalid_properties
|
|
98
|
+
invalid_properties = Array.new
|
|
99
|
+
if @count.nil?
|
|
100
|
+
invalid_properties.push('invalid value for "count", count cannot be nil.')
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
if @results.nil?
|
|
104
|
+
invalid_properties.push('invalid value for "results", results cannot be nil.')
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
invalid_properties
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Check to see if the all the properties in the model are valid
|
|
111
|
+
# @return true if the model is valid
|
|
112
|
+
def valid?
|
|
113
|
+
return false if @count.nil?
|
|
114
|
+
return false if @results.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
|
+
count == o.count &&
|
|
124
|
+
_next == o._next &&
|
|
125
|
+
previous == o.previous &&
|
|
126
|
+
results == o.results
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# @see the `==` method
|
|
130
|
+
# @param [Object] Object to be compared
|
|
131
|
+
def eql?(o)
|
|
132
|
+
self == o
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Calculates hash code according to all attributes.
|
|
136
|
+
# @return [Integer] Hash code
|
|
137
|
+
def hash
|
|
138
|
+
[count, _next, previous, results].hash
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Builds the object from hash
|
|
142
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
143
|
+
# @return [Object] Returns the model itself
|
|
144
|
+
def self.build_from_hash(attributes)
|
|
145
|
+
new.build_from_hash(attributes)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Builds the object from hash
|
|
149
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
150
|
+
# @return [Object] Returns the model itself
|
|
151
|
+
def build_from_hash(attributes)
|
|
152
|
+
return nil unless attributes.is_a?(Hash)
|
|
153
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
154
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
155
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
156
|
+
self.send("#{key}=", nil)
|
|
157
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
158
|
+
# check to ensure the input is an array given that the attribute
|
|
159
|
+
# is documented as an array but the input is not
|
|
160
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
161
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
162
|
+
end
|
|
163
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
164
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
self
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Deserializes the data based on type
|
|
172
|
+
# @param string type Data type
|
|
173
|
+
# @param string value Value to be deserialized
|
|
174
|
+
# @return [Object] Deserialized data
|
|
175
|
+
def _deserialize(type, value)
|
|
176
|
+
case type.to_sym
|
|
177
|
+
when :Time
|
|
178
|
+
Time.parse(value)
|
|
179
|
+
when :Date
|
|
180
|
+
Date.parse(value)
|
|
181
|
+
when :String
|
|
182
|
+
value.to_s
|
|
183
|
+
when :Integer
|
|
184
|
+
value.to_i
|
|
185
|
+
when :Float
|
|
186
|
+
value.to_f
|
|
187
|
+
when :Boolean
|
|
188
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
189
|
+
true
|
|
190
|
+
else
|
|
191
|
+
false
|
|
192
|
+
end
|
|
193
|
+
when :Object
|
|
194
|
+
# generic object (usually a Hash), return directly
|
|
195
|
+
value
|
|
196
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
197
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
198
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
199
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
200
|
+
k_type = Regexp.last_match[:k_type]
|
|
201
|
+
v_type = Regexp.last_match[:v_type]
|
|
202
|
+
{}.tap do |hash|
|
|
203
|
+
value.each do |k, v|
|
|
204
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
else # model
|
|
208
|
+
# models (e.g. Pet) or oneOf
|
|
209
|
+
klass = SnapTrade.const_get(type)
|
|
210
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Returns the string representation of the object
|
|
215
|
+
# @return [String] String presentation of the object
|
|
216
|
+
def to_s
|
|
217
|
+
to_hash.to_s
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
221
|
+
# @return [Hash] Returns the object in the form of hash
|
|
222
|
+
def to_body
|
|
223
|
+
to_hash
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Returns the object in the form of hash
|
|
227
|
+
# @return [Hash] Returns the object in the form of hash
|
|
228
|
+
def to_hash
|
|
229
|
+
hash = {}
|
|
230
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
231
|
+
value = self.send(attr)
|
|
232
|
+
if value.nil?
|
|
233
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
234
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
hash[param] = _to_hash(value)
|
|
238
|
+
end
|
|
239
|
+
hash
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
# Outputs non-array value in the form of hash
|
|
243
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
244
|
+
# @param [Object] value Any valid value
|
|
245
|
+
# @return [Hash] Returns the value in the form of hash
|
|
246
|
+
def _to_hash(value)
|
|
247
|
+
if value.is_a?(Array)
|
|
248
|
+
value.compact.map { |v| _to_hash(v) }
|
|
249
|
+
elsif value.is_a?(Hash)
|
|
250
|
+
{}.tap do |hash|
|
|
251
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
252
|
+
end
|
|
253
|
+
elsif value.respond_to? :to_hash
|
|
254
|
+
value.to_hash
|
|
255
|
+
else
|
|
256
|
+
value
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
end
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#SnapTrade
|
|
3
|
+
|
|
4
|
+
#Connect brokerage accounts to your app for live positions and trading
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
Contact: api@snaptrade.com
|
|
8
|
+
=end
|
|
9
|
+
|
|
10
|
+
require 'date'
|
|
11
|
+
require 'time'
|
|
12
|
+
|
|
13
|
+
module SnapTrade
|
|
14
|
+
# Security instrument metadata for crypto positions.
|
|
15
|
+
class CryptoInstrument
|
|
16
|
+
# Type of security instrument.
|
|
17
|
+
attr_accessor :kind
|
|
18
|
+
|
|
19
|
+
# Unique identifier for the instrument.
|
|
20
|
+
attr_accessor :id
|
|
21
|
+
|
|
22
|
+
# The formatted trading symbol for the security.
|
|
23
|
+
attr_accessor :symbol
|
|
24
|
+
|
|
25
|
+
# The raw symbol without any exchange suffix.
|
|
26
|
+
attr_accessor :raw_symbol
|
|
27
|
+
|
|
28
|
+
# Human-readable description of the security.
|
|
29
|
+
attr_accessor :description
|
|
30
|
+
|
|
31
|
+
# ISO-4217 currency code for the security listing.
|
|
32
|
+
attr_accessor :currency
|
|
33
|
+
|
|
34
|
+
# Exchange MIC code or exchange code for the security.
|
|
35
|
+
attr_accessor :exchange
|
|
36
|
+
|
|
37
|
+
attr_accessor :figi_instrument
|
|
38
|
+
|
|
39
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
40
|
+
def self.attribute_map
|
|
41
|
+
{
|
|
42
|
+
:'kind' => :'kind',
|
|
43
|
+
:'id' => :'id',
|
|
44
|
+
:'symbol' => :'symbol',
|
|
45
|
+
:'raw_symbol' => :'raw_symbol',
|
|
46
|
+
:'description' => :'description',
|
|
47
|
+
:'currency' => :'currency',
|
|
48
|
+
:'exchange' => :'exchange',
|
|
49
|
+
:'figi_instrument' => :'figi_instrument'
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Returns all the JSON keys this model knows about
|
|
54
|
+
def self.acceptable_attributes
|
|
55
|
+
attribute_map.values
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Attribute type mapping.
|
|
59
|
+
def self.openapi_types
|
|
60
|
+
{
|
|
61
|
+
:'kind' => :'CryptoInstrumentKind',
|
|
62
|
+
:'id' => :'String',
|
|
63
|
+
:'symbol' => :'String',
|
|
64
|
+
:'raw_symbol' => :'String',
|
|
65
|
+
:'description' => :'String',
|
|
66
|
+
:'currency' => :'String',
|
|
67
|
+
:'exchange' => :'String',
|
|
68
|
+
:'figi_instrument' => :'StockInstrumentFigiInstrument'
|
|
69
|
+
}
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# List of attributes with nullable: true
|
|
73
|
+
def self.openapi_nullable
|
|
74
|
+
Set.new([
|
|
75
|
+
:'description',
|
|
76
|
+
:'currency',
|
|
77
|
+
:'exchange',
|
|
78
|
+
:'figi_instrument'
|
|
79
|
+
])
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Initializes the object
|
|
83
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
84
|
+
def initialize(attributes = {})
|
|
85
|
+
if (!attributes.is_a?(Hash))
|
|
86
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::CryptoInstrument` initialize method"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
90
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
91
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
92
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::CryptoInstrument`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
93
|
+
end
|
|
94
|
+
h[k.to_sym] = v
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if attributes.key?(:'kind')
|
|
98
|
+
self.kind = attributes[:'kind']
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
if attributes.key?(:'id')
|
|
102
|
+
self.id = attributes[:'id']
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
if attributes.key?(:'symbol')
|
|
106
|
+
self.symbol = attributes[:'symbol']
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
if attributes.key?(:'raw_symbol')
|
|
110
|
+
self.raw_symbol = attributes[:'raw_symbol']
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
if attributes.key?(:'description')
|
|
114
|
+
self.description = attributes[:'description']
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
if attributes.key?(:'currency')
|
|
118
|
+
self.currency = attributes[:'currency']
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
if attributes.key?(:'exchange')
|
|
122
|
+
self.exchange = attributes[:'exchange']
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
if attributes.key?(:'figi_instrument')
|
|
126
|
+
self.figi_instrument = attributes[:'figi_instrument']
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
131
|
+
# @return Array for valid properties with the reasons
|
|
132
|
+
def list_invalid_properties
|
|
133
|
+
invalid_properties = Array.new
|
|
134
|
+
if @kind.nil?
|
|
135
|
+
invalid_properties.push('invalid value for "kind", kind cannot be nil.')
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
if @id.nil?
|
|
139
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
if @symbol.nil?
|
|
143
|
+
invalid_properties.push('invalid value for "symbol", symbol cannot be nil.')
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
if @raw_symbol.nil?
|
|
147
|
+
invalid_properties.push('invalid value for "raw_symbol", raw_symbol cannot be nil.')
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
invalid_properties
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Check to see if the all the properties in the model are valid
|
|
154
|
+
# @return true if the model is valid
|
|
155
|
+
def valid?
|
|
156
|
+
return false if @kind.nil?
|
|
157
|
+
return false if @id.nil?
|
|
158
|
+
return false if @symbol.nil?
|
|
159
|
+
return false if @raw_symbol.nil?
|
|
160
|
+
true
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Checks equality by comparing each attribute.
|
|
164
|
+
# @param [Object] Object to be compared
|
|
165
|
+
def ==(o)
|
|
166
|
+
return true if self.equal?(o)
|
|
167
|
+
self.class == o.class &&
|
|
168
|
+
kind == o.kind &&
|
|
169
|
+
id == o.id &&
|
|
170
|
+
symbol == o.symbol &&
|
|
171
|
+
raw_symbol == o.raw_symbol &&
|
|
172
|
+
description == o.description &&
|
|
173
|
+
currency == o.currency &&
|
|
174
|
+
exchange == o.exchange &&
|
|
175
|
+
figi_instrument == o.figi_instrument
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# @see the `==` method
|
|
179
|
+
# @param [Object] Object to be compared
|
|
180
|
+
def eql?(o)
|
|
181
|
+
self == o
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Calculates hash code according to all attributes.
|
|
185
|
+
# @return [Integer] Hash code
|
|
186
|
+
def hash
|
|
187
|
+
[kind, id, symbol, raw_symbol, description, currency, exchange, figi_instrument].hash
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Builds the object from hash
|
|
191
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
192
|
+
# @return [Object] Returns the model itself
|
|
193
|
+
def self.build_from_hash(attributes)
|
|
194
|
+
new.build_from_hash(attributes)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# Builds the object from hash
|
|
198
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
199
|
+
# @return [Object] Returns the model itself
|
|
200
|
+
def build_from_hash(attributes)
|
|
201
|
+
return nil unless attributes.is_a?(Hash)
|
|
202
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
203
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
204
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
205
|
+
self.send("#{key}=", nil)
|
|
206
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
207
|
+
# check to ensure the input is an array given that the attribute
|
|
208
|
+
# is documented as an array but the input is not
|
|
209
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
210
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
211
|
+
end
|
|
212
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
213
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
self
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Deserializes the data based on type
|
|
221
|
+
# @param string type Data type
|
|
222
|
+
# @param string value Value to be deserialized
|
|
223
|
+
# @return [Object] Deserialized data
|
|
224
|
+
def _deserialize(type, value)
|
|
225
|
+
case type.to_sym
|
|
226
|
+
when :Time
|
|
227
|
+
Time.parse(value)
|
|
228
|
+
when :Date
|
|
229
|
+
Date.parse(value)
|
|
230
|
+
when :String
|
|
231
|
+
value.to_s
|
|
232
|
+
when :Integer
|
|
233
|
+
value.to_i
|
|
234
|
+
when :Float
|
|
235
|
+
value.to_f
|
|
236
|
+
when :Boolean
|
|
237
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
238
|
+
true
|
|
239
|
+
else
|
|
240
|
+
false
|
|
241
|
+
end
|
|
242
|
+
when :Object
|
|
243
|
+
# generic object (usually a Hash), return directly
|
|
244
|
+
value
|
|
245
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
246
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
247
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
248
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
249
|
+
k_type = Regexp.last_match[:k_type]
|
|
250
|
+
v_type = Regexp.last_match[:v_type]
|
|
251
|
+
{}.tap do |hash|
|
|
252
|
+
value.each do |k, v|
|
|
253
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
else # model
|
|
257
|
+
# models (e.g. Pet) or oneOf
|
|
258
|
+
klass = SnapTrade.const_get(type)
|
|
259
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
# Returns the string representation of the object
|
|
264
|
+
# @return [String] String presentation of the object
|
|
265
|
+
def to_s
|
|
266
|
+
to_hash.to_s
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
270
|
+
# @return [Hash] Returns the object in the form of hash
|
|
271
|
+
def to_body
|
|
272
|
+
to_hash
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
# Returns the object in the form of hash
|
|
276
|
+
# @return [Hash] Returns the object in the form of hash
|
|
277
|
+
def to_hash
|
|
278
|
+
hash = {}
|
|
279
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
280
|
+
value = self.send(attr)
|
|
281
|
+
if value.nil?
|
|
282
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
283
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
hash[param] = _to_hash(value)
|
|
287
|
+
end
|
|
288
|
+
hash
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# Outputs non-array value in the form of hash
|
|
292
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
293
|
+
# @param [Object] value Any valid value
|
|
294
|
+
# @return [Hash] Returns the value in the form of hash
|
|
295
|
+
def _to_hash(value)
|
|
296
|
+
if value.is_a?(Array)
|
|
297
|
+
value.compact.map { |v| _to_hash(v) }
|
|
298
|
+
elsif value.is_a?(Hash)
|
|
299
|
+
{}.tap do |hash|
|
|
300
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
301
|
+
end
|
|
302
|
+
elsif value.respond_to? :to_hash
|
|
303
|
+
value.to_hash
|
|
304
|
+
else
|
|
305
|
+
value
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#SnapTrade
|
|
3
|
+
|
|
4
|
+
#Connect brokerage accounts to your app for live positions and trading
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
Contact: api@snaptrade.com
|
|
8
|
+
=end
|
|
9
|
+
|
|
10
|
+
require 'date'
|
|
11
|
+
require 'time'
|
|
12
|
+
|
|
13
|
+
module SnapTrade
|
|
14
|
+
class CryptoInstrumentKind
|
|
15
|
+
CRYPTO = "crypto".freeze
|
|
16
|
+
|
|
17
|
+
def self.all_vars
|
|
18
|
+
@all_vars ||= [CRYPTO].freeze
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Builds the enum from string
|
|
22
|
+
# @param [String] The enum value in the form of the string
|
|
23
|
+
# @return [String] The enum value
|
|
24
|
+
def self.build_from_hash(value)
|
|
25
|
+
new.build_from_hash(value)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Builds the enum from string
|
|
29
|
+
# @param [String] The enum value in the form of the string
|
|
30
|
+
# @return [String] The enum value
|
|
31
|
+
def build_from_hash(value)
|
|
32
|
+
return value if CryptoInstrumentKind.all_vars.include?(value)
|
|
33
|
+
raise "Invalid ENUM value #{value} for class #CryptoInstrumentKind"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|