snaptrade 3.0.3 → 3.0.5
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 -4
- data/lib/snaptrade/api/account_information_api.rb +103 -0
- data/lib/snaptrade/api/authentication_api.rb +6 -2
- data/lib/snaptrade/api/experimental_endpoints_api.rb +6 -6
- data/lib/snaptrade/models/bucket.rb +41 -0
- data/lib/snaptrade/models/connection_account.rb +3 -1
- data/lib/snaptrade/models/deposit_account.rb +346 -0
- data/lib/snaptrade/models/deposit_account_balance.rb +228 -0
- data/lib/snaptrade/models/deposit_account_kind.rb +36 -0
- data/lib/snaptrade/models/snap_trade_login_user_request_body.rb +13 -1
- data/lib/snaptrade/models/user_aum_percentile_object.rb +282 -0
- data/lib/snaptrade/models/user_aum_percentile_response.rb +218 -0
- data/lib/snaptrade/models/user_aum_percentile_response_data.rb +288 -0
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +7 -0
- data/spec/api/account_information_api_spec.rb +13 -0
- data/spec/api/experimental_endpoints_api_spec.rb +1 -1
- data/spec/models/bucket_spec.rb +23 -0
- data/spec/models/deposit_account_balance_spec.rb +35 -0
- data/spec/models/deposit_account_kind_spec.rb +23 -0
- data/spec/models/deposit_account_spec.rb +89 -0
- data/spec/models/snap_trade_login_user_request_body_spec.rb +6 -0
- data/spec/models/user_aum_percentile_object_spec.rb +53 -0
- data/spec/models/user_aum_percentile_response_data_spec.rb +53 -0
- data/spec/models/user_aum_percentile_response_spec.rb +29 -0
- metadata +226 -205
|
@@ -0,0 +1,346 @@
|
|
|
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 deposit account (checking, savings) under a connection.
|
|
15
|
+
class DepositAccount
|
|
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. Only populated for brokerages that expose this data; `null` for all other brokerages.
|
|
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
|
+
attr_accessor :balance
|
|
46
|
+
|
|
47
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
48
|
+
def self.attribute_map
|
|
49
|
+
{
|
|
50
|
+
:'kind' => :'kind',
|
|
51
|
+
:'id' => :'id',
|
|
52
|
+
:'connection_id' => :'connection_id',
|
|
53
|
+
:'display_name' => :'display_name',
|
|
54
|
+
:'number' => :'number',
|
|
55
|
+
:'institution_account_id' => :'institution_account_id',
|
|
56
|
+
:'institution_id' => :'institution_id',
|
|
57
|
+
:'opening_date' => :'opening_date',
|
|
58
|
+
:'sync_status' => :'sync_status',
|
|
59
|
+
:'raw_type' => :'raw_type',
|
|
60
|
+
:'balance' => :'balance'
|
|
61
|
+
}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Returns all the JSON keys this model knows about
|
|
65
|
+
def self.acceptable_attributes
|
|
66
|
+
attribute_map.values
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Attribute type mapping.
|
|
70
|
+
def self.openapi_types
|
|
71
|
+
{
|
|
72
|
+
:'kind' => :'DepositAccountKind',
|
|
73
|
+
:'id' => :'String',
|
|
74
|
+
:'connection_id' => :'String',
|
|
75
|
+
:'display_name' => :'String',
|
|
76
|
+
:'number' => :'String',
|
|
77
|
+
:'institution_account_id' => :'String',
|
|
78
|
+
:'institution_id' => :'String',
|
|
79
|
+
:'opening_date' => :'Time',
|
|
80
|
+
:'sync_status' => :'ConnectionAccountSyncStatus',
|
|
81
|
+
:'raw_type' => :'String',
|
|
82
|
+
:'balance' => :'DepositAccountBalance'
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# List of attributes with nullable: true
|
|
87
|
+
def self.openapi_nullable
|
|
88
|
+
Set.new([
|
|
89
|
+
:'display_name',
|
|
90
|
+
:'institution_account_id',
|
|
91
|
+
:'opening_date',
|
|
92
|
+
:'raw_type',
|
|
93
|
+
:'balance'
|
|
94
|
+
])
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Initializes the object
|
|
98
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
99
|
+
def initialize(attributes = {})
|
|
100
|
+
if (!attributes.is_a?(Hash))
|
|
101
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::DepositAccount` initialize method"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
105
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
106
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
107
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::DepositAccount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
108
|
+
end
|
|
109
|
+
h[k.to_sym] = v
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if attributes.key?(:'kind')
|
|
113
|
+
self.kind = attributes[:'kind']
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
if attributes.key?(:'id')
|
|
117
|
+
self.id = attributes[:'id']
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
if attributes.key?(:'connection_id')
|
|
121
|
+
self.connection_id = attributes[:'connection_id']
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
if attributes.key?(:'display_name')
|
|
125
|
+
self.display_name = attributes[:'display_name']
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
if attributes.key?(:'number')
|
|
129
|
+
self.number = attributes[:'number']
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
if attributes.key?(:'institution_account_id')
|
|
133
|
+
self.institution_account_id = attributes[:'institution_account_id']
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
if attributes.key?(:'institution_id')
|
|
137
|
+
self.institution_id = attributes[:'institution_id']
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
if attributes.key?(:'opening_date')
|
|
141
|
+
self.opening_date = attributes[:'opening_date']
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
if attributes.key?(:'sync_status')
|
|
145
|
+
self.sync_status = attributes[:'sync_status']
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
if attributes.key?(:'raw_type')
|
|
149
|
+
self.raw_type = attributes[:'raw_type']
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
if attributes.key?(:'balance')
|
|
153
|
+
self.balance = attributes[:'balance']
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
158
|
+
# @return Array for valid properties with the reasons
|
|
159
|
+
def list_invalid_properties
|
|
160
|
+
invalid_properties = Array.new
|
|
161
|
+
if @kind.nil?
|
|
162
|
+
invalid_properties.push('invalid value for "kind", kind cannot be nil.')
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
if @id.nil?
|
|
166
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
if @connection_id.nil?
|
|
170
|
+
invalid_properties.push('invalid value for "connection_id", connection_id cannot be nil.')
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
if @number.nil?
|
|
174
|
+
invalid_properties.push('invalid value for "number", number cannot be nil.')
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
if @sync_status.nil?
|
|
178
|
+
invalid_properties.push('invalid value for "sync_status", sync_status cannot be nil.')
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
invalid_properties
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Check to see if the all the properties in the model are valid
|
|
185
|
+
# @return true if the model is valid
|
|
186
|
+
def valid?
|
|
187
|
+
return false if @kind.nil?
|
|
188
|
+
return false if @id.nil?
|
|
189
|
+
return false if @connection_id.nil?
|
|
190
|
+
return false if @number.nil?
|
|
191
|
+
return false if @sync_status.nil?
|
|
192
|
+
true
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Checks equality by comparing each attribute.
|
|
196
|
+
# @param [Object] Object to be compared
|
|
197
|
+
def ==(o)
|
|
198
|
+
return true if self.equal?(o)
|
|
199
|
+
self.class == o.class &&
|
|
200
|
+
kind == o.kind &&
|
|
201
|
+
id == o.id &&
|
|
202
|
+
connection_id == o.connection_id &&
|
|
203
|
+
display_name == o.display_name &&
|
|
204
|
+
number == o.number &&
|
|
205
|
+
institution_account_id == o.institution_account_id &&
|
|
206
|
+
institution_id == o.institution_id &&
|
|
207
|
+
opening_date == o.opening_date &&
|
|
208
|
+
sync_status == o.sync_status &&
|
|
209
|
+
raw_type == o.raw_type &&
|
|
210
|
+
balance == o.balance
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# @see the `==` method
|
|
214
|
+
# @param [Object] Object to be compared
|
|
215
|
+
def eql?(o)
|
|
216
|
+
self == o
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Calculates hash code according to all attributes.
|
|
220
|
+
# @return [Integer] Hash code
|
|
221
|
+
def hash
|
|
222
|
+
[kind, id, connection_id, display_name, number, institution_account_id, institution_id, opening_date, sync_status, raw_type, balance].hash
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Builds the object from hash
|
|
226
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
227
|
+
# @return [Object] Returns the model itself
|
|
228
|
+
def self.build_from_hash(attributes)
|
|
229
|
+
new.build_from_hash(attributes)
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Builds the object from hash
|
|
233
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
234
|
+
# @return [Object] Returns the model itself
|
|
235
|
+
def build_from_hash(attributes)
|
|
236
|
+
return nil unless attributes.is_a?(Hash)
|
|
237
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
238
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
239
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
240
|
+
self.send("#{key}=", nil)
|
|
241
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
242
|
+
# check to ensure the input is an array given that the attribute
|
|
243
|
+
# is documented as an array but the input is not
|
|
244
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
245
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
246
|
+
end
|
|
247
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
248
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
self
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# Deserializes the data based on type
|
|
256
|
+
# @param string type Data type
|
|
257
|
+
# @param string value Value to be deserialized
|
|
258
|
+
# @return [Object] Deserialized data
|
|
259
|
+
def _deserialize(type, value)
|
|
260
|
+
case type.to_sym
|
|
261
|
+
when :Time
|
|
262
|
+
Time.parse(value)
|
|
263
|
+
when :Date
|
|
264
|
+
Date.parse(value)
|
|
265
|
+
when :String
|
|
266
|
+
value.to_s
|
|
267
|
+
when :Integer
|
|
268
|
+
value.to_i
|
|
269
|
+
when :Float
|
|
270
|
+
value.to_f
|
|
271
|
+
when :Boolean
|
|
272
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
273
|
+
true
|
|
274
|
+
else
|
|
275
|
+
false
|
|
276
|
+
end
|
|
277
|
+
when :Object
|
|
278
|
+
# generic object (usually a Hash), return directly
|
|
279
|
+
value
|
|
280
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
281
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
282
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
283
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
284
|
+
k_type = Regexp.last_match[:k_type]
|
|
285
|
+
v_type = Regexp.last_match[:v_type]
|
|
286
|
+
{}.tap do |hash|
|
|
287
|
+
value.each do |k, v|
|
|
288
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
else # model
|
|
292
|
+
# models (e.g. Pet) or oneOf
|
|
293
|
+
klass = SnapTrade.const_get(type)
|
|
294
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
# Returns the string representation of the object
|
|
299
|
+
# @return [String] String presentation of the object
|
|
300
|
+
def to_s
|
|
301
|
+
to_hash.to_s
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
305
|
+
# @return [Hash] Returns the object in the form of hash
|
|
306
|
+
def to_body
|
|
307
|
+
to_hash
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
# Returns the object in the form of hash
|
|
311
|
+
# @return [Hash] Returns the object in the form of hash
|
|
312
|
+
def to_hash
|
|
313
|
+
hash = {}
|
|
314
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
315
|
+
value = self.send(attr)
|
|
316
|
+
if value.nil?
|
|
317
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
318
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
hash[param] = _to_hash(value)
|
|
322
|
+
end
|
|
323
|
+
hash
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
# Outputs non-array value in the form of hash
|
|
327
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
328
|
+
# @param [Object] value Any valid value
|
|
329
|
+
# @return [Hash] Returns the value in the form of hash
|
|
330
|
+
def _to_hash(value)
|
|
331
|
+
if value.is_a?(Array)
|
|
332
|
+
value.compact.map { |v| _to_hash(v) }
|
|
333
|
+
elsif value.is_a?(Hash)
|
|
334
|
+
{}.tap do |hash|
|
|
335
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
336
|
+
end
|
|
337
|
+
elsif value.respond_to? :to_hash
|
|
338
|
+
value.to_hash
|
|
339
|
+
else
|
|
340
|
+
value
|
|
341
|
+
end
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
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
|
+
# Cash balance of the account. Null when unknown (e.g. a real-time fetch failed and no cached value exists).
|
|
15
|
+
class DepositAccountBalance
|
|
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::DepositAccountBalance` 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::DepositAccountBalance`. 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
|
|
@@ -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 DepositAccountKind
|
|
15
|
+
DEPOSIT = "deposit".freeze
|
|
16
|
+
|
|
17
|
+
def self.all_vars
|
|
18
|
+
@all_vars ||= [DEPOSIT].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 DepositAccountKind.all_vars.include?(value)
|
|
33
|
+
raise "Invalid ENUM value #{value} for class #DepositAccountKind"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -34,6 +34,9 @@ module SnapTrade
|
|
|
34
34
|
# Enable dark mode for the connection portal. Defaults to false.
|
|
35
35
|
attr_accessor :dark_mode
|
|
36
36
|
|
|
37
|
+
# Language the connection portal renders in. `en` and `pt-BR` are the languages we ship; any other language is rejected with a 400. Matching is case- and separator-insensitive, so `pt-br`, `pt-BR` and `pt_BR` are equivalent, and a regional tag resolves to the language when we ship it, so `en-US` renders `en`. Deliberately not an enum: those equivalent spellings are all accepted by the API, and an enum would have generated SDKs reject them before the request is sent. Screens without translated copy fall back to English individually. Defaults to `en`.
|
|
38
|
+
attr_accessor :locale
|
|
39
|
+
|
|
37
40
|
# Sets the connection portal version to render. Currently only `v4` is supported and is the default. All other versions are deprecated and will automatically be set to v4.
|
|
38
41
|
attr_accessor :connection_portal_version
|
|
39
42
|
|
|
@@ -47,6 +50,7 @@ module SnapTrade
|
|
|
47
50
|
:'connection_type' => :'connectionType',
|
|
48
51
|
:'show_close_button' => :'showCloseButton',
|
|
49
52
|
:'dark_mode' => :'darkMode',
|
|
53
|
+
:'locale' => :'locale',
|
|
50
54
|
:'connection_portal_version' => :'connectionPortalVersion'
|
|
51
55
|
}
|
|
52
56
|
end
|
|
@@ -66,6 +70,7 @@ module SnapTrade
|
|
|
66
70
|
:'connection_type' => :'ConnectionType',
|
|
67
71
|
:'show_close_button' => :'Boolean',
|
|
68
72
|
:'dark_mode' => :'Boolean',
|
|
73
|
+
:'locale' => :'String',
|
|
69
74
|
:'connection_portal_version' => :'ConnectionPortalVersion'
|
|
70
75
|
}
|
|
71
76
|
end
|
|
@@ -121,6 +126,12 @@ module SnapTrade
|
|
|
121
126
|
self.dark_mode = attributes[:'dark_mode']
|
|
122
127
|
end
|
|
123
128
|
|
|
129
|
+
if attributes.key?(:'locale')
|
|
130
|
+
self.locale = attributes[:'locale']
|
|
131
|
+
else
|
|
132
|
+
self.locale = 'en'
|
|
133
|
+
end
|
|
134
|
+
|
|
124
135
|
if attributes.key?(:'connection_portal_version')
|
|
125
136
|
self.connection_portal_version = attributes[:'connection_portal_version']
|
|
126
137
|
else
|
|
@@ -153,6 +164,7 @@ module SnapTrade
|
|
|
153
164
|
connection_type == o.connection_type &&
|
|
154
165
|
show_close_button == o.show_close_button &&
|
|
155
166
|
dark_mode == o.dark_mode &&
|
|
167
|
+
locale == o.locale &&
|
|
156
168
|
connection_portal_version == o.connection_portal_version
|
|
157
169
|
end
|
|
158
170
|
|
|
@@ -165,7 +177,7 @@ module SnapTrade
|
|
|
165
177
|
# Calculates hash code according to all attributes.
|
|
166
178
|
# @return [Integer] Hash code
|
|
167
179
|
def hash
|
|
168
|
-
[broker, immediate_redirect, custom_redirect, reconnect, connection_type, show_close_button, dark_mode, connection_portal_version].hash
|
|
180
|
+
[broker, immediate_redirect, custom_redirect, reconnect, connection_type, show_close_button, dark_mode, locale, connection_portal_version].hash
|
|
169
181
|
end
|
|
170
182
|
|
|
171
183
|
# Builds the object from hash
|