snaptrade 3.0.4 → 3.0.6
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 +4 -4
- data/lib/snaptrade/api/experimental_endpoints_api.rb +6 -6
- 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/o_auth_webhook_base.rb +341 -0
- data/lib/snaptrade/models/schema_version.rb +36 -0
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +5 -0
- data/spec/api/experimental_endpoints_api_spec.rb +1 -1
- 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/o_auth_webhook_base_spec.rb +89 -0
- data/spec/models/schema_version_spec.rb +23 -0
- metadata +217 -202
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 33ffcead2b0b233863ba95f328820529c973e1896daeaf094057d1b622bbc0e4
|
|
4
|
+
data.tar.gz: 5b5cbe5195457fc1d3a474555d67f949d35e3c9d9cadae4a4063f1e4410c7677
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 228ff904386baeb904841f969514d387af852716fd067b81d6d05e5d504226888c55469b909e0fdaf26432230cd338f218c0ac8e24af24fc0728885e5c919736
|
|
7
|
+
data.tar.gz: ee645d458616b0bb16a1bf956247c54e95905b17f46029f3613c46237476ce6320484c4dcba94304410715f5602727f1be65a4a9933a55d51630c33019309ba8
|
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
|
-
[](https://rubygems.org/gems/snaptrade/versions/3.0.6)
|
|
10
10
|
[](https://snaptrade.com/)
|
|
11
11
|
|
|
12
12
|
</div>
|
|
@@ -83,7 +83,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
|
83
83
|
Add to Gemfile:
|
|
84
84
|
|
|
85
85
|
```ruby
|
|
86
|
-
gem 'snaptrade', '~> 3.0.
|
|
86
|
+
gem 'snaptrade', '~> 3.0.6'
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
## Getting Started<a id="getting-started"></a>
|
|
@@ -1443,9 +1443,9 @@ Experimental and subject to change without notice.
|
|
|
1443
1443
|
|
|
1444
1444
|
Returns the accounts that belong to the specified connection for the authenticated user, using the `kind`-discriminated account shape.
|
|
1445
1445
|
|
|
1446
|
-
Each item in the response carries a `kind` field (currently
|
|
1446
|
+
Each item in the response carries a `kind` field (currently `investment` and `deposit` are implemented) that determines which additional fields are present -- see the `ConnectionAccount` schema.
|
|
1447
1447
|
|
|
1448
|
-
On Pay as you Go / Real-time, this endpoint refreshes each account's opening date
|
|
1448
|
+
On Pay as you Go / Real-time, this endpoint refreshes each account's opening date and total balance (`market_value` for `investment`, `balance` for `deposit`) live from the brokerage on each call, along with funding date for `investment` accounts.
|
|
1449
1449
|
|
|
1450
1450
|
On Pay as you Go / Daily, this endpoint returns Daily data. Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. To force a refresh, use the [manual refresh endpoint](/reference/Connections/Connections_refreshBrokerageAuthorization).
|
|
1451
1451
|
|
|
@@ -625,9 +625,9 @@ module SnapTrade
|
|
|
625
625
|
#
|
|
626
626
|
# Returns the accounts that belong to the specified connection for the authenticated user, using the `kind`-discriminated account shape.
|
|
627
627
|
#
|
|
628
|
-
# Each item in the response carries a `kind` field (currently
|
|
628
|
+
# Each item in the response carries a `kind` field (currently `investment` and `deposit` are implemented) that determines which additional fields are present -- see the `ConnectionAccount` schema.
|
|
629
629
|
#
|
|
630
|
-
# On Pay as you Go / Real-time, this endpoint refreshes each account's opening date
|
|
630
|
+
# On Pay as you Go / Real-time, this endpoint refreshes each account's opening date and total balance (`market_value` for `investment`, `balance` for `deposit`) live from the brokerage on each call, along with funding date for `investment` accounts.
|
|
631
631
|
#
|
|
632
632
|
# On Pay as you Go / Daily, this endpoint returns Daily data. Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. To force a refresh, use the [manual refresh endpoint](/reference/Connections/Connections_refreshBrokerageAuthorization).
|
|
633
633
|
#
|
|
@@ -648,9 +648,9 @@ module SnapTrade
|
|
|
648
648
|
#
|
|
649
649
|
# Returns the accounts that belong to the specified connection for the authenticated user, using the `kind`-discriminated account shape.
|
|
650
650
|
#
|
|
651
|
-
# Each item in the response carries a `kind` field (currently
|
|
651
|
+
# Each item in the response carries a `kind` field (currently `investment` and `deposit` are implemented) that determines which additional fields are present -- see the `ConnectionAccount` schema.
|
|
652
652
|
#
|
|
653
|
-
# On Pay as you Go / Real-time, this endpoint refreshes each account's opening date
|
|
653
|
+
# On Pay as you Go / Real-time, this endpoint refreshes each account's opening date and total balance (`market_value` for `investment`, `balance` for `deposit`) live from the brokerage on each call, along with funding date for `investment` accounts.
|
|
654
654
|
#
|
|
655
655
|
# On Pay as you Go / Daily, this endpoint returns Daily data. Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. To force a refresh, use the [manual refresh endpoint](/reference/Connections/Connections_refreshBrokerageAuthorization).
|
|
656
656
|
#
|
|
@@ -665,7 +665,7 @@ module SnapTrade
|
|
|
665
665
|
end
|
|
666
666
|
|
|
667
667
|
# List accounts for a connection (discriminated union)
|
|
668
|
-
# Experimental and subject to change without notice. Returns the accounts that belong to the specified connection for the authenticated user, using the `kind`-discriminated account shape. Each item in the response carries a `kind` field (currently
|
|
668
|
+
# Experimental and subject to change without notice. Returns the accounts that belong to the specified connection for the authenticated user, using the `kind`-discriminated account shape. Each item in the response carries a `kind` field (currently `investment` and `deposit` are implemented) that determines which additional fields are present -- see the `ConnectionAccount` schema. On Pay as you Go / Real-time, this endpoint refreshes each account's opening date and total balance (`market_value` for `investment`, `balance` for `deposit`) live from the brokerage on each call, along with funding date for `investment` accounts. On Pay as you Go / Daily, this endpoint returns Daily data. Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. To force a refresh, use the [manual refresh endpoint](/reference/Connections/Connections_refreshBrokerageAuthorization). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see whether your plan includes real-time data.
|
|
669
669
|
# @param authorization_id [String]
|
|
670
670
|
# @param user_id [String]
|
|
671
671
|
# @param user_secret [String]
|
|
@@ -677,7 +677,7 @@ module SnapTrade
|
|
|
677
677
|
end
|
|
678
678
|
|
|
679
679
|
# List accounts for a connection (discriminated union)
|
|
680
|
-
# Experimental and subject to change without notice. Returns the accounts that belong to the specified connection for the authenticated user, using the `kind`-discriminated account shape. Each item in the response carries a `kind` field (currently
|
|
680
|
+
# Experimental and subject to change without notice. Returns the accounts that belong to the specified connection for the authenticated user, using the `kind`-discriminated account shape. Each item in the response carries a `kind` field (currently `investment` and `deposit` are implemented) that determines which additional fields are present -- see the `ConnectionAccount` schema. On Pay as you Go / Real-time, this endpoint refreshes each account's opening date and total balance (`market_value` for `investment`, `balance` for `deposit`) live from the brokerage on each call, along with funding date for `investment` accounts. On Pay as you Go / Daily, this endpoint returns Daily data. Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. To force a refresh, use the [manual refresh endpoint](/reference/Connections/Connections_refreshBrokerageAuthorization). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see whether your plan includes real-time data.
|
|
681
681
|
# @param authorization_id [String]
|
|
682
682
|
# @param user_id [String]
|
|
683
683
|
# @param user_secret [String]
|
|
@@ -11,12 +11,13 @@ require 'date'
|
|
|
11
11
|
require 'time'
|
|
12
12
|
|
|
13
13
|
module SnapTrade
|
|
14
|
-
# A single account under a connection, from the `kind`-discriminated union used by `Connections_listConnectionAccounts`. Use `kind` to determine which schema is present.
|
|
14
|
+
# A single account under a connection, from the `kind`-discriminated union used by `Connections_listConnectionAccounts`. Use `kind` to determine which schema is present. `investment` and `deposit` are implemented today; `line_of_credit` will be added as an additional variant in a future release.
|
|
15
15
|
module ConnectionAccount
|
|
16
16
|
class << self
|
|
17
17
|
# List of class defined in oneOf (OpenAPI v3)
|
|
18
18
|
def openapi_one_of
|
|
19
19
|
[
|
|
20
|
+
:'DepositAccount',
|
|
20
21
|
:'InvestmentAccount'
|
|
21
22
|
]
|
|
22
23
|
end
|
|
@@ -29,6 +30,7 @@ module SnapTrade
|
|
|
29
30
|
# Discriminator's mapping (OpenAPI v3)
|
|
30
31
|
def openapi_discriminator_mapping
|
|
31
32
|
{
|
|
33
|
+
:'deposit' => :'DepositAccount',
|
|
32
34
|
:'investment' => :'InvestmentAccount'
|
|
33
35
|
}
|
|
34
36
|
end
|
|
@@ -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
|