snaptrade 2.0.166 → 2.0.168

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.
@@ -125,125 +125,13 @@ module SnapTrade
125
125
  end
126
126
 
127
127
 
128
- # Get the options chain for a symbol
129
- #
130
- # Returns the option chain for the specified symbol in the specified account.
131
- #
132
- # @param user_id [String]
133
- # @param user_secret [String]
134
- # @param account_id [String] The ID of the account to get the options chain from.
135
- # @param symbol [String] Universal symbol ID if symbol
136
- # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
137
- def get_options_chain(user_id:, user_secret:, account_id:, symbol:, extra: {})
138
- data, _status_code, _headers = get_options_chain_with_http_info_impl(user_id, user_secret, account_id, symbol, extra)
139
- data
140
- end
141
-
142
- # Get the options chain for a symbol
143
- #
144
- # Returns the option chain for the specified symbol in the specified account.
145
- #
146
- # @param user_id [String]
147
- # @param user_secret [String]
148
- # @param account_id [String] The ID of the account to get the options chain from.
149
- # @param symbol [String] Universal symbol ID if symbol
150
- # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
151
- def get_options_chain_with_http_info(user_id:, user_secret:, account_id:, symbol:, extra: {})
152
- get_options_chain_with_http_info_impl(user_id, user_secret, account_id, symbol, extra)
153
- end
154
-
155
- # Get the options chain for a symbol
156
- # Returns the option chain for the specified symbol in the specified account.
157
- # @param user_id [String]
158
- # @param user_secret [String]
159
- # @param account_id [String] The ID of the account to get the options chain from.
160
- # @param symbol [String] Universal symbol ID if symbol
161
- # @param [Hash] opts the optional parameters
162
- # @return [Array<OptionChainInner>]
163
- private def get_options_chain_impl(user_id, user_secret, account_id, symbol, opts = {})
164
- data, _status_code, _headers = get_options_chain_with_http_info(user_id, user_secret, account_id, symbol, opts)
165
- data
166
- end
167
-
168
- # Get the options chain for a symbol
169
- # Returns the option chain for the specified symbol in the specified account.
170
- # @param user_id [String]
171
- # @param user_secret [String]
172
- # @param account_id [String] The ID of the account to get the options chain from.
173
- # @param symbol [String] Universal symbol ID if symbol
174
- # @param [Hash] opts the optional parameters
175
- # @return [Array<(Array<OptionChainInner>, Integer, Hash)>] Array<OptionChainInner> data, response status code and response headers
176
- private def get_options_chain_with_http_info_impl(user_id, user_secret, account_id, symbol, opts = {})
177
- if @api_client.config.debugging
178
- @api_client.config.logger.debug 'Calling API: OptionsApi.get_options_chain ...'
179
- end
180
- # verify the required parameter 'user_id' is set
181
- if @api_client.config.client_side_validation && user_id.nil?
182
- fail ArgumentError, "Missing the required parameter 'user_id' when calling OptionsApi.get_options_chain"
183
- end
184
- # verify the required parameter 'user_secret' is set
185
- if @api_client.config.client_side_validation && user_secret.nil?
186
- fail ArgumentError, "Missing the required parameter 'user_secret' when calling OptionsApi.get_options_chain"
187
- end
188
- # verify the required parameter 'account_id' is set
189
- if @api_client.config.client_side_validation && account_id.nil?
190
- fail ArgumentError, "Missing the required parameter 'account_id' when calling OptionsApi.get_options_chain"
191
- end
192
- # verify the required parameter 'symbol' is set
193
- if @api_client.config.client_side_validation && symbol.nil?
194
- fail ArgumentError, "Missing the required parameter 'symbol' when calling OptionsApi.get_options_chain"
195
- end
196
- # resource path
197
- local_var_path = '/accounts/{accountId}/optionsChain'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
198
-
199
- # query parameters
200
- query_params = opts[:query_params] || {}
201
- query_params[:'userId'] = user_id
202
- query_params[:'userSecret'] = user_secret
203
- query_params[:'symbol'] = symbol
204
-
205
- # header parameters
206
- header_params = opts[:header_params] || {}
207
- # HTTP header 'Accept' (if needed)
208
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
209
-
210
- # form parameters
211
- form_params = opts[:form_params] || {}
212
-
213
- # http body (model)
214
- post_body = opts[:debug_body]
215
-
216
- # return_type
217
- return_type = opts[:debug_return_type] || 'Array<OptionChainInner>'
218
-
219
- # auth_names
220
- auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
221
-
222
- new_options = opts.merge(
223
- :operation => :"OptionsApi.get_options_chain",
224
- :header_params => header_params,
225
- :query_params => query_params,
226
- :form_params => form_params,
227
- :body => post_body,
228
- :auth_names => auth_names,
229
- :return_type => return_type
230
- )
231
-
232
- data, status_code, headers, response = @api_client.call_api(:GET, local_var_path, new_options)
233
- if @api_client.config.debugging
234
- @api_client.config.logger.debug "API called: OptionsApi#get_options_chain\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
235
- end
236
- return data, status_code, headers, response
237
- end
238
-
239
-
240
128
  # List account option positions
241
129
  #
242
130
  # Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions).
243
131
  #
244
132
  # Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access:
245
133
  # - If you do, this endpoint returns real-time data.
246
- # - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint.
134
+ # - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://support.snaptrade.com/brokerages-table?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint.
247
135
  #
248
136
  # @param user_id [String]
249
137
  # @param user_secret [String]
@@ -260,7 +148,7 @@ module SnapTrade
260
148
  #
261
149
  # Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access:
262
150
  # - If you do, this endpoint returns real-time data.
263
- # - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint.
151
+ # - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://support.snaptrade.com/brokerages-table?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint.
264
152
  #
265
153
  # @param user_id [String]
266
154
  # @param user_secret [String]
@@ -271,7 +159,7 @@ module SnapTrade
271
159
  end
272
160
 
273
161
  # List account option positions
274
- # Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint.
162
+ # Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don't, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://support.snaptrade.com/brokerages-table?v=d16c4c97b8d5438bbb2d8581ac53b11e) and look for \"Cache Expiry Time\" to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint.
275
163
  # @param user_id [String]
276
164
  # @param user_secret [String]
277
165
  # @param account_id [String]
@@ -283,7 +171,7 @@ module SnapTrade
283
171
  end
284
172
 
285
173
  # List account option positions
286
- # Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don&#39;t, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v&#x3D;d16c4c97b8d5438bbb2d8581ac53b11e) and look for \&quot;Cache Expiry Time\&quot; to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint.
174
+ # Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the [positions endpoint](/reference/Account%20Information/AccountInformation_getUserAccountPositions). Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don&#39;t, the data is cached and refreshed once a day. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://support.snaptrade.com/brokerages-table?v&#x3D;d16c4c97b8d5438bbb2d8581ac53b11e) and look for \&quot;Cache Expiry Time\&quot; to see the exact value for a specific brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint.
287
175
  # @param user_id [String]
288
176
  # @param user_secret [String]
289
177
  # @param account_id [String]
@@ -381,7 +381,7 @@ module SnapTrade
381
381
  # Get option order impact
382
382
  #
383
383
  # Simulates an option order with up to 4 legs and returns the estimated cost and transaction fees without placing it.
384
- # Only supported for certain brokerages. Please refer to https://snaptrade.notion.site/brokerages for more information on brokerage trading support.
384
+ # Only supported for certain brokerages. Please refer to https://support.snaptrade.com/brokerages for more information on brokerage trading support.
385
385
  #
386
386
  # @param order_type [MlegOrderTypeStrict] The type of order to place.
387
387
  # @param time_in_force [TimeInForceStrict] The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.
@@ -410,7 +410,7 @@ module SnapTrade
410
410
  # Get option order impact
411
411
  #
412
412
  # Simulates an option order with up to 4 legs and returns the estimated cost and transaction fees without placing it.
413
- # Only supported for certain brokerages. Please refer to https://snaptrade.notion.site/brokerages for more information on brokerage trading support.
413
+ # Only supported for certain brokerages. Please refer to https://support.snaptrade.com/brokerages for more information on brokerage trading support.
414
414
  #
415
415
  # @param order_type [MlegOrderTypeStrict] The type of order to place.
416
416
  # @param time_in_force [TimeInForceStrict] The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.
@@ -436,7 +436,7 @@ module SnapTrade
436
436
  end
437
437
 
438
438
  # Get option order impact
439
- # Simulates an option order with up to 4 legs and returns the estimated cost and transaction fees without placing it. Only supported for certain brokerages. Please refer to https://snaptrade.notion.site/brokerages for more information on brokerage trading support.
439
+ # Simulates an option order with up to 4 legs and returns the estimated cost and transaction fees without placing it. Only supported for certain brokerages. Please refer to https://support.snaptrade.com/brokerages for more information on brokerage trading support.
440
440
  # @param user_id [String]
441
441
  # @param user_secret [String]
442
442
  # @param account_id [String]
@@ -449,7 +449,7 @@ module SnapTrade
449
449
  end
450
450
 
451
451
  # Get option order impact
452
- # Simulates an option order with up to 4 legs and returns the estimated cost and transaction fees without placing it. Only supported for certain brokerages. Please refer to https://snaptrade.notion.site/brokerages for more information on brokerage trading support.
452
+ # Simulates an option order with up to 4 legs and returns the estimated cost and transaction fees without placing it. Only supported for certain brokerages. Please refer to https://support.snaptrade.com/brokerages for more information on brokerage trading support.
453
453
  # @param user_id [String]
454
454
  # @param user_secret [String]
455
455
  # @param account_id [String]
@@ -1289,7 +1289,7 @@ module SnapTrade
1289
1289
 
1290
1290
  # Place option order
1291
1291
  #
1292
- # Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support
1292
+ # Places a multi-leg option order. Only supported on certain option trading brokerages. https://support.snaptrade.com/brokerages has information on brokerage trading support
1293
1293
  #
1294
1294
  # @param order_type [MlegOrderTypeStrict] The type of order to place.
1295
1295
  # @param time_in_force [TimeInForceStrict] The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.
@@ -1317,7 +1317,7 @@ module SnapTrade
1317
1317
 
1318
1318
  # Place option order
1319
1319
  #
1320
- # Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support
1320
+ # Places a multi-leg option order. Only supported on certain option trading brokerages. https://support.snaptrade.com/brokerages has information on brokerage trading support
1321
1321
  #
1322
1322
  # @param order_type [MlegOrderTypeStrict] The type of order to place.
1323
1323
  # @param time_in_force [TimeInForceStrict] The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.
@@ -1343,7 +1343,7 @@ module SnapTrade
1343
1343
  end
1344
1344
 
1345
1345
  # Place option order
1346
- # Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support
1346
+ # Places a multi-leg option order. Only supported on certain option trading brokerages. https://support.snaptrade.com/brokerages has information on brokerage trading support
1347
1347
  # @param user_id [String]
1348
1348
  # @param user_secret [String]
1349
1349
  # @param account_id [String]
@@ -1356,7 +1356,7 @@ module SnapTrade
1356
1356
  end
1357
1357
 
1358
1358
  # Place option order
1359
- # Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support
1359
+ # Places a multi-leg option order. Only supported on certain option trading brokerages. https://support.snaptrade.com/brokerages has information on brokerage trading support
1360
1360
  # @param user_id [String]
1361
1361
  # @param user_secret [String]
1362
1362
  # @param account_id [String]
@@ -40,7 +40,7 @@ module SnapTrade
40
40
  # A human-readable description of the transaction. This is usually the brokerage's description of the transaction.
41
41
  attr_accessor :description
42
42
 
43
- # The recorded time for the transaction. The granularity of this timestamp depends on the brokerage. Some brokerages provide the exact time of the transaction, while others provide only the date. Please check the [integrations page](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=6fab8012ade6441fa0c6d9af9c55ce3a) for the specific brokerage to see the granularity of the timestamps. Note that even though the field is named `trade_date`, it can represent any type of transaction, not just trades.
43
+ # The recorded time for the transaction. The granularity of this timestamp depends on the brokerage. Some brokerages provide the exact time of the transaction, while others provide only the date. Please check the [integrations page](https://support.snaptrade.com/brokerages-table?v=6fab8012ade6441fa0c6d9af9c55ce3a) for the specific brokerage to see the granularity of the timestamps. Note that even though the field is named `trade_date`, it can represent any type of transaction, not just trades.
44
44
  attr_accessor :trade_date
45
45
 
46
46
  # The date on which the transaction is settled.
@@ -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
+ # The estimeated account value at a specific point in time.
15
+ class AccountValueHistoryItem
16
+ # The date of the estimated account value
17
+ attr_accessor :date
18
+
19
+ # Estimate of the total market value of this account (includes cash, equity, fixed income, etc) at the given date.
20
+ attr_accessor :total_value
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'date' => :'date',
26
+ :'total_value' => :'total_value'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'date' => :'Date',
39
+ :'total_value' => :'String'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
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::AccountValueHistoryItem` 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::AccountValueHistoryItem`. 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?(:'date')
65
+ self.date = attributes[:'date']
66
+ end
67
+
68
+ if attributes.key?(:'total_value')
69
+ self.total_value = attributes[:'total_value']
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
+ date == o.date &&
92
+ total_value == o.total_value
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
+ [date, total_value].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