snaptrade 2.0.22 → 2.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +38 -2
- data/lib/snaptrade/api/connections_api.rb +103 -0
- data/lib/snaptrade/models/amount.rb +1 -1
- data/lib/snaptrade/models/brokerage_authorization_refresh_confirmation.rb +217 -0
- data/lib/snaptrade/models/model402_brokerage_auth_disabled_response.rb +228 -0
- data/lib/snaptrade/models/model403_feature_not_enabled_response.rb +228 -0
- data/lib/snaptrade/models/option_brokerage_symbol.rb +235 -0
- data/lib/snaptrade/models/options_position.rb +1 -1
- data/lib/snaptrade/models/snap_trade_holdings_total_value.rb +1 -1
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +4 -0
- data/spec/api/connections_api_spec.rb +14 -0
- data/spec/models/brokerage_authorization_refresh_confirmation_spec.rb +29 -0
- data/spec/models/model402_brokerage_auth_disabled_response_spec.rb +35 -0
- data/spec/models/model403_feature_not_enabled_response_spec.rb +35 -0
- data/spec/models/option_brokerage_symbol_spec.rb +41 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1972714969f69805cc22e43f640774a439dfa47616884f4b499e954629a2e794
|
4
|
+
data.tar.gz: 2a1c839688235913f4a11ae234c4a0f1cb8f67dfebdc45871dc965fbb7644d58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ea0918d1207fd6addc2b0591cc3e969104b882ef029533ca540a8c955f6f60d382125d5e114c21583b079dfa0af8802878a5196b5c71110e820c5c55361d3c7
|
7
|
+
data.tar.gz: c160f91c727da185a9c78b6bb1eaf639c601184c0f72fa9d3ab68f7fb015d0a714be98a98f4d0a8e8da4f5f1804aaa7fbbb276461eb9ca9a64bfb16cf64497ea
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
Connect brokerage accounts to your app for live positions and trading
|
8
8
|
|
9
|
-
[![npm](https://img.shields.io/badge/gem-v2.0.
|
9
|
+
[![npm](https://img.shields.io/badge/gem-v2.0.24-blue)](https://rubygems.org/gems/snaptrade/versions/2.0.24)
|
10
10
|
[![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/)
|
11
11
|
|
12
12
|
</div>
|
@@ -36,6 +36,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
36
36
|
* [`snaptrade.authentication.reset_snap_trade_user_secret`](#snaptradeauthenticationreset_snap_trade_user_secret)
|
37
37
|
* [`snaptrade.connections.detail_brokerage_authorization`](#snaptradeconnectionsdetail_brokerage_authorization)
|
38
38
|
* [`snaptrade.connections.list_brokerage_authorizations`](#snaptradeconnectionslist_brokerage_authorizations)
|
39
|
+
* [`snaptrade.connections.refresh_brokerage_authorization`](#snaptradeconnectionsrefresh_brokerage_authorization)
|
39
40
|
* [`snaptrade.connections.remove_brokerage_authorization`](#snaptradeconnectionsremove_brokerage_authorization)
|
40
41
|
* [`snaptrade.connections.session_events`](#snaptradeconnectionssession_events)
|
41
42
|
* [`snaptrade.options.get_option_strategy`](#snaptradeoptionsget_option_strategy)
|
@@ -69,7 +70,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
69
70
|
Add to Gemfile:
|
70
71
|
|
71
72
|
```ruby
|
72
|
-
gem 'snaptrade', '~> 2.0.
|
73
|
+
gem 'snaptrade', '~> 2.0.24'
|
73
74
|
```
|
74
75
|
|
75
76
|
## Getting Started<a id="getting-started"></a>
|
@@ -710,6 +711,41 @@ p result
|
|
710
711
|
---
|
711
712
|
|
712
713
|
|
714
|
+
### `snaptrade.connections.refresh_brokerage_authorization`<a id="snaptradeconnectionsrefresh_brokerage_authorization"></a>
|
715
|
+
|
716
|
+
Trigger a holdings update for all accounts under this authorization. Updates will be queued asynchronously. ACCOUNT_HOLDINGS_UPDATED webhook will be sent once the sync completes
|
717
|
+
|
718
|
+
#### 🛠️ Usage<a id="🛠️-usage"></a>
|
719
|
+
|
720
|
+
```ruby
|
721
|
+
result = snaptrade.connections.refresh_brokerage_authorization(
|
722
|
+
authorization_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
|
723
|
+
user_id: "snaptrade-user-123",
|
724
|
+
user_secret: "USERSECRET123",
|
725
|
+
)
|
726
|
+
p result
|
727
|
+
```
|
728
|
+
|
729
|
+
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
730
|
+
|
731
|
+
##### authorization_id: `String`<a id="authorization_id-string"></a>
|
732
|
+
The ID of a brokerage authorization object.
|
733
|
+
|
734
|
+
##### user_id: `String`<a id="user_id-string"></a>
|
735
|
+
##### user_secret: `String`<a id="user_secret-string"></a>
|
736
|
+
#### 🔄 Return<a id="🔄-return"></a>
|
737
|
+
|
738
|
+
[BrokerageAuthorizationRefreshConfirmation](./lib/snaptrade/models/brokerage_authorization_refresh_confirmation.rb)
|
739
|
+
|
740
|
+
#### 🌐 Endpoint<a id="🌐-endpoint"></a>
|
741
|
+
|
742
|
+
`/authorizations/{authorizationId}/refresh` `POST`
|
743
|
+
|
744
|
+
[🔙 **Back to Table of Contents**](#table-of-contents)
|
745
|
+
|
746
|
+
---
|
747
|
+
|
748
|
+
|
713
749
|
### `snaptrade.connections.remove_brokerage_authorization`<a id="snaptradeconnectionsremove_brokerage_authorization"></a>
|
714
750
|
|
715
751
|
Deletes a specified brokerage authorization given by the ID.
|
@@ -215,6 +215,109 @@ module SnapTrade
|
|
215
215
|
end
|
216
216
|
|
217
217
|
|
218
|
+
# Refresh holdings for a connection
|
219
|
+
#
|
220
|
+
# Trigger a holdings update for all accounts under this authorization. Updates will be queued asynchronously. ACCOUNT_HOLDINGS_UPDATED webhook will be sent once the sync completes
|
221
|
+
#
|
222
|
+
# @param authorization_id [String] The ID of a brokerage authorization object.
|
223
|
+
# @param user_id [String]
|
224
|
+
# @param user_secret [String]
|
225
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
226
|
+
def refresh_brokerage_authorization(authorization_id:, user_id:, user_secret:, extra: {})
|
227
|
+
data, _status_code, _headers = refresh_brokerage_authorization_with_http_info_impl(authorization_id, user_id, user_secret, extra)
|
228
|
+
data
|
229
|
+
end
|
230
|
+
|
231
|
+
# Refresh holdings for a connection
|
232
|
+
#
|
233
|
+
# Trigger a holdings update for all accounts under this authorization. Updates will be queued asynchronously. ACCOUNT_HOLDINGS_UPDATED webhook will be sent once the sync completes
|
234
|
+
#
|
235
|
+
# @param authorization_id [String] The ID of a brokerage authorization object.
|
236
|
+
# @param user_id [String]
|
237
|
+
# @param user_secret [String]
|
238
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
239
|
+
def refresh_brokerage_authorization_with_http_info(authorization_id:, user_id:, user_secret:, extra: {})
|
240
|
+
refresh_brokerage_authorization_with_http_info_impl(authorization_id, user_id, user_secret, extra)
|
241
|
+
end
|
242
|
+
|
243
|
+
# Refresh holdings for a connection
|
244
|
+
# Trigger a holdings update for all accounts under this authorization. Updates will be queued asynchronously. ACCOUNT_HOLDINGS_UPDATED webhook will be sent once the sync completes
|
245
|
+
# @param authorization_id [String] The ID of a brokerage authorization object.
|
246
|
+
# @param user_id [String]
|
247
|
+
# @param user_secret [String]
|
248
|
+
# @param [Hash] opts the optional parameters
|
249
|
+
# @return [BrokerageAuthorizationRefreshConfirmation]
|
250
|
+
private def refresh_brokerage_authorization_impl(authorization_id, user_id, user_secret, opts = {})
|
251
|
+
data, _status_code, _headers = refresh_brokerage_authorization_with_http_info(authorization_id, user_id, user_secret, opts)
|
252
|
+
data
|
253
|
+
end
|
254
|
+
|
255
|
+
# Refresh holdings for a connection
|
256
|
+
# Trigger a holdings update for all accounts under this authorization. Updates will be queued asynchronously. ACCOUNT_HOLDINGS_UPDATED webhook will be sent once the sync completes
|
257
|
+
# @param authorization_id [String] The ID of a brokerage authorization object.
|
258
|
+
# @param user_id [String]
|
259
|
+
# @param user_secret [String]
|
260
|
+
# @param [Hash] opts the optional parameters
|
261
|
+
# @return [Array<(BrokerageAuthorizationRefreshConfirmation, Integer, Hash)>] BrokerageAuthorizationRefreshConfirmation data, response status code and response headers
|
262
|
+
private def refresh_brokerage_authorization_with_http_info_impl(authorization_id, user_id, user_secret, opts = {})
|
263
|
+
if @api_client.config.debugging
|
264
|
+
@api_client.config.logger.debug 'Calling API: ConnectionsApi.refresh_brokerage_authorization ...'
|
265
|
+
end
|
266
|
+
# verify the required parameter 'authorization_id' is set
|
267
|
+
if @api_client.config.client_side_validation && authorization_id.nil?
|
268
|
+
fail ArgumentError, "Missing the required parameter 'authorization_id' when calling ConnectionsApi.refresh_brokerage_authorization"
|
269
|
+
end
|
270
|
+
# verify the required parameter 'user_id' is set
|
271
|
+
if @api_client.config.client_side_validation && user_id.nil?
|
272
|
+
fail ArgumentError, "Missing the required parameter 'user_id' when calling ConnectionsApi.refresh_brokerage_authorization"
|
273
|
+
end
|
274
|
+
# verify the required parameter 'user_secret' is set
|
275
|
+
if @api_client.config.client_side_validation && user_secret.nil?
|
276
|
+
fail ArgumentError, "Missing the required parameter 'user_secret' when calling ConnectionsApi.refresh_brokerage_authorization"
|
277
|
+
end
|
278
|
+
# resource path
|
279
|
+
local_var_path = '/authorizations/{authorizationId}/refresh'.sub('{' + 'authorizationId' + '}', CGI.escape(authorization_id.to_s))
|
280
|
+
|
281
|
+
# query parameters
|
282
|
+
query_params = opts[:query_params] || {}
|
283
|
+
query_params[:'userId'] = user_id
|
284
|
+
query_params[:'userSecret'] = user_secret
|
285
|
+
|
286
|
+
# header parameters
|
287
|
+
header_params = opts[:header_params] || {}
|
288
|
+
# HTTP header 'Accept' (if needed)
|
289
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
290
|
+
|
291
|
+
# form parameters
|
292
|
+
form_params = opts[:form_params] || {}
|
293
|
+
|
294
|
+
# http body (model)
|
295
|
+
post_body = opts[:debug_body]
|
296
|
+
|
297
|
+
# return_type
|
298
|
+
return_type = opts[:debug_return_type] || 'BrokerageAuthorizationRefreshConfirmation'
|
299
|
+
|
300
|
+
# auth_names
|
301
|
+
auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
|
302
|
+
|
303
|
+
new_options = opts.merge(
|
304
|
+
:operation => :"ConnectionsApi.refresh_brokerage_authorization",
|
305
|
+
:header_params => header_params,
|
306
|
+
:query_params => query_params,
|
307
|
+
:form_params => form_params,
|
308
|
+
:body => post_body,
|
309
|
+
:auth_names => auth_names,
|
310
|
+
:return_type => return_type
|
311
|
+
)
|
312
|
+
|
313
|
+
data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options)
|
314
|
+
if @api_client.config.debugging
|
315
|
+
@api_client.config.logger.debug "API called: ConnectionsApi#refresh_brokerage_authorization\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
316
|
+
end
|
317
|
+
return data, status_code, headers, response
|
318
|
+
end
|
319
|
+
|
320
|
+
|
218
321
|
# Delete brokerage authorization
|
219
322
|
#
|
220
323
|
# Deletes a specified brokerage authorization given by the ID.
|
@@ -0,0 +1,217 @@
|
|
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 BrokerageAuthorizationRefreshConfirmation
|
15
|
+
# Refresh confirmation details
|
16
|
+
attr_accessor :detail
|
17
|
+
|
18
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
19
|
+
def self.attribute_map
|
20
|
+
{
|
21
|
+
:'detail' => :'detail'
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns all the JSON keys this model knows about
|
26
|
+
def self.acceptable_attributes
|
27
|
+
attribute_map.values
|
28
|
+
end
|
29
|
+
|
30
|
+
# Attribute type mapping.
|
31
|
+
def self.openapi_types
|
32
|
+
{
|
33
|
+
:'detail' => :'String'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# List of attributes with nullable: true
|
38
|
+
def self.openapi_nullable
|
39
|
+
Set.new([
|
40
|
+
])
|
41
|
+
end
|
42
|
+
|
43
|
+
# Initializes the object
|
44
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
45
|
+
def initialize(attributes = {})
|
46
|
+
if (!attributes.is_a?(Hash))
|
47
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::BrokerageAuthorizationRefreshConfirmation` initialize method"
|
48
|
+
end
|
49
|
+
|
50
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
51
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
52
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
53
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::BrokerageAuthorizationRefreshConfirmation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
54
|
+
end
|
55
|
+
h[k.to_sym] = v
|
56
|
+
}
|
57
|
+
|
58
|
+
if attributes.key?(:'detail')
|
59
|
+
self.detail = attributes[:'detail']
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
64
|
+
# @return Array for valid properties with the reasons
|
65
|
+
def list_invalid_properties
|
66
|
+
invalid_properties = Array.new
|
67
|
+
invalid_properties
|
68
|
+
end
|
69
|
+
|
70
|
+
# Check to see if the all the properties in the model are valid
|
71
|
+
# @return true if the model is valid
|
72
|
+
def valid?
|
73
|
+
true
|
74
|
+
end
|
75
|
+
|
76
|
+
# Checks equality by comparing each attribute.
|
77
|
+
# @param [Object] Object to be compared
|
78
|
+
def ==(o)
|
79
|
+
return true if self.equal?(o)
|
80
|
+
self.class == o.class &&
|
81
|
+
detail == o.detail
|
82
|
+
end
|
83
|
+
|
84
|
+
# @see the `==` method
|
85
|
+
# @param [Object] Object to be compared
|
86
|
+
def eql?(o)
|
87
|
+
self == o
|
88
|
+
end
|
89
|
+
|
90
|
+
# Calculates hash code according to all attributes.
|
91
|
+
# @return [Integer] Hash code
|
92
|
+
def hash
|
93
|
+
[detail].hash
|
94
|
+
end
|
95
|
+
|
96
|
+
# Builds the object from hash
|
97
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
98
|
+
# @return [Object] Returns the model itself
|
99
|
+
def self.build_from_hash(attributes)
|
100
|
+
new.build_from_hash(attributes)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Builds the object from hash
|
104
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
105
|
+
# @return [Object] Returns the model itself
|
106
|
+
def build_from_hash(attributes)
|
107
|
+
return nil unless attributes.is_a?(Hash)
|
108
|
+
attributes = attributes.transform_keys(&:to_sym)
|
109
|
+
self.class.openapi_types.each_pair do |key, type|
|
110
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
111
|
+
self.send("#{key}=", nil)
|
112
|
+
elsif type =~ /\AArray<(.*)>/i
|
113
|
+
# check to ensure the input is an array given that the attribute
|
114
|
+
# is documented as an array but the input is not
|
115
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
116
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
117
|
+
end
|
118
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
119
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
self
|
124
|
+
end
|
125
|
+
|
126
|
+
# Deserializes the data based on type
|
127
|
+
# @param string type Data type
|
128
|
+
# @param string value Value to be deserialized
|
129
|
+
# @return [Object] Deserialized data
|
130
|
+
def _deserialize(type, value)
|
131
|
+
case type.to_sym
|
132
|
+
when :Time
|
133
|
+
Time.parse(value)
|
134
|
+
when :Date
|
135
|
+
Date.parse(value)
|
136
|
+
when :String
|
137
|
+
value.to_s
|
138
|
+
when :Integer
|
139
|
+
value.to_i
|
140
|
+
when :Float
|
141
|
+
value.to_f
|
142
|
+
when :Boolean
|
143
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
144
|
+
true
|
145
|
+
else
|
146
|
+
false
|
147
|
+
end
|
148
|
+
when :Object
|
149
|
+
# generic object (usually a Hash), return directly
|
150
|
+
value
|
151
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
152
|
+
inner_type = Regexp.last_match[:inner_type]
|
153
|
+
value.map { |v| _deserialize(inner_type, v) }
|
154
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
155
|
+
k_type = Regexp.last_match[:k_type]
|
156
|
+
v_type = Regexp.last_match[:v_type]
|
157
|
+
{}.tap do |hash|
|
158
|
+
value.each do |k, v|
|
159
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
else # model
|
163
|
+
# models (e.g. Pet) or oneOf
|
164
|
+
klass = SnapTrade.const_get(type)
|
165
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# Returns the string representation of the object
|
170
|
+
# @return [String] String presentation of the object
|
171
|
+
def to_s
|
172
|
+
to_hash.to_s
|
173
|
+
end
|
174
|
+
|
175
|
+
# to_body is an alias to to_hash (backward compatibility)
|
176
|
+
# @return [Hash] Returns the object in the form of hash
|
177
|
+
def to_body
|
178
|
+
to_hash
|
179
|
+
end
|
180
|
+
|
181
|
+
# Returns the object in the form of hash
|
182
|
+
# @return [Hash] Returns the object in the form of hash
|
183
|
+
def to_hash
|
184
|
+
hash = {}
|
185
|
+
self.class.attribute_map.each_pair do |attr, param|
|
186
|
+
value = self.send(attr)
|
187
|
+
if value.nil?
|
188
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
189
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
190
|
+
end
|
191
|
+
|
192
|
+
hash[param] = _to_hash(value)
|
193
|
+
end
|
194
|
+
hash
|
195
|
+
end
|
196
|
+
|
197
|
+
# Outputs non-array value in the form of hash
|
198
|
+
# For object, use to_hash. Otherwise, just return the value
|
199
|
+
# @param [Object] value Any valid value
|
200
|
+
# @return [Hash] Returns the value in the form of hash
|
201
|
+
def _to_hash(value)
|
202
|
+
if value.is_a?(Array)
|
203
|
+
value.compact.map { |v| _to_hash(v) }
|
204
|
+
elsif value.is_a?(Hash)
|
205
|
+
{}.tap do |hash|
|
206
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
207
|
+
end
|
208
|
+
elsif value.respond_to? :to_hash
|
209
|
+
value.to_hash
|
210
|
+
else
|
211
|
+
value
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
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
|
+
# Cannot perform action because connection is disabled
|
15
|
+
class Model402BrokerageAuthDisabledResponse
|
16
|
+
attr_accessor :detail
|
17
|
+
|
18
|
+
attr_accessor :code
|
19
|
+
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
21
|
+
def self.attribute_map
|
22
|
+
{
|
23
|
+
:'detail' => :'detail',
|
24
|
+
:'code' => :'code'
|
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
|
+
:'detail' => :'Object',
|
37
|
+
:'code' => :'Object'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
# List of attributes with nullable: true
|
42
|
+
def self.openapi_nullable
|
43
|
+
Set.new([
|
44
|
+
:'detail',
|
45
|
+
:'code'
|
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::Model402BrokerageAuthDisabledResponse` 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::Model402BrokerageAuthDisabledResponse`. 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?(:'detail')
|
65
|
+
self.detail = attributes[:'detail']
|
66
|
+
end
|
67
|
+
|
68
|
+
if attributes.key?(:'code')
|
69
|
+
self.code = attributes[:'code']
|
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
|
+
detail == o.detail &&
|
92
|
+
code == o.code
|
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
|
+
[detail, code].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
|