snaptrade 3.0.41 → 3.0.43
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/README.md +43 -3
- data/lib/snaptrade/api/management_api.rb +108 -12
- data/lib/snaptrade/models/account_balances_v2_response.rb +1 -1
- data/lib/snaptrade/models/account_balances_v2_response_margin.rb +1 -1
- data/lib/snaptrade/models/connected_asset_partner_stats.rb +382 -0
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +1 -0
- data/spec/api/management_api_spec.rb +15 -3
- data/spec/models/connected_asset_partner_stats_spec.rb +107 -0
- metadata +256 -253
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#SnapTrade
|
|
3
|
+
|
|
4
|
+
#Connect brokerage accounts to your app for live positions and trading. ## Rate limiting Two limits apply to requests signed with your `clientId`. The stricter one wins, and exceeding either returns `429 Too Many Requests`. - **Customer-level** — 250 requests/minute by default, scoped to your `clientId` and applied across all endpoints. Reported in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. - **Account-level** — 10 requests/minute per account, scoped to (`clientId`, `accountId`). All covered operations for one account draw on the same bucket — reading balances and reading positions share it — and enforcement does not depend on the HTTP method, so updating an account consumes the same bucket as reading it. Only enforced for Personal users, and only for integrations it has been rolled out to — it is not yet in force for every Personal integration. It also does not apply on every operation that documents a 429 below. Where it applies it is reported in `X-RateLimit-Account-Limit`, `X-RateLimit-Account-Remaining` and `X-RateLimit-Account-Reset`. Do not read the absence of those headers as proof the limit is off — some configurations omit the rate limit headers while still enforcing the limit, so header absence tells you nothing about your allowance. On a 429, `X-RateLimit-Remaining: 0` means you hit the customer-level limit and `X-RateLimit-Account-Remaining: 0` means the account-level one. Wait for the corresponding `*-Reset` value (seconds) before retrying, or fall back to exponential backoff with jitter. Not every 429 is explained by those headers. A separate per-authenticated-user limit, reported in no `X-RateLimit-*` header, covers OAuth-authenticated requests and signed requests in configurations where the customer-level limit is not in effect — on the operations that use the default throttles. A few operations override those and are governed by the customer-level limit alone. The two do not stack: a signed request governed by the customer-level limit above is not additionally subject to the per-user one. If a 429 arrives with no header at zero — or with no `X-RateLimit-*` headers at all — honour `Retry-After` and back off. Treat the remaining counts as a hint, not a guarantee that the next request will succeed. Because the customer-level limit applies everywhere, any signed request can return 429. **OAuth-authenticated requests are an exception.** They are not subject to the customer-level limit and do not receive `X-RateLimit-Limit`, `X-RateLimit-Remaining` or `X-RateLimit-Reset` — do not wait on those headers or design around a customer-level allowance on this path. The account-level limit still applies to them on the account-data endpoints above, reported in the `X-RateLimit-Account-*` headers. On operations using the default throttles the per-user limit above applies to them as well, so an OAuth request can be rejected while the account headers still show capacity; on the few operations that override those throttles, OAuth callers have no per-user ceiling at all. Drive retries from `Retry-After` and exponential backoff with jitter rather than from the headers. See https://docs.snaptrade.com/docs/ratelimiting.
|
|
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
|
+
# User, connection, and connected asset totals for your SnapTrade Client ID.
|
|
15
|
+
class ConnectedAssetPartnerStats
|
|
16
|
+
# Number of users registered with your Client ID.
|
|
17
|
+
attr_accessor :total_users
|
|
18
|
+
|
|
19
|
+
# Number of users registered with your Client ID that have at least one connection, active or disabled.
|
|
20
|
+
attr_accessor :total_connected_users
|
|
21
|
+
|
|
22
|
+
# Number of active connections across users registered with your Client ID.
|
|
23
|
+
attr_accessor :total_active_connections
|
|
24
|
+
|
|
25
|
+
# Number of disabled connections across users registered with your Client ID.
|
|
26
|
+
attr_accessor :total_disabled_connections
|
|
27
|
+
|
|
28
|
+
# Number of users who have authorized your OAuth application. `null` if your Client ID has no OAuth application.
|
|
29
|
+
attr_accessor :oauth_total_users
|
|
30
|
+
|
|
31
|
+
# Number of users who have authorized your OAuth application and have at least one connection, active or disabled. `null` if your Client ID has no OAuth application.
|
|
32
|
+
attr_accessor :oauth_total_connected_users
|
|
33
|
+
|
|
34
|
+
# Number of active connections across users who have authorized your OAuth application. `null` if your Client ID has no OAuth application.
|
|
35
|
+
attr_accessor :oauth_total_active_connections
|
|
36
|
+
|
|
37
|
+
# Number of disabled connections across users who have authorized your OAuth application. `null` if your Client ID has no OAuth application.
|
|
38
|
+
attr_accessor :oauth_total_disabled_connections
|
|
39
|
+
|
|
40
|
+
# Total latest account value across active connections of users registered with your Client ID, in `connected_assets_currency`. `null` until the first daily snapshot has been calculated.
|
|
41
|
+
attr_accessor :connected_assets
|
|
42
|
+
|
|
43
|
+
# Total account value across disabled connections of users registered with your Client ID, as of each connection's last sync, in `connected_assets_currency`. `null` until the first daily snapshot has been calculated.
|
|
44
|
+
attr_accessor :disabled_connected_assets
|
|
45
|
+
|
|
46
|
+
# Total latest account value across active connections of users who have authorized your OAuth application, in `connected_assets_currency`. `null` if your Client ID has no OAuth application, or until the first daily snapshot after it was added.
|
|
47
|
+
attr_accessor :oauth_connected_assets
|
|
48
|
+
|
|
49
|
+
# Total account value across disabled connections of users who have authorized your OAuth application, as of each connection's last sync, in `connected_assets_currency`. `null` if your Client ID has no OAuth application, or until the first daily snapshot after it was added.
|
|
50
|
+
attr_accessor :oauth_disabled_connected_assets
|
|
51
|
+
|
|
52
|
+
# ISO 4217 currency code the asset values are expressed in.
|
|
53
|
+
attr_accessor :connected_assets_currency
|
|
54
|
+
|
|
55
|
+
# Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format indicating when the connected asset values were last calculated. `null` until the first daily snapshot has been calculated.
|
|
56
|
+
attr_accessor :connected_assets_calculated_at
|
|
57
|
+
|
|
58
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
59
|
+
def self.attribute_map
|
|
60
|
+
{
|
|
61
|
+
:'total_users' => :'total_users',
|
|
62
|
+
:'total_connected_users' => :'total_connected_users',
|
|
63
|
+
:'total_active_connections' => :'total_active_connections',
|
|
64
|
+
:'total_disabled_connections' => :'total_disabled_connections',
|
|
65
|
+
:'oauth_total_users' => :'oauth_total_users',
|
|
66
|
+
:'oauth_total_connected_users' => :'oauth_total_connected_users',
|
|
67
|
+
:'oauth_total_active_connections' => :'oauth_total_active_connections',
|
|
68
|
+
:'oauth_total_disabled_connections' => :'oauth_total_disabled_connections',
|
|
69
|
+
:'connected_assets' => :'connected_assets',
|
|
70
|
+
:'disabled_connected_assets' => :'disabled_connected_assets',
|
|
71
|
+
:'oauth_connected_assets' => :'oauth_connected_assets',
|
|
72
|
+
:'oauth_disabled_connected_assets' => :'oauth_disabled_connected_assets',
|
|
73
|
+
:'connected_assets_currency' => :'connected_assets_currency',
|
|
74
|
+
:'connected_assets_calculated_at' => :'connected_assets_calculated_at'
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Returns all the JSON keys this model knows about
|
|
79
|
+
def self.acceptable_attributes
|
|
80
|
+
attribute_map.values
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Attribute type mapping.
|
|
84
|
+
def self.openapi_types
|
|
85
|
+
{
|
|
86
|
+
:'total_users' => :'Integer',
|
|
87
|
+
:'total_connected_users' => :'Integer',
|
|
88
|
+
:'total_active_connections' => :'Integer',
|
|
89
|
+
:'total_disabled_connections' => :'Integer',
|
|
90
|
+
:'oauth_total_users' => :'Integer',
|
|
91
|
+
:'oauth_total_connected_users' => :'Integer',
|
|
92
|
+
:'oauth_total_active_connections' => :'Integer',
|
|
93
|
+
:'oauth_total_disabled_connections' => :'Integer',
|
|
94
|
+
:'connected_assets' => :'Float',
|
|
95
|
+
:'disabled_connected_assets' => :'Float',
|
|
96
|
+
:'oauth_connected_assets' => :'Float',
|
|
97
|
+
:'oauth_disabled_connected_assets' => :'Float',
|
|
98
|
+
:'connected_assets_currency' => :'String',
|
|
99
|
+
:'connected_assets_calculated_at' => :'Time'
|
|
100
|
+
}
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# List of attributes with nullable: true
|
|
104
|
+
def self.openapi_nullable
|
|
105
|
+
Set.new([
|
|
106
|
+
:'oauth_total_users',
|
|
107
|
+
:'oauth_total_connected_users',
|
|
108
|
+
:'oauth_total_active_connections',
|
|
109
|
+
:'oauth_total_disabled_connections',
|
|
110
|
+
:'connected_assets',
|
|
111
|
+
:'disabled_connected_assets',
|
|
112
|
+
:'oauth_connected_assets',
|
|
113
|
+
:'oauth_disabled_connected_assets',
|
|
114
|
+
:'connected_assets_calculated_at'
|
|
115
|
+
])
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Initializes the object
|
|
119
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
120
|
+
def initialize(attributes = {})
|
|
121
|
+
if (!attributes.is_a?(Hash))
|
|
122
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::ConnectedAssetPartnerStats` initialize method"
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
126
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
127
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
128
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::ConnectedAssetPartnerStats`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
129
|
+
end
|
|
130
|
+
h[k.to_sym] = v
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if attributes.key?(:'total_users')
|
|
134
|
+
self.total_users = attributes[:'total_users']
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
if attributes.key?(:'total_connected_users')
|
|
138
|
+
self.total_connected_users = attributes[:'total_connected_users']
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
if attributes.key?(:'total_active_connections')
|
|
142
|
+
self.total_active_connections = attributes[:'total_active_connections']
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
if attributes.key?(:'total_disabled_connections')
|
|
146
|
+
self.total_disabled_connections = attributes[:'total_disabled_connections']
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
if attributes.key?(:'oauth_total_users')
|
|
150
|
+
self.oauth_total_users = attributes[:'oauth_total_users']
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
if attributes.key?(:'oauth_total_connected_users')
|
|
154
|
+
self.oauth_total_connected_users = attributes[:'oauth_total_connected_users']
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
if attributes.key?(:'oauth_total_active_connections')
|
|
158
|
+
self.oauth_total_active_connections = attributes[:'oauth_total_active_connections']
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
if attributes.key?(:'oauth_total_disabled_connections')
|
|
162
|
+
self.oauth_total_disabled_connections = attributes[:'oauth_total_disabled_connections']
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
if attributes.key?(:'connected_assets')
|
|
166
|
+
self.connected_assets = attributes[:'connected_assets']
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
if attributes.key?(:'disabled_connected_assets')
|
|
170
|
+
self.disabled_connected_assets = attributes[:'disabled_connected_assets']
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
if attributes.key?(:'oauth_connected_assets')
|
|
174
|
+
self.oauth_connected_assets = attributes[:'oauth_connected_assets']
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
if attributes.key?(:'oauth_disabled_connected_assets')
|
|
178
|
+
self.oauth_disabled_connected_assets = attributes[:'oauth_disabled_connected_assets']
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
if attributes.key?(:'connected_assets_currency')
|
|
182
|
+
self.connected_assets_currency = attributes[:'connected_assets_currency']
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
if attributes.key?(:'connected_assets_calculated_at')
|
|
186
|
+
self.connected_assets_calculated_at = attributes[:'connected_assets_calculated_at']
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
191
|
+
# @return Array for valid properties with the reasons
|
|
192
|
+
def list_invalid_properties
|
|
193
|
+
invalid_properties = Array.new
|
|
194
|
+
if @total_users.nil?
|
|
195
|
+
invalid_properties.push('invalid value for "total_users", total_users cannot be nil.')
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
if @total_connected_users.nil?
|
|
199
|
+
invalid_properties.push('invalid value for "total_connected_users", total_connected_users cannot be nil.')
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
if @total_active_connections.nil?
|
|
203
|
+
invalid_properties.push('invalid value for "total_active_connections", total_active_connections cannot be nil.')
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
if @total_disabled_connections.nil?
|
|
207
|
+
invalid_properties.push('invalid value for "total_disabled_connections", total_disabled_connections cannot be nil.')
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
if @connected_assets_currency.nil?
|
|
211
|
+
invalid_properties.push('invalid value for "connected_assets_currency", connected_assets_currency cannot be nil.')
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
invalid_properties
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Check to see if the all the properties in the model are valid
|
|
218
|
+
# @return true if the model is valid
|
|
219
|
+
def valid?
|
|
220
|
+
return false if @total_users.nil?
|
|
221
|
+
return false if @total_connected_users.nil?
|
|
222
|
+
return false if @total_active_connections.nil?
|
|
223
|
+
return false if @total_disabled_connections.nil?
|
|
224
|
+
return false if @connected_assets_currency.nil?
|
|
225
|
+
true
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
# Checks equality by comparing each attribute.
|
|
229
|
+
# @param [Object] Object to be compared
|
|
230
|
+
def ==(o)
|
|
231
|
+
return true if self.equal?(o)
|
|
232
|
+
self.class == o.class &&
|
|
233
|
+
total_users == o.total_users &&
|
|
234
|
+
total_connected_users == o.total_connected_users &&
|
|
235
|
+
total_active_connections == o.total_active_connections &&
|
|
236
|
+
total_disabled_connections == o.total_disabled_connections &&
|
|
237
|
+
oauth_total_users == o.oauth_total_users &&
|
|
238
|
+
oauth_total_connected_users == o.oauth_total_connected_users &&
|
|
239
|
+
oauth_total_active_connections == o.oauth_total_active_connections &&
|
|
240
|
+
oauth_total_disabled_connections == o.oauth_total_disabled_connections &&
|
|
241
|
+
connected_assets == o.connected_assets &&
|
|
242
|
+
disabled_connected_assets == o.disabled_connected_assets &&
|
|
243
|
+
oauth_connected_assets == o.oauth_connected_assets &&
|
|
244
|
+
oauth_disabled_connected_assets == o.oauth_disabled_connected_assets &&
|
|
245
|
+
connected_assets_currency == o.connected_assets_currency &&
|
|
246
|
+
connected_assets_calculated_at == o.connected_assets_calculated_at
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# @see the `==` method
|
|
250
|
+
# @param [Object] Object to be compared
|
|
251
|
+
def eql?(o)
|
|
252
|
+
self == o
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# Calculates hash code according to all attributes.
|
|
256
|
+
# @return [Integer] Hash code
|
|
257
|
+
def hash
|
|
258
|
+
[total_users, total_connected_users, total_active_connections, total_disabled_connections, oauth_total_users, oauth_total_connected_users, oauth_total_active_connections, oauth_total_disabled_connections, connected_assets, disabled_connected_assets, oauth_connected_assets, oauth_disabled_connected_assets, connected_assets_currency, connected_assets_calculated_at].hash
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# Builds the object from hash
|
|
262
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
263
|
+
# @return [Object] Returns the model itself
|
|
264
|
+
def self.build_from_hash(attributes)
|
|
265
|
+
new.build_from_hash(attributes)
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# Builds the object from hash
|
|
269
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
270
|
+
# @return [Object] Returns the model itself
|
|
271
|
+
def build_from_hash(attributes)
|
|
272
|
+
return nil unless attributes.is_a?(Hash)
|
|
273
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
274
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
275
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
276
|
+
self.send("#{key}=", nil)
|
|
277
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
278
|
+
# check to ensure the input is an array given that the attribute
|
|
279
|
+
# is documented as an array but the input is not
|
|
280
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
281
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
282
|
+
end
|
|
283
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
284
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
self
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# Deserializes the data based on type
|
|
292
|
+
# @param string type Data type
|
|
293
|
+
# @param string value Value to be deserialized
|
|
294
|
+
# @return [Object] Deserialized data
|
|
295
|
+
def _deserialize(type, value)
|
|
296
|
+
case type.to_sym
|
|
297
|
+
when :Time
|
|
298
|
+
Time.parse(value)
|
|
299
|
+
when :Date
|
|
300
|
+
Date.parse(value)
|
|
301
|
+
when :String
|
|
302
|
+
value.to_s
|
|
303
|
+
when :Integer
|
|
304
|
+
value.to_i
|
|
305
|
+
when :Float
|
|
306
|
+
value.to_f
|
|
307
|
+
when :Boolean
|
|
308
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
309
|
+
true
|
|
310
|
+
else
|
|
311
|
+
false
|
|
312
|
+
end
|
|
313
|
+
when :Object
|
|
314
|
+
# generic object (usually a Hash), return directly
|
|
315
|
+
value
|
|
316
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
317
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
318
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
319
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
320
|
+
k_type = Regexp.last_match[:k_type]
|
|
321
|
+
v_type = Regexp.last_match[:v_type]
|
|
322
|
+
{}.tap do |hash|
|
|
323
|
+
value.each do |k, v|
|
|
324
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
else # model
|
|
328
|
+
# models (e.g. Pet) or oneOf
|
|
329
|
+
klass = SnapTrade.const_get(type)
|
|
330
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
# Returns the string representation of the object
|
|
335
|
+
# @return [String] String presentation of the object
|
|
336
|
+
def to_s
|
|
337
|
+
to_hash.to_s
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
341
|
+
# @return [Hash] Returns the object in the form of hash
|
|
342
|
+
def to_body
|
|
343
|
+
to_hash
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
# Returns the object in the form of hash
|
|
347
|
+
# @return [Hash] Returns the object in the form of hash
|
|
348
|
+
def to_hash
|
|
349
|
+
hash = {}
|
|
350
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
351
|
+
value = self.send(attr)
|
|
352
|
+
if value.nil?
|
|
353
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
354
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
hash[param] = _to_hash(value)
|
|
358
|
+
end
|
|
359
|
+
hash
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
# Outputs non-array value in the form of hash
|
|
363
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
364
|
+
# @param [Object] value Any valid value
|
|
365
|
+
# @return [Hash] Returns the value in the form of hash
|
|
366
|
+
def _to_hash(value)
|
|
367
|
+
if value.is_a?(Array)
|
|
368
|
+
value.compact.map { |v| _to_hash(v) }
|
|
369
|
+
elsif value.is_a?(Hash)
|
|
370
|
+
{}.tap do |hash|
|
|
371
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
372
|
+
end
|
|
373
|
+
elsif value.respond_to? :to_hash
|
|
374
|
+
value.to_hash
|
|
375
|
+
else
|
|
376
|
+
value
|
|
377
|
+
end
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
end
|
data/lib/snaptrade/version.rb
CHANGED
data/lib/snaptrade.rb
CHANGED
|
@@ -95,6 +95,7 @@ require 'snaptrade/models/complex_order_leg'
|
|
|
95
95
|
require 'snaptrade/models/complex_order_leg_order_role'
|
|
96
96
|
require 'snaptrade/models/complex_order_response'
|
|
97
97
|
require 'snaptrade/models/complex_order_response_type'
|
|
98
|
+
require 'snaptrade/models/connected_asset_partner_stats'
|
|
98
99
|
require 'snaptrade/models/connection_account'
|
|
99
100
|
require 'snaptrade/models/connection_account_sync_status'
|
|
100
101
|
require 'snaptrade/models/connection_accounts_response'
|
|
@@ -28,15 +28,27 @@ describe 'ManagementApi' do
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
# unit tests for get_stats
|
|
31
|
-
# Get usage stats
|
|
32
|
-
# Returns user, connection, and connected asset totals for your SnapTrade Client ID. These are the same numbers shown on the Users & Connections page of the SnapTrade Dashboard. User and connection counts are cached for up to 5 minutes. Connected asset values come from a snapshot calculated once a day; `
|
|
31
|
+
# Get usage stats (beta)
|
|
32
|
+
# **Beta.** This endpoint and its response schema may change. Returns user, connection, and connected asset totals for your SnapTrade Client ID. These are the same numbers shown on the Users & Connections page of the SnapTrade Dashboard. User and connection counts are cached for up to 5 minutes. Connected asset values come from a snapshot calculated once a day; `connected_assets_calculated_at` indicates when it was last calculated.
|
|
33
33
|
# @param [Hash] opts the optional parameters
|
|
34
34
|
# @option opts [String] :currency ISO 4217 currency code to express connected asset values in. Defaults to `USD`.
|
|
35
|
-
# @return [
|
|
35
|
+
# @return [ConnectedAssetPartnerStats]
|
|
36
36
|
describe 'get_stats test' do
|
|
37
37
|
it 'should work' do
|
|
38
38
|
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
# unit tests for get_stats_legacy
|
|
43
|
+
# Get usage stats (deprecated)
|
|
44
|
+
# **Deprecated.** Use `GET /management/stats` for the beta response with connected asset field names. Returns user, connection, and connected asset totals for your SnapTrade Client ID. These are the same numbers shown on the Users & Connections page of the SnapTrade Dashboard. User and connection counts are cached for up to 5 minutes. Connected asset values come from a snapshot calculated once a day; `assets_under_management_calculated_at` indicates when it was last calculated.
|
|
45
|
+
# @param [Hash] opts the optional parameters
|
|
46
|
+
# @option opts [String] :currency ISO 4217 currency code to express connected asset values in. Defaults to `USD`.
|
|
47
|
+
# @return [PartnerStats]
|
|
48
|
+
describe 'get_stats_legacy test' do
|
|
49
|
+
it 'should work' do
|
|
50
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
42
54
|
end
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#SnapTrade
|
|
3
|
+
|
|
4
|
+
#Connect brokerage accounts to your app for live positions and trading. ## Rate limiting Two limits apply to requests signed with your `clientId`. The stricter one wins, and exceeding either returns `429 Too Many Requests`. - **Customer-level** — 250 requests/minute by default, scoped to your `clientId` and applied across all endpoints. Reported in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. - **Account-level** — 10 requests/minute per account, scoped to (`clientId`, `accountId`). All covered operations for one account draw on the same bucket — reading balances and reading positions share it — and enforcement does not depend on the HTTP method, so updating an account consumes the same bucket as reading it. Only enforced for Personal users, and only for integrations it has been rolled out to — it is not yet in force for every Personal integration. It also does not apply on every operation that documents a 429 below. Where it applies it is reported in `X-RateLimit-Account-Limit`, `X-RateLimit-Account-Remaining` and `X-RateLimit-Account-Reset`. Do not read the absence of those headers as proof the limit is off — some configurations omit the rate limit headers while still enforcing the limit, so header absence tells you nothing about your allowance. On a 429, `X-RateLimit-Remaining: 0` means you hit the customer-level limit and `X-RateLimit-Account-Remaining: 0` means the account-level one. Wait for the corresponding `*-Reset` value (seconds) before retrying, or fall back to exponential backoff with jitter. Not every 429 is explained by those headers. A separate per-authenticated-user limit, reported in no `X-RateLimit-*` header, covers OAuth-authenticated requests and signed requests in configurations where the customer-level limit is not in effect — on the operations that use the default throttles. A few operations override those and are governed by the customer-level limit alone. The two do not stack: a signed request governed by the customer-level limit above is not additionally subject to the per-user one. If a 429 arrives with no header at zero — or with no `X-RateLimit-*` headers at all — honour `Retry-After` and back off. Treat the remaining counts as a hint, not a guarantee that the next request will succeed. Because the customer-level limit applies everywhere, any signed request can return 429. **OAuth-authenticated requests are an exception.** They are not subject to the customer-level limit and do not receive `X-RateLimit-Limit`, `X-RateLimit-Remaining` or `X-RateLimit-Reset` — do not wait on those headers or design around a customer-level allowance on this path. The account-level limit still applies to them on the account-data endpoints above, reported in the `X-RateLimit-Account-*` headers. On operations using the default throttles the per-user limit above applies to them as well, so an OAuth request can be rejected while the account headers still show capacity; on the few operations that override those throttles, OAuth callers have no per-user ceiling at all. Drive retries from `Retry-After` and exponential backoff with jitter rather than from the headers. See https://docs.snaptrade.com/docs/ratelimiting.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
Contact: api@snaptrade.com
|
|
8
|
+
=end
|
|
9
|
+
|
|
10
|
+
require 'spec_helper'
|
|
11
|
+
require 'json'
|
|
12
|
+
require 'date'
|
|
13
|
+
|
|
14
|
+
# Unit tests for SnapTrade::ConnectedAssetPartnerStats
|
|
15
|
+
describe SnapTrade::ConnectedAssetPartnerStats do
|
|
16
|
+
let(:instance) { SnapTrade::ConnectedAssetPartnerStats.new }
|
|
17
|
+
|
|
18
|
+
describe 'test an instance of ConnectedAssetPartnerStats' do
|
|
19
|
+
it 'should create an instance of ConnectedAssetPartnerStats' do
|
|
20
|
+
expect(instance).to be_instance_of(SnapTrade::ConnectedAssetPartnerStats)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
describe 'test attribute "total_users"' do
|
|
24
|
+
it 'should work' do
|
|
25
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe 'test attribute "total_connected_users"' do
|
|
30
|
+
it 'should work' do
|
|
31
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe 'test attribute "total_active_connections"' do
|
|
36
|
+
it 'should work' do
|
|
37
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe 'test attribute "total_disabled_connections"' do
|
|
42
|
+
it 'should work' do
|
|
43
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe 'test attribute "oauth_total_users"' do
|
|
48
|
+
it 'should work' do
|
|
49
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe 'test attribute "oauth_total_connected_users"' do
|
|
54
|
+
it 'should work' do
|
|
55
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe 'test attribute "oauth_total_active_connections"' do
|
|
60
|
+
it 'should work' do
|
|
61
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe 'test attribute "oauth_total_disabled_connections"' do
|
|
66
|
+
it 'should work' do
|
|
67
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe 'test attribute "connected_assets"' do
|
|
72
|
+
it 'should work' do
|
|
73
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
describe 'test attribute "disabled_connected_assets"' do
|
|
78
|
+
it 'should work' do
|
|
79
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe 'test attribute "oauth_connected_assets"' do
|
|
84
|
+
it 'should work' do
|
|
85
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
describe 'test attribute "oauth_disabled_connected_assets"' do
|
|
90
|
+
it 'should work' do
|
|
91
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
describe 'test attribute "connected_assets_currency"' do
|
|
96
|
+
it 'should work' do
|
|
97
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
describe 'test attribute "connected_assets_calculated_at"' do
|
|
102
|
+
it 'should work' do
|
|
103
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
end
|