@@ -53,14 +53,16 @@ def setup_environment(force=False) -> bool:
53
53
54
54
# Based on TME API snippets mentioned in API documentation: https://developers.tme.eu/documentation/download
55
55
# https://github.com/tme-dev/TME-API/blob/master/Python/call.py
56
- def tme_api_request (endpoint , tme_api_settings , part_number , api_host = 'https://api.tme.eu' , format = 'json' ):
56
+ def tme_api_request (endpoint , tme_api_settings , part_number , api_host = 'https://api.tme.eu' , format = 'json' , ** kwargs ):
57
57
TME_API_TOKEN = tme_api_settings .get ('TME_API_TOKEN' , None )
58
58
TME_API_SECRET = tme_api_settings .get ('TME_API_SECRET' , None )
59
59
60
60
params = collections .OrderedDict ()
61
61
params ['Country' ] = tme_api_settings .get ('TME_API_COUNTRY' , 'US' )
62
62
params ['Language' ] = tme_api_settings .get ('TME_API_LANGUAGE' , 'EN' )
63
63
params ['SymbolList[0]' ] = part_number
64
+ if kwargs .get ('currency' , None ):
65
+ params ['Currency' ] = kwargs .get ('currency' )
64
66
if not TME_API_TOKEN and not TME_API_SECRET :
65
67
TME_API_TOKEN = os .environ .get ('TME_API_TOKEN' , None )
66
68
TME_API_SECRET = os .environ .get ('TME_API_SECRET' , None )
@@ -136,7 +138,7 @@ def search_product(response):
136
138
part_info ['parameters' ][param ['ParameterName' ]] = param ['ParameterValue' ]
137
139
138
140
# query the prices
139
- response = download (tme_api_request ('/Products/GetPrices' , tme_api_settings , part_number ))
141
+ response = download (tme_api_request ('/Products/GetPrices' , tme_api_settings , part_number , currency = 'USD' ))
140
142
# check if accidentally no data returned
141
143
if response is None or response ['Status' ] != 'OK' :
142
144
return part_info
0 commit comments