snaptrade-python-sdk 11.0.157__py3-none-any.whl → 11.0.158__py3-none-any.whl
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.
- snaptrade_client/__init__.py +1 -1
- snaptrade_client/api_client.py +1 -1
- snaptrade_client/apis/path_to_api.py +3 -0
- snaptrade_client/apis/paths/accounts_account_id_orders_details_v2.py +7 -0
- snaptrade_client/apis/tags/experimental_endpoints_api_generated.py +2 -0
- snaptrade_client/configuration.py +1 -1
- snaptrade_client/operation_parameter_map.py +16 -0
- snaptrade_client/paths/__init__.py +1 -0
- snaptrade_client/paths/accounts_account_id_orders_details_v2/__init__.py +7 -0
- snaptrade_client/paths/accounts_account_id_orders_details_v2/post.py +691 -0
- snaptrade_client/paths/accounts_account_id_orders_details_v2/post.pyi +678 -0
- {snaptrade_python_sdk-11.0.157.dist-info → snaptrade_python_sdk-11.0.158.dist-info}/METADATA +56 -3
- {snaptrade_python_sdk-11.0.157.dist-info → snaptrade_python_sdk-11.0.158.dist-info}/RECORD +15 -11
- {snaptrade_python_sdk-11.0.157.dist-info → snaptrade_python_sdk-11.0.158.dist-info}/LICENSE +0 -0
- {snaptrade_python_sdk-11.0.157.dist-info → snaptrade_python_sdk-11.0.158.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
SnapTrade
|
|
5
|
+
|
|
6
|
+
Connect brokerage accounts to your app for live positions and trading
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 1.0.0
|
|
9
|
+
Contact: api@snaptrade.com
|
|
10
|
+
Created by: https://snaptrade.com/
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from dataclasses import dataclass
|
|
14
|
+
import typing_extensions
|
|
15
|
+
import urllib3
|
|
16
|
+
from snaptrade_client.request_before_hook import request_before_hook
|
|
17
|
+
import json
|
|
18
|
+
from urllib3._collections import HTTPHeaderDict
|
|
19
|
+
|
|
20
|
+
from snaptrade_client.api_response import AsyncGeneratorResponse
|
|
21
|
+
from snaptrade_client import api_client, exceptions
|
|
22
|
+
from datetime import date, datetime # noqa: F401
|
|
23
|
+
import decimal # noqa: F401
|
|
24
|
+
import functools # noqa: F401
|
|
25
|
+
import io # noqa: F401
|
|
26
|
+
import re # noqa: F401
|
|
27
|
+
import typing # noqa: F401
|
|
28
|
+
import typing_extensions # noqa: F401
|
|
29
|
+
import uuid # noqa: F401
|
|
30
|
+
|
|
31
|
+
import frozendict # noqa: F401
|
|
32
|
+
|
|
33
|
+
from snaptrade_client import schemas # noqa: F401
|
|
34
|
+
|
|
35
|
+
from snaptrade_client.model.model400_failed_request_response import Model400FailedRequestResponse as Model400FailedRequestResponseSchema
|
|
36
|
+
from snaptrade_client.model.account_order_record_v2 import AccountOrderRecordV2 as AccountOrderRecordV2Schema
|
|
37
|
+
from snaptrade_client.model.model500_unexpected_exception_response import Model500UnexpectedExceptionResponse as Model500UnexpectedExceptionResponseSchema
|
|
38
|
+
from snaptrade_client.model.model404_failed_request_response import Model404FailedRequestResponse as Model404FailedRequestResponseSchema
|
|
39
|
+
|
|
40
|
+
from snaptrade_client.type.model400_failed_request_response import Model400FailedRequestResponse
|
|
41
|
+
from snaptrade_client.type.model500_unexpected_exception_response import Model500UnexpectedExceptionResponse
|
|
42
|
+
from snaptrade_client.type.account_order_record_v2 import AccountOrderRecordV2
|
|
43
|
+
from snaptrade_client.type.model404_failed_request_response import Model404FailedRequestResponse
|
|
44
|
+
|
|
45
|
+
from . import path
|
|
46
|
+
|
|
47
|
+
# Query params
|
|
48
|
+
UserIdSchema = schemas.StrSchema
|
|
49
|
+
UserSecretSchema = schemas.StrSchema
|
|
50
|
+
RequestRequiredQueryParams = typing_extensions.TypedDict(
|
|
51
|
+
'RequestRequiredQueryParams',
|
|
52
|
+
{
|
|
53
|
+
'userId': typing.Union[UserIdSchema, str, ],
|
|
54
|
+
'userSecret': typing.Union[UserSecretSchema, str, ],
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
RequestOptionalQueryParams = typing_extensions.TypedDict(
|
|
58
|
+
'RequestOptionalQueryParams',
|
|
59
|
+
{
|
|
60
|
+
},
|
|
61
|
+
total=False
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams):
|
|
66
|
+
pass
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
request_query_user_id = api_client.QueryParameter(
|
|
70
|
+
name="userId",
|
|
71
|
+
style=api_client.ParameterStyle.FORM,
|
|
72
|
+
schema=UserIdSchema,
|
|
73
|
+
required=True,
|
|
74
|
+
explode=True,
|
|
75
|
+
)
|
|
76
|
+
request_query_user_secret = api_client.QueryParameter(
|
|
77
|
+
name="userSecret",
|
|
78
|
+
style=api_client.ParameterStyle.FORM,
|
|
79
|
+
schema=UserSecretSchema,
|
|
80
|
+
required=True,
|
|
81
|
+
explode=True,
|
|
82
|
+
)
|
|
83
|
+
# Path params
|
|
84
|
+
AccountIdSchema = schemas.UUIDSchema
|
|
85
|
+
RequestRequiredPathParams = typing_extensions.TypedDict(
|
|
86
|
+
'RequestRequiredPathParams',
|
|
87
|
+
{
|
|
88
|
+
'accountId': typing.Union[AccountIdSchema, str, uuid.UUID, ],
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
RequestOptionalPathParams = typing_extensions.TypedDict(
|
|
92
|
+
'RequestOptionalPathParams',
|
|
93
|
+
{
|
|
94
|
+
},
|
|
95
|
+
total=False
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class RequestPathParams(RequestRequiredPathParams, RequestOptionalPathParams):
|
|
100
|
+
pass
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
request_path_account_id = api_client.PathParameter(
|
|
104
|
+
name="accountId",
|
|
105
|
+
style=api_client.ParameterStyle.SIMPLE,
|
|
106
|
+
schema=AccountIdSchema,
|
|
107
|
+
required=True,
|
|
108
|
+
)
|
|
109
|
+
# body param
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class SchemaForRequestBodyApplicationJson(
|
|
113
|
+
schemas.DictSchema
|
|
114
|
+
):
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class MetaOapg:
|
|
118
|
+
required = {
|
|
119
|
+
"brokerage_order_id",
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
class properties:
|
|
123
|
+
brokerage_order_id = schemas.StrSchema
|
|
124
|
+
__annotations__ = {
|
|
125
|
+
"brokerage_order_id": brokerage_order_id,
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
brokerage_order_id: MetaOapg.properties.brokerage_order_id
|
|
129
|
+
|
|
130
|
+
@typing.overload
|
|
131
|
+
def __getitem__(self, name: typing_extensions.Literal["brokerage_order_id"]) -> MetaOapg.properties.brokerage_order_id: ...
|
|
132
|
+
|
|
133
|
+
@typing.overload
|
|
134
|
+
def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ...
|
|
135
|
+
|
|
136
|
+
def __getitem__(self, name: typing.Union[typing_extensions.Literal["brokerage_order_id", ], str]):
|
|
137
|
+
# dict_instance[name] accessor
|
|
138
|
+
return super().__getitem__(name)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
@typing.overload
|
|
142
|
+
def get_item_oapg(self, name: typing_extensions.Literal["brokerage_order_id"]) -> MetaOapg.properties.brokerage_order_id: ...
|
|
143
|
+
|
|
144
|
+
@typing.overload
|
|
145
|
+
def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
|
|
146
|
+
|
|
147
|
+
def get_item_oapg(self, name: typing.Union[typing_extensions.Literal["brokerage_order_id", ], str]):
|
|
148
|
+
return super().get_item_oapg(name)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def __new__(
|
|
152
|
+
cls,
|
|
153
|
+
*args: typing.Union[dict, frozendict.frozendict, ],
|
|
154
|
+
brokerage_order_id: typing.Union[MetaOapg.properties.brokerage_order_id, str, ],
|
|
155
|
+
_configuration: typing.Optional[schemas.Configuration] = None,
|
|
156
|
+
**kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes],
|
|
157
|
+
) -> 'SchemaForRequestBodyApplicationJson':
|
|
158
|
+
return super().__new__(
|
|
159
|
+
cls,
|
|
160
|
+
*args,
|
|
161
|
+
brokerage_order_id=brokerage_order_id,
|
|
162
|
+
_configuration=_configuration,
|
|
163
|
+
**kwargs,
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
request_body_typing_any = api_client.RequestBody(
|
|
168
|
+
content={
|
|
169
|
+
'application/json': api_client.MediaType(
|
|
170
|
+
schema=SchemaForRequestBodyApplicationJson),
|
|
171
|
+
},
|
|
172
|
+
required=True,
|
|
173
|
+
)
|
|
174
|
+
_auth = [
|
|
175
|
+
'PartnerClientId',
|
|
176
|
+
'PartnerSignature',
|
|
177
|
+
'PartnerTimestamp',
|
|
178
|
+
]
|
|
179
|
+
SchemaFor200ResponseBodyApplicationJson = AccountOrderRecordV2Schema
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
@dataclass
|
|
183
|
+
class ApiResponseFor200(api_client.ApiResponse):
|
|
184
|
+
body: AccountOrderRecordV2
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
@dataclass
|
|
188
|
+
class ApiResponseFor200Async(api_client.AsyncApiResponse):
|
|
189
|
+
body: AccountOrderRecordV2
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
_response_for_200 = api_client.OpenApiResponse(
|
|
193
|
+
response_cls=ApiResponseFor200,
|
|
194
|
+
response_cls_async=ApiResponseFor200Async,
|
|
195
|
+
content={
|
|
196
|
+
'application/json': api_client.MediaType(
|
|
197
|
+
schema=SchemaFor200ResponseBodyApplicationJson),
|
|
198
|
+
},
|
|
199
|
+
)
|
|
200
|
+
SchemaFor400ResponseBodyApplicationJson = Model400FailedRequestResponseSchema
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
@dataclass
|
|
204
|
+
class ApiResponseFor400(api_client.ApiResponse):
|
|
205
|
+
body: Model400FailedRequestResponse
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
@dataclass
|
|
209
|
+
class ApiResponseFor400Async(api_client.AsyncApiResponse):
|
|
210
|
+
body: Model400FailedRequestResponse
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
_response_for_400 = api_client.OpenApiResponse(
|
|
214
|
+
response_cls=ApiResponseFor400,
|
|
215
|
+
response_cls_async=ApiResponseFor400Async,
|
|
216
|
+
content={
|
|
217
|
+
'application/json': api_client.MediaType(
|
|
218
|
+
schema=SchemaFor400ResponseBodyApplicationJson),
|
|
219
|
+
},
|
|
220
|
+
)
|
|
221
|
+
SchemaFor404ResponseBodyApplicationJson = Model404FailedRequestResponseSchema
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
@dataclass
|
|
225
|
+
class ApiResponseFor404(api_client.ApiResponse):
|
|
226
|
+
body: Model404FailedRequestResponse
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
@dataclass
|
|
230
|
+
class ApiResponseFor404Async(api_client.AsyncApiResponse):
|
|
231
|
+
body: Model404FailedRequestResponse
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
_response_for_404 = api_client.OpenApiResponse(
|
|
235
|
+
response_cls=ApiResponseFor404,
|
|
236
|
+
response_cls_async=ApiResponseFor404Async,
|
|
237
|
+
content={
|
|
238
|
+
'application/json': api_client.MediaType(
|
|
239
|
+
schema=SchemaFor404ResponseBodyApplicationJson),
|
|
240
|
+
},
|
|
241
|
+
)
|
|
242
|
+
SchemaFor500ResponseBodyApplicationJson = Model500UnexpectedExceptionResponseSchema
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
@dataclass
|
|
246
|
+
class ApiResponseFor500(api_client.ApiResponse):
|
|
247
|
+
body: Model500UnexpectedExceptionResponse
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
@dataclass
|
|
251
|
+
class ApiResponseFor500Async(api_client.AsyncApiResponse):
|
|
252
|
+
body: Model500UnexpectedExceptionResponse
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
_response_for_500 = api_client.OpenApiResponse(
|
|
256
|
+
response_cls=ApiResponseFor500,
|
|
257
|
+
response_cls_async=ApiResponseFor500Async,
|
|
258
|
+
content={
|
|
259
|
+
'application/json': api_client.MediaType(
|
|
260
|
+
schema=SchemaFor500ResponseBodyApplicationJson),
|
|
261
|
+
},
|
|
262
|
+
)
|
|
263
|
+
_status_code_to_response = {
|
|
264
|
+
'200': _response_for_200,
|
|
265
|
+
'400': _response_for_400,
|
|
266
|
+
'404': _response_for_404,
|
|
267
|
+
'500': _response_for_500,
|
|
268
|
+
}
|
|
269
|
+
_all_accept_content_types = (
|
|
270
|
+
'application/json',
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
class BaseApi(api_client.Api):
|
|
275
|
+
|
|
276
|
+
def _get_user_account_order_detail_v2_mapped_args(
|
|
277
|
+
self,
|
|
278
|
+
body: typing.Optional[typing.Any] = None,
|
|
279
|
+
brokerage_order_id: typing.Optional[str] = None,
|
|
280
|
+
account_id: typing.Optional[str] = None,
|
|
281
|
+
user_id: typing.Optional[str] = None,
|
|
282
|
+
user_secret: typing.Optional[str] = None,
|
|
283
|
+
query_params: typing.Optional[dict] = {},
|
|
284
|
+
path_params: typing.Optional[dict] = {},
|
|
285
|
+
) -> api_client.MappedArgs:
|
|
286
|
+
args: api_client.MappedArgs = api_client.MappedArgs()
|
|
287
|
+
_query_params = {}
|
|
288
|
+
_path_params = {}
|
|
289
|
+
_body = {}
|
|
290
|
+
if brokerage_order_id is not None:
|
|
291
|
+
_body["brokerage_order_id"] = brokerage_order_id
|
|
292
|
+
args.body = body if body is not None else _body
|
|
293
|
+
if user_id is not None:
|
|
294
|
+
_query_params["userId"] = user_id
|
|
295
|
+
if user_secret is not None:
|
|
296
|
+
_query_params["userSecret"] = user_secret
|
|
297
|
+
if account_id is not None:
|
|
298
|
+
_path_params["accountId"] = account_id
|
|
299
|
+
args.query = query_params if query_params else _query_params
|
|
300
|
+
args.path = path_params if path_params else _path_params
|
|
301
|
+
return args
|
|
302
|
+
|
|
303
|
+
async def _aget_user_account_order_detail_v2_oapg(
|
|
304
|
+
self,
|
|
305
|
+
body: typing.Any = None,
|
|
306
|
+
query_params: typing.Optional[dict] = {},
|
|
307
|
+
path_params: typing.Optional[dict] = {},
|
|
308
|
+
skip_deserialization: bool = True,
|
|
309
|
+
timeout: typing.Optional[typing.Union[float, typing.Tuple]] = None,
|
|
310
|
+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
|
|
311
|
+
content_type: str = 'application/json',
|
|
312
|
+
stream: bool = False,
|
|
313
|
+
**kwargs,
|
|
314
|
+
) -> typing.Union[
|
|
315
|
+
ApiResponseFor200Async,
|
|
316
|
+
api_client.ApiResponseWithoutDeserializationAsync,
|
|
317
|
+
AsyncGeneratorResponse,
|
|
318
|
+
]:
|
|
319
|
+
"""
|
|
320
|
+
Get account order detail (V2)
|
|
321
|
+
:param skip_deserialization: If true then api_response.response will be set but
|
|
322
|
+
api_response.body and api_response.headers will not be deserialized into schema
|
|
323
|
+
class instances
|
|
324
|
+
"""
|
|
325
|
+
self._verify_typed_dict_inputs_oapg(RequestQueryParams, query_params)
|
|
326
|
+
self._verify_typed_dict_inputs_oapg(RequestPathParams, path_params)
|
|
327
|
+
used_path = path.value
|
|
328
|
+
|
|
329
|
+
_path_params = {}
|
|
330
|
+
for parameter in (
|
|
331
|
+
request_path_account_id,
|
|
332
|
+
):
|
|
333
|
+
parameter_data = path_params.get(parameter.name, schemas.unset)
|
|
334
|
+
if parameter_data is schemas.unset:
|
|
335
|
+
continue
|
|
336
|
+
serialized_data = parameter.serialize(parameter_data)
|
|
337
|
+
_path_params.update(serialized_data)
|
|
338
|
+
|
|
339
|
+
for k, v in _path_params.items():
|
|
340
|
+
used_path = used_path.replace('{%s}' % k, v)
|
|
341
|
+
|
|
342
|
+
prefix_separator_iterator = None
|
|
343
|
+
for parameter in (
|
|
344
|
+
request_query_user_id,
|
|
345
|
+
request_query_user_secret,
|
|
346
|
+
):
|
|
347
|
+
parameter_data = query_params.get(parameter.name, schemas.unset)
|
|
348
|
+
if parameter_data is schemas.unset:
|
|
349
|
+
continue
|
|
350
|
+
if prefix_separator_iterator is None:
|
|
351
|
+
prefix_separator_iterator = parameter.get_prefix_separator_iterator()
|
|
352
|
+
serialized_data = parameter.serialize(parameter_data, prefix_separator_iterator)
|
|
353
|
+
for serialized_value in serialized_data.values():
|
|
354
|
+
used_path += serialized_value
|
|
355
|
+
|
|
356
|
+
_headers = HTTPHeaderDict()
|
|
357
|
+
# TODO add cookie handling
|
|
358
|
+
if accept_content_types:
|
|
359
|
+
for accept_content_type in accept_content_types:
|
|
360
|
+
_headers.add('Accept', accept_content_type)
|
|
361
|
+
method = 'post'.upper()
|
|
362
|
+
_headers.add('Content-Type', content_type)
|
|
363
|
+
|
|
364
|
+
if body is schemas.unset:
|
|
365
|
+
raise exceptions.ApiValueError(
|
|
366
|
+
'The required body parameter has an invalid value of: unset. Set a valid value instead')
|
|
367
|
+
_fields = None
|
|
368
|
+
_body = None
|
|
369
|
+
request_before_hook(
|
|
370
|
+
resource_path=used_path,
|
|
371
|
+
method=method,
|
|
372
|
+
configuration=self.api_client.configuration,
|
|
373
|
+
path_template='/accounts/{accountId}/orders/details/v2',
|
|
374
|
+
body=body,
|
|
375
|
+
auth_settings=_auth,
|
|
376
|
+
headers=_headers,
|
|
377
|
+
)
|
|
378
|
+
serialized_data = request_body_typing_any.serialize(body, content_type)
|
|
379
|
+
if 'fields' in serialized_data:
|
|
380
|
+
_fields = serialized_data['fields']
|
|
381
|
+
elif 'body' in serialized_data:
|
|
382
|
+
_body = serialized_data['body']
|
|
383
|
+
|
|
384
|
+
response = await self.api_client.async_call_api(
|
|
385
|
+
resource_path=used_path,
|
|
386
|
+
method=method,
|
|
387
|
+
headers=_headers,
|
|
388
|
+
fields=_fields,
|
|
389
|
+
serialized_body=_body,
|
|
390
|
+
body=body,
|
|
391
|
+
auth_settings=_auth,
|
|
392
|
+
prefix_separator_iterator=prefix_separator_iterator,
|
|
393
|
+
timeout=timeout,
|
|
394
|
+
**kwargs
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
if stream:
|
|
398
|
+
if not 200 <= response.http_response.status <= 299:
|
|
399
|
+
body = (await response.http_response.content.read()).decode("utf-8")
|
|
400
|
+
raise exceptions.ApiStreamingException(
|
|
401
|
+
status=response.http_response.status,
|
|
402
|
+
reason=response.http_response.reason,
|
|
403
|
+
body=body,
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
async def stream_iterator():
|
|
407
|
+
"""
|
|
408
|
+
iterates over response.http_response.content and closes connection once iteration has finished
|
|
409
|
+
"""
|
|
410
|
+
async for line in response.http_response.content:
|
|
411
|
+
if line == b'\r\n':
|
|
412
|
+
continue
|
|
413
|
+
yield line
|
|
414
|
+
response.http_response.close()
|
|
415
|
+
await response.session.close()
|
|
416
|
+
return AsyncGeneratorResponse(
|
|
417
|
+
content=stream_iterator(),
|
|
418
|
+
headers=response.http_response.headers,
|
|
419
|
+
status=response.http_response.status,
|
|
420
|
+
response=response.http_response
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
response_for_status = _status_code_to_response.get(str(response.http_response.status))
|
|
424
|
+
if response_for_status:
|
|
425
|
+
api_response = await response_for_status.deserialize_async(
|
|
426
|
+
response,
|
|
427
|
+
self.api_client.configuration,
|
|
428
|
+
skip_deserialization=skip_deserialization
|
|
429
|
+
)
|
|
430
|
+
else:
|
|
431
|
+
# If response data is JSON then deserialize for SDK consumer convenience
|
|
432
|
+
is_json = api_client.JSONDetector._content_type_is_json(response.http_response.headers.get('Content-Type', ''))
|
|
433
|
+
api_response = api_client.ApiResponseWithoutDeserializationAsync(
|
|
434
|
+
body=await response.http_response.json() if is_json else await response.http_response.text(),
|
|
435
|
+
response=response.http_response,
|
|
436
|
+
round_trip_time=response.round_trip_time,
|
|
437
|
+
status=response.http_response.status,
|
|
438
|
+
headers=response.http_response.headers,
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
if not 200 <= api_response.status <= 299:
|
|
442
|
+
raise exceptions.ApiException(api_response=api_response)
|
|
443
|
+
|
|
444
|
+
# cleanup session / response
|
|
445
|
+
response.http_response.close()
|
|
446
|
+
await response.session.close()
|
|
447
|
+
|
|
448
|
+
return api_response
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
def _get_user_account_order_detail_v2_oapg(
|
|
452
|
+
self,
|
|
453
|
+
body: typing.Any = None,
|
|
454
|
+
query_params: typing.Optional[dict] = {},
|
|
455
|
+
path_params: typing.Optional[dict] = {},
|
|
456
|
+
skip_deserialization: bool = True,
|
|
457
|
+
timeout: typing.Optional[typing.Union[float, typing.Tuple]] = None,
|
|
458
|
+
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
|
|
459
|
+
content_type: str = 'application/json',
|
|
460
|
+
stream: bool = False,
|
|
461
|
+
) -> typing.Union[
|
|
462
|
+
ApiResponseFor200,
|
|
463
|
+
api_client.ApiResponseWithoutDeserialization,
|
|
464
|
+
]:
|
|
465
|
+
"""
|
|
466
|
+
Get account order detail (V2)
|
|
467
|
+
:param skip_deserialization: If true then api_response.response will be set but
|
|
468
|
+
api_response.body and api_response.headers will not be deserialized into schema
|
|
469
|
+
class instances
|
|
470
|
+
"""
|
|
471
|
+
self._verify_typed_dict_inputs_oapg(RequestQueryParams, query_params)
|
|
472
|
+
self._verify_typed_dict_inputs_oapg(RequestPathParams, path_params)
|
|
473
|
+
used_path = path.value
|
|
474
|
+
|
|
475
|
+
_path_params = {}
|
|
476
|
+
for parameter in (
|
|
477
|
+
request_path_account_id,
|
|
478
|
+
):
|
|
479
|
+
parameter_data = path_params.get(parameter.name, schemas.unset)
|
|
480
|
+
if parameter_data is schemas.unset:
|
|
481
|
+
continue
|
|
482
|
+
serialized_data = parameter.serialize(parameter_data)
|
|
483
|
+
_path_params.update(serialized_data)
|
|
484
|
+
|
|
485
|
+
for k, v in _path_params.items():
|
|
486
|
+
used_path = used_path.replace('{%s}' % k, v)
|
|
487
|
+
|
|
488
|
+
prefix_separator_iterator = None
|
|
489
|
+
for parameter in (
|
|
490
|
+
request_query_user_id,
|
|
491
|
+
request_query_user_secret,
|
|
492
|
+
):
|
|
493
|
+
parameter_data = query_params.get(parameter.name, schemas.unset)
|
|
494
|
+
if parameter_data is schemas.unset:
|
|
495
|
+
continue
|
|
496
|
+
if prefix_separator_iterator is None:
|
|
497
|
+
prefix_separator_iterator = parameter.get_prefix_separator_iterator()
|
|
498
|
+
serialized_data = parameter.serialize(parameter_data, prefix_separator_iterator)
|
|
499
|
+
for serialized_value in serialized_data.values():
|
|
500
|
+
used_path += serialized_value
|
|
501
|
+
|
|
502
|
+
_headers = HTTPHeaderDict()
|
|
503
|
+
# TODO add cookie handling
|
|
504
|
+
if accept_content_types:
|
|
505
|
+
for accept_content_type in accept_content_types:
|
|
506
|
+
_headers.add('Accept', accept_content_type)
|
|
507
|
+
method = 'post'.upper()
|
|
508
|
+
_headers.add('Content-Type', content_type)
|
|
509
|
+
|
|
510
|
+
if body is schemas.unset:
|
|
511
|
+
raise exceptions.ApiValueError(
|
|
512
|
+
'The required body parameter has an invalid value of: unset. Set a valid value instead')
|
|
513
|
+
_fields = None
|
|
514
|
+
_body = None
|
|
515
|
+
request_before_hook(
|
|
516
|
+
resource_path=used_path,
|
|
517
|
+
method=method,
|
|
518
|
+
configuration=self.api_client.configuration,
|
|
519
|
+
path_template='/accounts/{accountId}/orders/details/v2',
|
|
520
|
+
body=body,
|
|
521
|
+
auth_settings=_auth,
|
|
522
|
+
headers=_headers,
|
|
523
|
+
)
|
|
524
|
+
serialized_data = request_body_typing_any.serialize(body, content_type)
|
|
525
|
+
if 'fields' in serialized_data:
|
|
526
|
+
_fields = serialized_data['fields']
|
|
527
|
+
elif 'body' in serialized_data:
|
|
528
|
+
_body = serialized_data['body']
|
|
529
|
+
|
|
530
|
+
response = self.api_client.call_api(
|
|
531
|
+
resource_path=used_path,
|
|
532
|
+
method=method,
|
|
533
|
+
headers=_headers,
|
|
534
|
+
fields=_fields,
|
|
535
|
+
serialized_body=_body,
|
|
536
|
+
body=body,
|
|
537
|
+
auth_settings=_auth,
|
|
538
|
+
prefix_separator_iterator=prefix_separator_iterator,
|
|
539
|
+
timeout=timeout,
|
|
540
|
+
)
|
|
541
|
+
|
|
542
|
+
response_for_status = _status_code_to_response.get(str(response.http_response.status))
|
|
543
|
+
if response_for_status:
|
|
544
|
+
api_response = response_for_status.deserialize(
|
|
545
|
+
response,
|
|
546
|
+
self.api_client.configuration,
|
|
547
|
+
skip_deserialization=skip_deserialization
|
|
548
|
+
)
|
|
549
|
+
else:
|
|
550
|
+
# If response data is JSON then deserialize for SDK consumer convenience
|
|
551
|
+
is_json = api_client.JSONDetector._content_type_is_json(response.http_response.headers.get('Content-Type', ''))
|
|
552
|
+
api_response = api_client.ApiResponseWithoutDeserialization(
|
|
553
|
+
body=json.loads(response.http_response.data) if is_json else response.http_response.data,
|
|
554
|
+
response=response.http_response,
|
|
555
|
+
round_trip_time=response.round_trip_time,
|
|
556
|
+
status=response.http_response.status,
|
|
557
|
+
headers=response.http_response.headers,
|
|
558
|
+
)
|
|
559
|
+
|
|
560
|
+
if not 200 <= api_response.status <= 299:
|
|
561
|
+
raise exceptions.ApiException(api_response=api_response)
|
|
562
|
+
|
|
563
|
+
return api_response
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
class GetUserAccountOrderDetailV2(BaseApi):
|
|
567
|
+
# this class is used by api classes that refer to endpoints with operationId fn names
|
|
568
|
+
|
|
569
|
+
async def aget_user_account_order_detail_v2(
|
|
570
|
+
self,
|
|
571
|
+
body: typing.Optional[typing.Any] = None,
|
|
572
|
+
brokerage_order_id: typing.Optional[str] = None,
|
|
573
|
+
account_id: typing.Optional[str] = None,
|
|
574
|
+
user_id: typing.Optional[str] = None,
|
|
575
|
+
user_secret: typing.Optional[str] = None,
|
|
576
|
+
query_params: typing.Optional[dict] = {},
|
|
577
|
+
path_params: typing.Optional[dict] = {},
|
|
578
|
+
**kwargs,
|
|
579
|
+
) -> typing.Union[
|
|
580
|
+
ApiResponseFor200Async,
|
|
581
|
+
api_client.ApiResponseWithoutDeserializationAsync,
|
|
582
|
+
AsyncGeneratorResponse,
|
|
583
|
+
]:
|
|
584
|
+
args = self._get_user_account_order_detail_v2_mapped_args(
|
|
585
|
+
body=body,
|
|
586
|
+
query_params=query_params,
|
|
587
|
+
path_params=path_params,
|
|
588
|
+
brokerage_order_id=brokerage_order_id,
|
|
589
|
+
account_id=account_id,
|
|
590
|
+
user_id=user_id,
|
|
591
|
+
user_secret=user_secret,
|
|
592
|
+
)
|
|
593
|
+
return await self._aget_user_account_order_detail_v2_oapg(
|
|
594
|
+
body=args.body,
|
|
595
|
+
query_params=args.query,
|
|
596
|
+
path_params=args.path,
|
|
597
|
+
**kwargs,
|
|
598
|
+
)
|
|
599
|
+
|
|
600
|
+
def get_user_account_order_detail_v2(
|
|
601
|
+
self,
|
|
602
|
+
body: typing.Optional[typing.Any] = None,
|
|
603
|
+
brokerage_order_id: typing.Optional[str] = None,
|
|
604
|
+
account_id: typing.Optional[str] = None,
|
|
605
|
+
user_id: typing.Optional[str] = None,
|
|
606
|
+
user_secret: typing.Optional[str] = None,
|
|
607
|
+
query_params: typing.Optional[dict] = {},
|
|
608
|
+
path_params: typing.Optional[dict] = {},
|
|
609
|
+
) -> typing.Union[
|
|
610
|
+
ApiResponseFor200,
|
|
611
|
+
api_client.ApiResponseWithoutDeserialization,
|
|
612
|
+
]:
|
|
613
|
+
""" Returns the detail of a single order using the external order ID provided in the request body. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. """
|
|
614
|
+
args = self._get_user_account_order_detail_v2_mapped_args(
|
|
615
|
+
body=body,
|
|
616
|
+
query_params=query_params,
|
|
617
|
+
path_params=path_params,
|
|
618
|
+
brokerage_order_id=brokerage_order_id,
|
|
619
|
+
account_id=account_id,
|
|
620
|
+
user_id=user_id,
|
|
621
|
+
user_secret=user_secret,
|
|
622
|
+
)
|
|
623
|
+
return self._get_user_account_order_detail_v2_oapg(
|
|
624
|
+
body=args.body,
|
|
625
|
+
query_params=args.query,
|
|
626
|
+
path_params=args.path,
|
|
627
|
+
)
|
|
628
|
+
|
|
629
|
+
class ApiForpost(BaseApi):
|
|
630
|
+
# this class is used by api classes that refer to endpoints by path and http method names
|
|
631
|
+
|
|
632
|
+
async def apost(
|
|
633
|
+
self,
|
|
634
|
+
body: typing.Optional[typing.Any] = None,
|
|
635
|
+
brokerage_order_id: typing.Optional[str] = None,
|
|
636
|
+
account_id: typing.Optional[str] = None,
|
|
637
|
+
user_id: typing.Optional[str] = None,
|
|
638
|
+
user_secret: typing.Optional[str] = None,
|
|
639
|
+
query_params: typing.Optional[dict] = {},
|
|
640
|
+
path_params: typing.Optional[dict] = {},
|
|
641
|
+
**kwargs,
|
|
642
|
+
) -> typing.Union[
|
|
643
|
+
ApiResponseFor200Async,
|
|
644
|
+
api_client.ApiResponseWithoutDeserializationAsync,
|
|
645
|
+
AsyncGeneratorResponse,
|
|
646
|
+
]:
|
|
647
|
+
args = self._get_user_account_order_detail_v2_mapped_args(
|
|
648
|
+
body=body,
|
|
649
|
+
query_params=query_params,
|
|
650
|
+
path_params=path_params,
|
|
651
|
+
brokerage_order_id=brokerage_order_id,
|
|
652
|
+
account_id=account_id,
|
|
653
|
+
user_id=user_id,
|
|
654
|
+
user_secret=user_secret,
|
|
655
|
+
)
|
|
656
|
+
return await self._aget_user_account_order_detail_v2_oapg(
|
|
657
|
+
body=args.body,
|
|
658
|
+
query_params=args.query,
|
|
659
|
+
path_params=args.path,
|
|
660
|
+
**kwargs,
|
|
661
|
+
)
|
|
662
|
+
|
|
663
|
+
def post(
|
|
664
|
+
self,
|
|
665
|
+
body: typing.Optional[typing.Any] = None,
|
|
666
|
+
brokerage_order_id: typing.Optional[str] = None,
|
|
667
|
+
account_id: typing.Optional[str] = None,
|
|
668
|
+
user_id: typing.Optional[str] = None,
|
|
669
|
+
user_secret: typing.Optional[str] = None,
|
|
670
|
+
query_params: typing.Optional[dict] = {},
|
|
671
|
+
path_params: typing.Optional[dict] = {},
|
|
672
|
+
) -> typing.Union[
|
|
673
|
+
ApiResponseFor200,
|
|
674
|
+
api_client.ApiResponseWithoutDeserialization,
|
|
675
|
+
]:
|
|
676
|
+
""" Returns the detail of a single order using the external order ID provided in the request body. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint. """
|
|
677
|
+
args = self._get_user_account_order_detail_v2_mapped_args(
|
|
678
|
+
body=body,
|
|
679
|
+
query_params=query_params,
|
|
680
|
+
path_params=path_params,
|
|
681
|
+
brokerage_order_id=brokerage_order_id,
|
|
682
|
+
account_id=account_id,
|
|
683
|
+
user_id=user_id,
|
|
684
|
+
user_secret=user_secret,
|
|
685
|
+
)
|
|
686
|
+
return self._get_user_account_order_detail_v2_oapg(
|
|
687
|
+
body=args.body,
|
|
688
|
+
query_params=args.query,
|
|
689
|
+
path_params=args.path,
|
|
690
|
+
)
|
|
691
|
+
|