1
- from typing import List , Dict , Any , Optional
1
+ import keyword
2
+ from typing import List , Dict , Any
2
3
3
4
from polygon .rest import models
4
5
5
- StockSymbol = str
6
- ConditionTypeMap = Dict [str , str ]
7
- SymbolTypeMap = Dict [str , str ]
8
- TickerSymbol = str
9
-
10
6
11
7
class Definition :
12
8
_swagger_name_to_python : Dict [str , str ]
@@ -23,8 +19,12 @@ def unmarshal_json(self, input_json):
23
19
else :
24
20
list_items = input_json
25
21
self .__setattr__ (list_attribute_name , list_items )
22
+ return self
26
23
elif isinstance (input_json , dict ):
27
24
self ._unmarshal_json_object (input_json )
25
+ return self
26
+ elif isinstance (input_json , float ) or isinstance (input_json , int ):
27
+ return input_json
28
28
29
29
@staticmethod
30
30
def _unmarshal_json_list (input_json , known_type ):
@@ -40,11 +40,13 @@ def _unmarshal_json_object(self, input_json):
40
40
if key in self ._swagger_name_to_python :
41
41
attribute_name = self ._swagger_name_to_python [key ]
42
42
if not self ._attribute_is_primitive [attribute_name ]:
43
- if attribute_name in models .name_to_class :
44
- value = models .name_to_class [attribute_name ]()
45
- value .unmarshal_json (input_json [key ])
43
+ if attribute_name in self ._attributes_to_types :
44
+ attribute_type = self ._attributes_to_types [attribute_name ]
45
+ if attribute_type in models .name_to_class :
46
+ model = models .name_to_class [attribute_type ]()
47
+ value = model .unmarshal_json (input_json [key ])
46
48
else :
47
- attribute_name = key
49
+ attribute_name = key + "_" if keyword . iskeyword ( key ) else ""
48
50
49
51
self .__setattr__ (attribute_name , value )
50
52
return self
@@ -109,7 +111,7 @@ class LastQuote(Definition):
109
111
"bidsize" : "bidsize" ,
110
112
"bidexchange" : "bidexchange" ,
111
113
"timestamp" : "timestamp" ,
112
-
114
+
113
115
}
114
116
115
117
_attribute_is_primitive = {
@@ -3633,3 +3635,9 @@ class CryptoSnapshotGainersLosersApiResponse(Definition):
3633
3635
def __init__ (self ):
3634
3636
self .status : str
3635
3637
self .tickers : List [CryptoSnapshotTicker ]
3638
+
3639
+
3640
+ StockSymbol = str
3641
+ ConditionTypeMap = Dict [str , str ]
3642
+ SymbolTypeMap = Dict [str , str ]
3643
+ TickerSymbol = str
0 commit comments