snaptrade 2.0.144 → 2.0.146

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.
@@ -0,0 +1,273 @@
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 'cgi'
11
+
12
+ module SnapTrade
13
+ class ExperimentalEndpointsApi
14
+ attr_accessor :api_client
15
+
16
+ def initialize(api_client = ApiClient.default)
17
+ @api_client = api_client
18
+ end
19
+
20
+ # List account orders v2
21
+ #
22
+ # Returns a list of recent orders in the specified account.
23
+ #
24
+ # The V2 order response format will include all legs of each order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg.
25
+ #
26
+ # If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection.
27
+ #
28
+ # @param user_id [String]
29
+ # @param user_secret [String]
30
+ # @param account_id [String]
31
+ # @param state [String] defaults value is set to \"all\"
32
+ # @param days [Integer] Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in.
33
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
34
+ def get_user_account_orders_v2(user_id:, user_secret:, account_id:, state: SENTINEL, days: SENTINEL, extra: {})
35
+ extra[:state] = state if state != SENTINEL
36
+ extra[:days] = days if days != SENTINEL
37
+ data, _status_code, _headers = get_user_account_orders_v2_with_http_info_impl(user_id, user_secret, account_id, extra)
38
+ data
39
+ end
40
+
41
+ # List account orders v2
42
+ #
43
+ # Returns a list of recent orders in the specified account.
44
+ #
45
+ # The V2 order response format will include all legs of each order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg.
46
+ #
47
+ # If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection.
48
+ #
49
+ # @param user_id [String]
50
+ # @param user_secret [String]
51
+ # @param account_id [String]
52
+ # @param state [String] defaults value is set to \"all\"
53
+ # @param days [Integer] Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in.
54
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
55
+ def get_user_account_orders_v2_with_http_info(user_id:, user_secret:, account_id:, state: SENTINEL, days: SENTINEL, extra: {})
56
+ extra[:state] = state if state != SENTINEL
57
+ extra[:days] = days if days != SENTINEL
58
+ get_user_account_orders_v2_with_http_info_impl(user_id, user_secret, account_id, extra)
59
+ end
60
+
61
+ # List account orders v2
62
+ # Returns a list of recent orders in the specified account. The V2 order response format will include all legs of each order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection.
63
+ # @param user_id [String]
64
+ # @param user_secret [String]
65
+ # @param account_id [String]
66
+ # @param [Hash] opts the optional parameters
67
+ # @option opts [String] :state defaults value is set to \"all\"
68
+ # @option opts [Integer] :days Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in.
69
+ # @return [AccountOrdersV2Response]
70
+ private def get_user_account_orders_v2_impl(user_id, user_secret, account_id, opts = {})
71
+ data, _status_code, _headers = get_user_account_orders_v2_with_http_info(user_id, user_secret, account_id, opts)
72
+ data
73
+ end
74
+
75
+ # List account orders v2
76
+ # Returns a list of recent orders in the specified account. The V2 order response format will include all legs of each order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection.
77
+ # @param user_id [String]
78
+ # @param user_secret [String]
79
+ # @param account_id [String]
80
+ # @param [Hash] opts the optional parameters
81
+ # @option opts [String] :state defaults value is set to \"all\"
82
+ # @option opts [Integer] :days Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in.
83
+ # @return [Array<(AccountOrdersV2Response, Integer, Hash)>] AccountOrdersV2Response data, response status code and response headers
84
+ private def get_user_account_orders_v2_with_http_info_impl(user_id, user_secret, account_id, opts = {})
85
+ if @api_client.config.debugging
86
+ @api_client.config.logger.debug 'Calling API: ExperimentalEndpointsApi.get_user_account_orders_v2 ...'
87
+ end
88
+ # verify the required parameter 'user_id' is set
89
+ if @api_client.config.client_side_validation && user_id.nil?
90
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling ExperimentalEndpointsApi.get_user_account_orders_v2"
91
+ end
92
+ # verify the required parameter 'user_secret' is set
93
+ if @api_client.config.client_side_validation && user_secret.nil?
94
+ fail ArgumentError, "Missing the required parameter 'user_secret' when calling ExperimentalEndpointsApi.get_user_account_orders_v2"
95
+ end
96
+ # verify the required parameter 'account_id' is set
97
+ if @api_client.config.client_side_validation && account_id.nil?
98
+ fail ArgumentError, "Missing the required parameter 'account_id' when calling ExperimentalEndpointsApi.get_user_account_orders_v2"
99
+ end
100
+ allowable_values = ["all", "open", "executed"]
101
+ if @api_client.config.client_side_validation && opts[:'state'] && !allowable_values.include?(opts[:'state'])
102
+ fail ArgumentError, "invalid value for \"state\", must be one of #{allowable_values}"
103
+ end
104
+ if @api_client.config.client_side_validation && !opts[:'days'].nil? && opts[:'days'] < 1
105
+ fail ArgumentError, 'invalid value for "opts[:"days"]" when calling ExperimentalEndpointsApi.get_user_account_orders_v2, must be greater than or equal to 1.'
106
+ end
107
+
108
+ # resource path
109
+ local_var_path = '/accounts/{accountId}/orders/v2'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
110
+
111
+ # query parameters
112
+ query_params = opts[:query_params] || {}
113
+ query_params[:'userId'] = user_id
114
+ query_params[:'userSecret'] = user_secret
115
+ query_params[:'state'] = opts[:'state'] if !opts[:'state'].nil?
116
+ query_params[:'days'] = opts[:'days'] if !opts[:'days'].nil?
117
+
118
+ # header parameters
119
+ header_params = opts[:header_params] || {}
120
+ # HTTP header 'Accept' (if needed)
121
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
122
+
123
+ # form parameters
124
+ form_params = opts[:form_params] || {}
125
+
126
+ # http body (model)
127
+ post_body = opts[:debug_body]
128
+
129
+ # return_type
130
+ return_type = opts[:debug_return_type] || 'AccountOrdersV2Response'
131
+
132
+ # auth_names
133
+ auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
134
+
135
+ new_options = opts.merge(
136
+ :operation => :"ExperimentalEndpointsApi.get_user_account_orders_v2",
137
+ :header_params => header_params,
138
+ :query_params => query_params,
139
+ :form_params => form_params,
140
+ :body => post_body,
141
+ :auth_names => auth_names,
142
+ :return_type => return_type
143
+ )
144
+
145
+ data, status_code, headers, response = @api_client.call_api(:GET, local_var_path, new_options)
146
+ if @api_client.config.debugging
147
+ @api_client.config.logger.debug "API called: ExperimentalEndpointsApi#get_user_account_orders_v2\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
148
+ end
149
+ return data, status_code, headers, response
150
+ end
151
+
152
+
153
+ # List account recent orders (V2, last 24 hours only)
154
+ #
155
+ # A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account using the V2 order format.
156
+ # This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders.
157
+ # Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days.
158
+ # By default only returns executed orders, but that can be changed by setting *only_executed* to false.
159
+ # **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)**
160
+ #
161
+ # @param user_id [String]
162
+ # @param user_secret [String]
163
+ # @param account_id [String]
164
+ # @param only_executed [Boolean] Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well
165
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
166
+ def get_user_account_recent_orders_v2(user_id:, user_secret:, account_id:, only_executed: SENTINEL, extra: {})
167
+ extra[:only_executed] = only_executed if only_executed != SENTINEL
168
+ data, _status_code, _headers = get_user_account_recent_orders_v2_with_http_info_impl(user_id, user_secret, account_id, extra)
169
+ data
170
+ end
171
+
172
+ # List account recent orders (V2, last 24 hours only)
173
+ #
174
+ # A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account using the V2 order format.
175
+ # This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders.
176
+ # Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days.
177
+ # By default only returns executed orders, but that can be changed by setting *only_executed* to false.
178
+ # **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)**
179
+ #
180
+ # @param user_id [String]
181
+ # @param user_secret [String]
182
+ # @param account_id [String]
183
+ # @param only_executed [Boolean] Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well
184
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
185
+ def get_user_account_recent_orders_v2_with_http_info(user_id:, user_secret:, account_id:, only_executed: SENTINEL, extra: {})
186
+ extra[:only_executed] = only_executed if only_executed != SENTINEL
187
+ get_user_account_recent_orders_v2_with_http_info_impl(user_id, user_secret, account_id, extra)
188
+ end
189
+
190
+ # List account recent orders (V2, last 24 hours only)
191
+ # A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account using the V2 order format. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders. Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days. By default only returns executed orders, but that can be changed by setting *only_executed* to false. **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)**
192
+ # @param user_id [String]
193
+ # @param user_secret [String]
194
+ # @param account_id [String]
195
+ # @param [Hash] opts the optional parameters
196
+ # @option opts [Boolean] :only_executed Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well
197
+ # @return [AccountOrdersV2Response]
198
+ private def get_user_account_recent_orders_v2_impl(user_id, user_secret, account_id, opts = {})
199
+ data, _status_code, _headers = get_user_account_recent_orders_v2_with_http_info(user_id, user_secret, account_id, opts)
200
+ data
201
+ end
202
+
203
+ # List account recent orders (V2, last 24 hours only)
204
+ # A lightweight endpoint that returns a list of orders executed in the last 24 hours in the specified account using the V2 order format. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders. Differs from /orders in that it is realtime, and only checks the last 24 hours as opposed to the last 30 days. By default only returns executed orders, but that can be changed by setting *only_executed* to false. **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)**
205
+ # @param user_id [String]
206
+ # @param user_secret [String]
207
+ # @param account_id [String]
208
+ # @param [Hash] opts the optional parameters
209
+ # @option opts [Boolean] :only_executed Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well
210
+ # @return [Array<(AccountOrdersV2Response, Integer, Hash)>] AccountOrdersV2Response data, response status code and response headers
211
+ private def get_user_account_recent_orders_v2_with_http_info_impl(user_id, user_secret, account_id, opts = {})
212
+ if @api_client.config.debugging
213
+ @api_client.config.logger.debug 'Calling API: ExperimentalEndpointsApi.get_user_account_recent_orders_v2 ...'
214
+ end
215
+ # verify the required parameter 'user_id' is set
216
+ if @api_client.config.client_side_validation && user_id.nil?
217
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling ExperimentalEndpointsApi.get_user_account_recent_orders_v2"
218
+ end
219
+ # verify the required parameter 'user_secret' is set
220
+ if @api_client.config.client_side_validation && user_secret.nil?
221
+ fail ArgumentError, "Missing the required parameter 'user_secret' when calling ExperimentalEndpointsApi.get_user_account_recent_orders_v2"
222
+ end
223
+ # verify the required parameter 'account_id' is set
224
+ if @api_client.config.client_side_validation && account_id.nil?
225
+ fail ArgumentError, "Missing the required parameter 'account_id' when calling ExperimentalEndpointsApi.get_user_account_recent_orders_v2"
226
+ end
227
+ # resource path
228
+ local_var_path = '/accounts/{accountId}/recentOrders/v2'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
229
+
230
+ # query parameters
231
+ query_params = opts[:query_params] || {}
232
+ query_params[:'userId'] = user_id
233
+ query_params[:'userSecret'] = user_secret
234
+ query_params[:'only_executed'] = opts[:'only_executed'] if !opts[:'only_executed'].nil?
235
+
236
+ # header parameters
237
+ header_params = opts[:header_params] || {}
238
+ # HTTP header 'Accept' (if needed)
239
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
240
+
241
+ # form parameters
242
+ form_params = opts[:form_params] || {}
243
+
244
+ # http body (model)
245
+ post_body = opts[:debug_body]
246
+
247
+ # return_type
248
+ return_type = opts[:debug_return_type] || 'AccountOrdersV2Response'
249
+
250
+ # auth_names
251
+ auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
252
+
253
+ new_options = opts.merge(
254
+ :operation => :"ExperimentalEndpointsApi.get_user_account_recent_orders_v2",
255
+ :header_params => header_params,
256
+ :query_params => query_params,
257
+ :form_params => form_params,
258
+ :body => post_body,
259
+ :auth_names => auth_names,
260
+ :return_type => return_type
261
+ )
262
+
263
+ data, status_code, headers, response = @api_client.call_api(:GET, local_var_path, new_options)
264
+ if @api_client.config.debugging
265
+ @api_client.config.logger.debug "API called: ExperimentalEndpointsApi#get_user_account_recent_orders_v2\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
266
+ end
267
+ return data, status_code, headers, response
268
+ end
269
+ end
270
+
271
+ # top-level client access to avoid having the user to insantiate their own API instances
272
+ ExperimentalEndpoints = ExperimentalEndpointsApi::new
273
+ end
@@ -133,7 +133,9 @@ module SnapTrade
133
133
  #
134
134
  # 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).
135
135
  #
136
- # The data returned here is cached. 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 data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**.
136
+ # 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:
137
+ # - If you do, this endpoint returns real-time data.
138
+ # - 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.
137
139
  #
138
140
  # @param user_id [String]
139
141
  # @param user_secret [String]
@@ -148,7 +150,9 @@ module SnapTrade
148
150
  #
149
151
  # 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).
150
152
  #
151
- # The data returned here is cached. 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 data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**.
153
+ # 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:
154
+ # - If you do, this endpoint returns real-time data.
155
+ # - 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.
152
156
  #
153
157
  # @param user_id [String]
154
158
  # @param user_secret [String]
@@ -159,7 +163,7 @@ module SnapTrade
159
163
  end
160
164
 
161
165
  # List account option positions
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). The data returned here is cached. 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 data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**.
166
+ # 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.
163
167
  # @param user_id [String]
164
168
  # @param user_secret [String]
165
169
  # @param account_id [String]
@@ -171,7 +175,7 @@ module SnapTrade
171
175
  end
172
176
 
173
177
  # List account option positions
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). The data returned here is cached. 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 data, please use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**.
178
+ # 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.
175
179
  # @param user_id [String]
176
180
  # @param user_secret [String]
177
181
  # @param account_id [String]
@@ -0,0 +1,292 @@
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
+ # Describes an individual leg that makes up an order in the V2 format.
15
+ class AccountOrderRecordLeg
16
+ # Brokerage order identifier for this leg, if available.
17
+ attr_accessor :leg_id
18
+
19
+ attr_accessor :instrument
20
+
21
+ # The action describes the intent or side of a trade. - BUY - SELL - BUY_COVER - SELL_SHORT - BUY_TO_OPEN - BUY_TO_CLOSE - SELL_TO_OPEN - SELL_TO_CLOSE
22
+ attr_accessor :action
23
+
24
+ # Execution price for this leg, if available.
25
+ attr_accessor :execution_price
26
+
27
+ # The total number of shares or contracts associated with this leg. Can be a decimal number for fractional shares.
28
+ attr_accessor :total_quantity
29
+
30
+ # The number of shares or contracts that have been canceled for this leg.
31
+ attr_accessor :canceled_quantity
32
+
33
+ # The number of shares or contracts that have been filled for this leg.
34
+ attr_accessor :filled_quantity
35
+
36
+ attr_accessor :status
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'leg_id' => :'leg_id',
42
+ :'instrument' => :'instrument',
43
+ :'action' => :'action',
44
+ :'execution_price' => :'execution_price',
45
+ :'total_quantity' => :'total_quantity',
46
+ :'canceled_quantity' => :'canceled_quantity',
47
+ :'filled_quantity' => :'filled_quantity',
48
+ :'status' => :'status'
49
+ }
50
+ end
51
+
52
+ # Returns all the JSON keys this model knows about
53
+ def self.acceptable_attributes
54
+ attribute_map.values
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'leg_id' => :'String',
61
+ :'instrument' => :'AccountOrderRecordLegInstrument',
62
+ :'action' => :'String',
63
+ :'execution_price' => :'Float',
64
+ :'total_quantity' => :'String',
65
+ :'canceled_quantity' => :'String',
66
+ :'filled_quantity' => :'String',
67
+ :'status' => :'AccountOrderRecordStatusV2'
68
+ }
69
+ end
70
+
71
+ # List of attributes with nullable: true
72
+ def self.openapi_nullable
73
+ Set.new([
74
+ :'leg_id',
75
+ :'execution_price',
76
+ :'total_quantity',
77
+ :'canceled_quantity',
78
+ :'filled_quantity',
79
+ :'status'
80
+ ])
81
+ end
82
+
83
+ # Initializes the object
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ def initialize(attributes = {})
86
+ if (!attributes.is_a?(Hash))
87
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::AccountOrderRecordLeg` initialize method"
88
+ end
89
+
90
+ # check to see if the attribute exists and convert string to symbol for hash key
91
+ attributes = attributes.each_with_object({}) { |(k, v), h|
92
+ if (!self.class.attribute_map.key?(k.to_sym))
93
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::AccountOrderRecordLeg`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
94
+ end
95
+ h[k.to_sym] = v
96
+ }
97
+
98
+ if attributes.key?(:'leg_id')
99
+ self.leg_id = attributes[:'leg_id']
100
+ end
101
+
102
+ if attributes.key?(:'instrument')
103
+ self.instrument = attributes[:'instrument']
104
+ end
105
+
106
+ if attributes.key?(:'action')
107
+ self.action = attributes[:'action']
108
+ end
109
+
110
+ if attributes.key?(:'execution_price')
111
+ self.execution_price = attributes[:'execution_price']
112
+ end
113
+
114
+ if attributes.key?(:'total_quantity')
115
+ self.total_quantity = attributes[:'total_quantity']
116
+ end
117
+
118
+ if attributes.key?(:'canceled_quantity')
119
+ self.canceled_quantity = attributes[:'canceled_quantity']
120
+ end
121
+
122
+ if attributes.key?(:'filled_quantity')
123
+ self.filled_quantity = attributes[:'filled_quantity']
124
+ end
125
+
126
+ if attributes.key?(:'status')
127
+ self.status = attributes[:'status']
128
+ end
129
+ end
130
+
131
+ # Show invalid properties with the reasons. Usually used together with valid?
132
+ # @return Array for valid properties with the reasons
133
+ def list_invalid_properties
134
+ invalid_properties = Array.new
135
+ invalid_properties
136
+ end
137
+
138
+ # Check to see if the all the properties in the model are valid
139
+ # @return true if the model is valid
140
+ def valid?
141
+ true
142
+ end
143
+
144
+ # Checks equality by comparing each attribute.
145
+ # @param [Object] Object to be compared
146
+ def ==(o)
147
+ return true if self.equal?(o)
148
+ self.class == o.class &&
149
+ leg_id == o.leg_id &&
150
+ instrument == o.instrument &&
151
+ action == o.action &&
152
+ execution_price == o.execution_price &&
153
+ total_quantity == o.total_quantity &&
154
+ canceled_quantity == o.canceled_quantity &&
155
+ filled_quantity == o.filled_quantity &&
156
+ status == o.status
157
+ end
158
+
159
+ # @see the `==` method
160
+ # @param [Object] Object to be compared
161
+ def eql?(o)
162
+ self == o
163
+ end
164
+
165
+ # Calculates hash code according to all attributes.
166
+ # @return [Integer] Hash code
167
+ def hash
168
+ [leg_id, instrument, action, execution_price, total_quantity, canceled_quantity, filled_quantity, status].hash
169
+ end
170
+
171
+ # Builds the object from hash
172
+ # @param [Hash] attributes Model attributes in the form of hash
173
+ # @return [Object] Returns the model itself
174
+ def self.build_from_hash(attributes)
175
+ new.build_from_hash(attributes)
176
+ end
177
+
178
+ # Builds the object from hash
179
+ # @param [Hash] attributes Model attributes in the form of hash
180
+ # @return [Object] Returns the model itself
181
+ def build_from_hash(attributes)
182
+ return nil unless attributes.is_a?(Hash)
183
+ attributes = attributes.transform_keys(&:to_sym)
184
+ self.class.openapi_types.each_pair do |key, type|
185
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
186
+ self.send("#{key}=", nil)
187
+ elsif type =~ /\AArray<(.*)>/i
188
+ # check to ensure the input is an array given that the attribute
189
+ # is documented as an array but the input is not
190
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
191
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
192
+ end
193
+ elsif !attributes[self.class.attribute_map[key]].nil?
194
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
195
+ end
196
+ end
197
+
198
+ self
199
+ end
200
+
201
+ # Deserializes the data based on type
202
+ # @param string type Data type
203
+ # @param string value Value to be deserialized
204
+ # @return [Object] Deserialized data
205
+ def _deserialize(type, value)
206
+ case type.to_sym
207
+ when :Time
208
+ Time.parse(value)
209
+ when :Date
210
+ Date.parse(value)
211
+ when :String
212
+ value.to_s
213
+ when :Integer
214
+ value.to_i
215
+ when :Float
216
+ value.to_f
217
+ when :Boolean
218
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
219
+ true
220
+ else
221
+ false
222
+ end
223
+ when :Object
224
+ # generic object (usually a Hash), return directly
225
+ value
226
+ when /\AArray<(?<inner_type>.+)>\z/
227
+ inner_type = Regexp.last_match[:inner_type]
228
+ value.map { |v| _deserialize(inner_type, v) }
229
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
230
+ k_type = Regexp.last_match[:k_type]
231
+ v_type = Regexp.last_match[:v_type]
232
+ {}.tap do |hash|
233
+ value.each do |k, v|
234
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
235
+ end
236
+ end
237
+ else # model
238
+ # models (e.g. Pet) or oneOf
239
+ klass = SnapTrade.const_get(type)
240
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
241
+ end
242
+ end
243
+
244
+ # Returns the string representation of the object
245
+ # @return [String] String presentation of the object
246
+ def to_s
247
+ to_hash.to_s
248
+ end
249
+
250
+ # to_body is an alias to to_hash (backward compatibility)
251
+ # @return [Hash] Returns the object in the form of hash
252
+ def to_body
253
+ to_hash
254
+ end
255
+
256
+ # Returns the object in the form of hash
257
+ # @return [Hash] Returns the object in the form of hash
258
+ def to_hash
259
+ hash = {}
260
+ self.class.attribute_map.each_pair do |attr, param|
261
+ value = self.send(attr)
262
+ if value.nil?
263
+ is_nullable = self.class.openapi_nullable.include?(attr)
264
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
265
+ end
266
+
267
+ hash[param] = _to_hash(value)
268
+ end
269
+ hash
270
+ end
271
+
272
+ # Outputs non-array value in the form of hash
273
+ # For object, use to_hash. Otherwise, just return the value
274
+ # @param [Object] value Any valid value
275
+ # @return [Hash] Returns the value in the form of hash
276
+ def _to_hash(value)
277
+ if value.is_a?(Array)
278
+ value.compact.map { |v| _to_hash(v) }
279
+ elsif value.is_a?(Hash)
280
+ {}.tap do |hash|
281
+ value.each { |k, v| hash[k] = _to_hash(v) }
282
+ end
283
+ elsif value.respond_to? :to_hash
284
+ value.to_hash
285
+ else
286
+ value
287
+ end
288
+ end
289
+
290
+ end
291
+
292
+ end