snaptrade 2.0.218 → 2.1.0
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 +2 -2
- data/README.md +47 -2
- data/lib/snaptrade/api/experimental_endpoints_api.rb +123 -0
- data/lib/snaptrade/models/connection_account.rb +51 -0
- data/lib/snaptrade/models/connection_account_sync_status.rb +250 -0
- data/lib/snaptrade/models/investment_account.rb +372 -0
- data/lib/snaptrade/models/investment_account_market_value.rb +228 -0
- data/lib/snaptrade/models/kind.rb +2 -2
- data/lib/snaptrade/models/stock_instrument.rb +1 -1
- data/lib/snaptrade/models/stock_instrument_kind.rb +36 -0
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +5 -0
- data/spec/api/experimental_endpoints_api_spec.rb +14 -0
- data/spec/getting_started_spec.rb +6 -6
- data/spec/models/connection_account_spec.rb +38 -0
- data/spec/models/connection_account_sync_status_spec.rb +47 -0
- data/spec/models/investment_account_market_value_spec.rb +35 -0
- data/spec/models/investment_account_spec.rb +101 -0
- data/spec/models/stock_instrument_kind_spec.rb +23 -0
- metadata +17 -2
|
@@ -0,0 +1,372 @@
|
|
|
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
|
+
# An investment/brokerage account under a connection. `opening_date`, `funding_date`, and `market_value` are real-time or cached depending on the caller's plan -- see `Connections_listConnectionAccounts`.
|
|
15
|
+
class InvestmentAccount
|
|
16
|
+
# Discriminator for the account kind.
|
|
17
|
+
attr_accessor :kind
|
|
18
|
+
|
|
19
|
+
# Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
|
|
20
|
+
attr_accessor :id
|
|
21
|
+
|
|
22
|
+
# Unique identifier for the connection (brokerage_authorization_id). This is the UUID used to reference the connection in SnapTrade.
|
|
23
|
+
attr_accessor :connection_id
|
|
24
|
+
|
|
25
|
+
# A display name for the account. Either assigned by the user or by the brokerage itself.
|
|
26
|
+
attr_accessor :display_name
|
|
27
|
+
|
|
28
|
+
# The account number assigned by the brokerage. For some brokerages, this field may be masked for security reasons.
|
|
29
|
+
attr_accessor :number
|
|
30
|
+
|
|
31
|
+
# A stable and unique account identifier provided by the institution. Will be set to null if not provided. When present, can be used to check if a user has connected the same brokerage account across multiple connections.
|
|
32
|
+
attr_accessor :institution_account_id
|
|
33
|
+
|
|
34
|
+
# Unique identifier for the institution (brokerage) that holds the account.
|
|
35
|
+
attr_accessor :institution_id
|
|
36
|
+
|
|
37
|
+
# Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format indicating when the account was opened at the brokerage.
|
|
38
|
+
attr_accessor :opening_date
|
|
39
|
+
|
|
40
|
+
attr_accessor :sync_status
|
|
41
|
+
|
|
42
|
+
# The account type as provided by the brokerage.
|
|
43
|
+
attr_accessor :raw_type
|
|
44
|
+
|
|
45
|
+
# Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format indicating when the account was funded.
|
|
46
|
+
attr_accessor :funding_date
|
|
47
|
+
|
|
48
|
+
# Indicates whether the account is a paper (simulated) trading account.
|
|
49
|
+
attr_accessor :is_paper
|
|
50
|
+
|
|
51
|
+
attr_accessor :market_value
|
|
52
|
+
|
|
53
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
54
|
+
def self.attribute_map
|
|
55
|
+
{
|
|
56
|
+
:'kind' => :'kind',
|
|
57
|
+
:'id' => :'id',
|
|
58
|
+
:'connection_id' => :'connection_id',
|
|
59
|
+
:'display_name' => :'display_name',
|
|
60
|
+
:'number' => :'number',
|
|
61
|
+
:'institution_account_id' => :'institution_account_id',
|
|
62
|
+
:'institution_id' => :'institution_id',
|
|
63
|
+
:'opening_date' => :'opening_date',
|
|
64
|
+
:'sync_status' => :'sync_status',
|
|
65
|
+
:'raw_type' => :'raw_type',
|
|
66
|
+
:'funding_date' => :'funding_date',
|
|
67
|
+
:'is_paper' => :'is_paper',
|
|
68
|
+
:'market_value' => :'market_value'
|
|
69
|
+
}
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Returns all the JSON keys this model knows about
|
|
73
|
+
def self.acceptable_attributes
|
|
74
|
+
attribute_map.values
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Attribute type mapping.
|
|
78
|
+
def self.openapi_types
|
|
79
|
+
{
|
|
80
|
+
:'kind' => :'Kind',
|
|
81
|
+
:'id' => :'String',
|
|
82
|
+
:'connection_id' => :'String',
|
|
83
|
+
:'display_name' => :'String',
|
|
84
|
+
:'number' => :'String',
|
|
85
|
+
:'institution_account_id' => :'String',
|
|
86
|
+
:'institution_id' => :'String',
|
|
87
|
+
:'opening_date' => :'Time',
|
|
88
|
+
:'sync_status' => :'ConnectionAccountSyncStatus',
|
|
89
|
+
:'raw_type' => :'String',
|
|
90
|
+
:'funding_date' => :'Time',
|
|
91
|
+
:'is_paper' => :'Boolean',
|
|
92
|
+
:'market_value' => :'InvestmentAccountMarketValue'
|
|
93
|
+
}
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# List of attributes with nullable: true
|
|
97
|
+
def self.openapi_nullable
|
|
98
|
+
Set.new([
|
|
99
|
+
:'display_name',
|
|
100
|
+
:'institution_account_id',
|
|
101
|
+
:'opening_date',
|
|
102
|
+
:'raw_type',
|
|
103
|
+
:'funding_date',
|
|
104
|
+
:'market_value'
|
|
105
|
+
])
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Initializes the object
|
|
109
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
110
|
+
def initialize(attributes = {})
|
|
111
|
+
if (!attributes.is_a?(Hash))
|
|
112
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::InvestmentAccount` initialize method"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
116
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
117
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
118
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::InvestmentAccount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
119
|
+
end
|
|
120
|
+
h[k.to_sym] = v
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if attributes.key?(:'kind')
|
|
124
|
+
self.kind = attributes[:'kind']
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
if attributes.key?(:'id')
|
|
128
|
+
self.id = attributes[:'id']
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
if attributes.key?(:'connection_id')
|
|
132
|
+
self.connection_id = attributes[:'connection_id']
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
if attributes.key?(:'display_name')
|
|
136
|
+
self.display_name = attributes[:'display_name']
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
if attributes.key?(:'number')
|
|
140
|
+
self.number = attributes[:'number']
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
if attributes.key?(:'institution_account_id')
|
|
144
|
+
self.institution_account_id = attributes[:'institution_account_id']
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
if attributes.key?(:'institution_id')
|
|
148
|
+
self.institution_id = attributes[:'institution_id']
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
if attributes.key?(:'opening_date')
|
|
152
|
+
self.opening_date = attributes[:'opening_date']
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
if attributes.key?(:'sync_status')
|
|
156
|
+
self.sync_status = attributes[:'sync_status']
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
if attributes.key?(:'raw_type')
|
|
160
|
+
self.raw_type = attributes[:'raw_type']
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
if attributes.key?(:'funding_date')
|
|
164
|
+
self.funding_date = attributes[:'funding_date']
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
if attributes.key?(:'is_paper')
|
|
168
|
+
self.is_paper = attributes[:'is_paper']
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
if attributes.key?(:'market_value')
|
|
172
|
+
self.market_value = attributes[:'market_value']
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
177
|
+
# @return Array for valid properties with the reasons
|
|
178
|
+
def list_invalid_properties
|
|
179
|
+
invalid_properties = Array.new
|
|
180
|
+
if @kind.nil?
|
|
181
|
+
invalid_properties.push('invalid value for "kind", kind cannot be nil.')
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
if @id.nil?
|
|
185
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
if @connection_id.nil?
|
|
189
|
+
invalid_properties.push('invalid value for "connection_id", connection_id cannot be nil.')
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
if @number.nil?
|
|
193
|
+
invalid_properties.push('invalid value for "number", number cannot be nil.')
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
if @sync_status.nil?
|
|
197
|
+
invalid_properties.push('invalid value for "sync_status", sync_status cannot be nil.')
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
if @is_paper.nil?
|
|
201
|
+
invalid_properties.push('invalid value for "is_paper", is_paper cannot be nil.')
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
invalid_properties
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# Check to see if the all the properties in the model are valid
|
|
208
|
+
# @return true if the model is valid
|
|
209
|
+
def valid?
|
|
210
|
+
return false if @kind.nil?
|
|
211
|
+
return false if @id.nil?
|
|
212
|
+
return false if @connection_id.nil?
|
|
213
|
+
return false if @number.nil?
|
|
214
|
+
return false if @sync_status.nil?
|
|
215
|
+
return false if @is_paper.nil?
|
|
216
|
+
true
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Checks equality by comparing each attribute.
|
|
220
|
+
# @param [Object] Object to be compared
|
|
221
|
+
def ==(o)
|
|
222
|
+
return true if self.equal?(o)
|
|
223
|
+
self.class == o.class &&
|
|
224
|
+
kind == o.kind &&
|
|
225
|
+
id == o.id &&
|
|
226
|
+
connection_id == o.connection_id &&
|
|
227
|
+
display_name == o.display_name &&
|
|
228
|
+
number == o.number &&
|
|
229
|
+
institution_account_id == o.institution_account_id &&
|
|
230
|
+
institution_id == o.institution_id &&
|
|
231
|
+
opening_date == o.opening_date &&
|
|
232
|
+
sync_status == o.sync_status &&
|
|
233
|
+
raw_type == o.raw_type &&
|
|
234
|
+
funding_date == o.funding_date &&
|
|
235
|
+
is_paper == o.is_paper &&
|
|
236
|
+
market_value == o.market_value
|
|
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
|
+
[kind, id, connection_id, display_name, number, institution_account_id, institution_id, opening_date, sync_status, raw_type, funding_date, is_paper, market_value].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
|
+
new.build_from_hash(attributes)
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# Builds the object from hash
|
|
259
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
260
|
+
# @return [Object] Returns the model itself
|
|
261
|
+
def build_from_hash(attributes)
|
|
262
|
+
return nil unless attributes.is_a?(Hash)
|
|
263
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
264
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
265
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
266
|
+
self.send("#{key}=", nil)
|
|
267
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
268
|
+
# check to ensure the input is an array given that the attribute
|
|
269
|
+
# is documented as an array but the input is not
|
|
270
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
271
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
272
|
+
end
|
|
273
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
274
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
self
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
# Deserializes the data based on type
|
|
282
|
+
# @param string type Data type
|
|
283
|
+
# @param string value Value to be deserialized
|
|
284
|
+
# @return [Object] Deserialized data
|
|
285
|
+
def _deserialize(type, value)
|
|
286
|
+
case type.to_sym
|
|
287
|
+
when :Time
|
|
288
|
+
Time.parse(value)
|
|
289
|
+
when :Date
|
|
290
|
+
Date.parse(value)
|
|
291
|
+
when :String
|
|
292
|
+
value.to_s
|
|
293
|
+
when :Integer
|
|
294
|
+
value.to_i
|
|
295
|
+
when :Float
|
|
296
|
+
value.to_f
|
|
297
|
+
when :Boolean
|
|
298
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
299
|
+
true
|
|
300
|
+
else
|
|
301
|
+
false
|
|
302
|
+
end
|
|
303
|
+
when :Object
|
|
304
|
+
# generic object (usually a Hash), return directly
|
|
305
|
+
value
|
|
306
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
307
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
308
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
309
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
310
|
+
k_type = Regexp.last_match[:k_type]
|
|
311
|
+
v_type = Regexp.last_match[:v_type]
|
|
312
|
+
{}.tap do |hash|
|
|
313
|
+
value.each do |k, v|
|
|
314
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
else # model
|
|
318
|
+
# models (e.g. Pet) or oneOf
|
|
319
|
+
klass = SnapTrade.const_get(type)
|
|
320
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
321
|
+
end
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
# Returns the string representation of the object
|
|
325
|
+
# @return [String] String presentation of the object
|
|
326
|
+
def to_s
|
|
327
|
+
to_hash.to_s
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
331
|
+
# @return [Hash] Returns the object in the form of hash
|
|
332
|
+
def to_body
|
|
333
|
+
to_hash
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
# Returns the object in the form of hash
|
|
337
|
+
# @return [Hash] Returns the object in the form of hash
|
|
338
|
+
def to_hash
|
|
339
|
+
hash = {}
|
|
340
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
341
|
+
value = self.send(attr)
|
|
342
|
+
if value.nil?
|
|
343
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
344
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
hash[param] = _to_hash(value)
|
|
348
|
+
end
|
|
349
|
+
hash
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
# Outputs non-array value in the form of hash
|
|
353
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
354
|
+
# @param [Object] value Any valid value
|
|
355
|
+
# @return [Hash] Returns the value in the form of hash
|
|
356
|
+
def _to_hash(value)
|
|
357
|
+
if value.is_a?(Array)
|
|
358
|
+
value.compact.map { |v| _to_hash(v) }
|
|
359
|
+
elsif value.is_a?(Hash)
|
|
360
|
+
{}.tap do |hash|
|
|
361
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
362
|
+
end
|
|
363
|
+
elsif value.respond_to? :to_hash
|
|
364
|
+
value.to_hash
|
|
365
|
+
else
|
|
366
|
+
value
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
end
|
|
@@ -0,0 +1,228 @@
|
|
|
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
|
+
# Total market value of the account. Null when unknown (e.g. a real-time fetch failed and no cached value exists).
|
|
15
|
+
class InvestmentAccountMarketValue
|
|
16
|
+
attr_accessor :amount
|
|
17
|
+
|
|
18
|
+
attr_accessor :currency
|
|
19
|
+
|
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
21
|
+
def self.attribute_map
|
|
22
|
+
{
|
|
23
|
+
:'amount' => :'amount',
|
|
24
|
+
:'currency' => :'currency'
|
|
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
|
+
:'amount' => :'Float',
|
|
37
|
+
:'currency' => :'String'
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# List of attributes with nullable: true
|
|
42
|
+
def self.openapi_nullable
|
|
43
|
+
Set.new([
|
|
44
|
+
:'amount',
|
|
45
|
+
:'currency'
|
|
46
|
+
])
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Initializes the object
|
|
50
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
51
|
+
def initialize(attributes = {})
|
|
52
|
+
if (!attributes.is_a?(Hash))
|
|
53
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::InvestmentAccountMarketValue` initialize method"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
57
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
58
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
59
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::InvestmentAccountMarketValue`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
60
|
+
end
|
|
61
|
+
h[k.to_sym] = v
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if attributes.key?(:'amount')
|
|
65
|
+
self.amount = attributes[:'amount']
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
if attributes.key?(:'currency')
|
|
69
|
+
self.currency = attributes[:'currency']
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
74
|
+
# @return Array for valid properties with the reasons
|
|
75
|
+
def list_invalid_properties
|
|
76
|
+
invalid_properties = Array.new
|
|
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
|
+
true
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Checks equality by comparing each attribute.
|
|
87
|
+
# @param [Object] Object to be compared
|
|
88
|
+
def ==(o)
|
|
89
|
+
return true if self.equal?(o)
|
|
90
|
+
self.class == o.class &&
|
|
91
|
+
amount == o.amount &&
|
|
92
|
+
currency == o.currency
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# @see the `==` method
|
|
96
|
+
# @param [Object] Object to be compared
|
|
97
|
+
def eql?(o)
|
|
98
|
+
self == o
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Calculates hash code according to all attributes.
|
|
102
|
+
# @return [Integer] Hash code
|
|
103
|
+
def hash
|
|
104
|
+
[amount, currency].hash
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Builds the object from hash
|
|
108
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
109
|
+
# @return [Object] Returns the model itself
|
|
110
|
+
def self.build_from_hash(attributes)
|
|
111
|
+
new.build_from_hash(attributes)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Builds the object from hash
|
|
115
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
116
|
+
# @return [Object] Returns the model itself
|
|
117
|
+
def build_from_hash(attributes)
|
|
118
|
+
return nil unless attributes.is_a?(Hash)
|
|
119
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
120
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
121
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
122
|
+
self.send("#{key}=", nil)
|
|
123
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
124
|
+
# check to ensure the input is an array given that the attribute
|
|
125
|
+
# is documented as an array but the input is not
|
|
126
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
127
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
128
|
+
end
|
|
129
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
130
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
self
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Deserializes the data based on type
|
|
138
|
+
# @param string type Data type
|
|
139
|
+
# @param string value Value to be deserialized
|
|
140
|
+
# @return [Object] Deserialized data
|
|
141
|
+
def _deserialize(type, value)
|
|
142
|
+
case type.to_sym
|
|
143
|
+
when :Time
|
|
144
|
+
Time.parse(value)
|
|
145
|
+
when :Date
|
|
146
|
+
Date.parse(value)
|
|
147
|
+
when :String
|
|
148
|
+
value.to_s
|
|
149
|
+
when :Integer
|
|
150
|
+
value.to_i
|
|
151
|
+
when :Float
|
|
152
|
+
value.to_f
|
|
153
|
+
when :Boolean
|
|
154
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
155
|
+
true
|
|
156
|
+
else
|
|
157
|
+
false
|
|
158
|
+
end
|
|
159
|
+
when :Object
|
|
160
|
+
# generic object (usually a Hash), return directly
|
|
161
|
+
value
|
|
162
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
163
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
164
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
165
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
166
|
+
k_type = Regexp.last_match[:k_type]
|
|
167
|
+
v_type = Regexp.last_match[:v_type]
|
|
168
|
+
{}.tap do |hash|
|
|
169
|
+
value.each do |k, v|
|
|
170
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
else # model
|
|
174
|
+
# models (e.g. Pet) or oneOf
|
|
175
|
+
klass = SnapTrade.const_get(type)
|
|
176
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Returns the string representation of the object
|
|
181
|
+
# @return [String] String presentation of the object
|
|
182
|
+
def to_s
|
|
183
|
+
to_hash.to_s
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
187
|
+
# @return [Hash] Returns the object in the form of hash
|
|
188
|
+
def to_body
|
|
189
|
+
to_hash
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Returns the object in the form of hash
|
|
193
|
+
# @return [Hash] Returns the object in the form of hash
|
|
194
|
+
def to_hash
|
|
195
|
+
hash = {}
|
|
196
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
197
|
+
value = self.send(attr)
|
|
198
|
+
if value.nil?
|
|
199
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
200
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
hash[param] = _to_hash(value)
|
|
204
|
+
end
|
|
205
|
+
hash
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Outputs non-array value in the form of hash
|
|
209
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
210
|
+
# @param [Object] value Any valid value
|
|
211
|
+
# @return [Hash] Returns the value in the form of hash
|
|
212
|
+
def _to_hash(value)
|
|
213
|
+
if value.is_a?(Array)
|
|
214
|
+
value.compact.map { |v| _to_hash(v) }
|
|
215
|
+
elsif value.is_a?(Hash)
|
|
216
|
+
{}.tap do |hash|
|
|
217
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
218
|
+
end
|
|
219
|
+
elsif value.respond_to? :to_hash
|
|
220
|
+
value.to_hash
|
|
221
|
+
else
|
|
222
|
+
value
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
end
|
|
@@ -12,10 +12,10 @@ require 'time'
|
|
|
12
12
|
|
|
13
13
|
module SnapTrade
|
|
14
14
|
class Kind
|
|
15
|
-
|
|
15
|
+
INVESTMENT = "investment".freeze
|
|
16
16
|
|
|
17
17
|
def self.all_vars
|
|
18
|
-
@all_vars ||= [
|
|
18
|
+
@all_vars ||= [INVESTMENT].freeze
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# Builds the enum from string
|
|
@@ -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 StockInstrumentKind
|
|
15
|
+
STOCK = "stock".freeze
|
|
16
|
+
|
|
17
|
+
def self.all_vars
|
|
18
|
+
@all_vars ||= [STOCK].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 StockInstrumentKind.all_vars.include?(value)
|
|
33
|
+
raise "Invalid ENUM value #{value} for class #StockInstrumentKind"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/snaptrade/version.rb
CHANGED
data/lib/snaptrade.rb
CHANGED
|
@@ -79,6 +79,8 @@ require 'snaptrade/models/complex_order_leg'
|
|
|
79
79
|
require 'snaptrade/models/complex_order_leg_order_role'
|
|
80
80
|
require 'snaptrade/models/complex_order_response'
|
|
81
81
|
require 'snaptrade/models/complex_order_response_type'
|
|
82
|
+
require 'snaptrade/models/connection_account'
|
|
83
|
+
require 'snaptrade/models/connection_account_sync_status'
|
|
82
84
|
require 'snaptrade/models/connection_portal_version'
|
|
83
85
|
require 'snaptrade/models/connection_type'
|
|
84
86
|
require 'snaptrade/models/connections_session_events200_response_inner'
|
|
@@ -108,6 +110,8 @@ require 'snaptrade/models/future_instrument'
|
|
|
108
110
|
require 'snaptrade/models/future_instrument_kind'
|
|
109
111
|
require 'snaptrade/models/holdings_status'
|
|
110
112
|
require 'snaptrade/models/instrument'
|
|
113
|
+
require 'snaptrade/models/investment_account'
|
|
114
|
+
require 'snaptrade/models/investment_account_market_value'
|
|
111
115
|
require 'snaptrade/models/kind'
|
|
112
116
|
require 'snaptrade/models/login_redirect_uri'
|
|
113
117
|
require 'snaptrade/models/manual_trade'
|
|
@@ -197,6 +201,7 @@ require 'snaptrade/models/snap_trade_register_user_request_body'
|
|
|
197
201
|
require 'snaptrade/models/status'
|
|
198
202
|
require 'snaptrade/models/stock_instrument'
|
|
199
203
|
require 'snaptrade/models/stock_instrument_figi_instrument'
|
|
204
|
+
require 'snaptrade/models/stock_instrument_kind'
|
|
200
205
|
require 'snaptrade/models/stop_loss'
|
|
201
206
|
require 'snaptrade/models/strategy_order_record'
|
|
202
207
|
require 'snaptrade/models/strategy_order_record_status'
|