77from typing import List , Union
88
99from . import models
10- from .errors import InvalidArgumentException
1110from .helpers import arguments , requests
1211from .helpers .generators import get_list_chunks
12+ from .errors import InvalidArgumentException
1313from .helpers .items import sort_items
1414from .sdk .api .default_api import DefaultApi
1515
@@ -29,7 +29,15 @@ class AmazonApi:
2929 ``InvalidArgumentException``
3030 """
3131
32- def __init__ (self , key : str , secret : str , tag : str , country : models .Country , throttling : float = 1 , ** kwargs ):
32+ def __init__ (
33+ self ,
34+ key : str ,
35+ secret : str ,
36+ tag : str ,
37+ country : models .Country ,
38+ throttling : float = 1 ,
39+ ** kwargs
40+ ):
3341 self ._key = key
3442 self ._secret = secret
3543 self ._tag = tag
@@ -38,15 +46,14 @@ def __init__(self, key: str, secret: str, tag: str, country: models.Country, thr
3846 self ._last_query_time = time .time () - throttling
3947
4048 try :
41- self ._host = ' webservices.amazon.' + models .regions .DOMAINS [country ]
49+ self ._host = " webservices.amazon." + models .regions .DOMAINS [country ]
4250 self ._region = models .regions .REGIONS [country ]
43- self ._marketplace = ' www.amazon.' + models .regions .DOMAINS [country ]
51+ self ._marketplace = " www.amazon." + models .regions .DOMAINS [country ]
4452 except KeyError as error :
45- raise InvalidArgumentException (' Country code is not correct' ) from error
53+ raise InvalidArgumentException (" Country code is not correct" ) from error
4654
4755 self ._api = DefaultApi (key , secret , self ._host , self ._region )
4856
49-
5057 def get_items (
5158 self ,
5259 items : Union [str , List [str ]],
@@ -85,12 +92,14 @@ def get_items(
8592 ``ItemsNotFoundException``
8693 """
8794
88- kwargs .update ({
89- 'condition' : condition ,
90- 'merchant' : merchant ,
91- 'currency_of_preference' : currency_of_preference ,
92- 'languages_of_preference' : languages_of_preference
93- })
95+ kwargs .update (
96+ {
97+ "condition" : condition ,
98+ "merchant" : merchant ,
99+ "currency_of_preference" : currency_of_preference ,
100+ "languages_of_preference" : languages_of_preference ,
101+ }
102+ )
94103
95104 items_ids = arguments .get_items_ids (items )
96105 results = []
@@ -103,7 +112,6 @@ def get_items(
103112
104113 return sort_items (results , items_ids , include_unavailable )
105114
106-
107115 def search_items (
108116 self ,
109117 item_count : int = None ,
@@ -181,36 +189,37 @@ def search_items(
181189 ``ItemsNotFoundException``
182190 """
183191
184- kwargs .update ({
185- 'item_count' : item_count ,
186- 'item_page' : item_page ,
187- 'actor' : actor ,
188- 'artist' : artist ,
189- 'author' : author ,
190- 'brand' : brand ,
191- 'keywords' : keywords ,
192- 'title' : title ,
193- 'availability' : availability ,
194- 'browse_node_id' : browse_node_id ,
195- 'condition' : condition ,
196- 'currency_of_preference' : currency_of_preference ,
197- 'delivery_flags' : delivery_flags ,
198- 'languages_of_preference' : languages_of_preference ,
199- 'max_price' : max_price ,
200- 'merchant' : merchant ,
201- 'min_price' : min_price ,
202- 'min_reviews_rating' : min_reviews_rating ,
203- 'min_saving_percent' : min_saving_percent ,
204- 'search_index' : search_index ,
205- 'sort_by' : sort_by ,
206- })
192+ kwargs .update (
193+ {
194+ "item_count" : item_count ,
195+ "item_page" : item_page ,
196+ "actor" : actor ,
197+ "artist" : artist ,
198+ "author" : author ,
199+ "brand" : brand ,
200+ "keywords" : keywords ,
201+ "title" : title ,
202+ "availability" : availability ,
203+ "browse_node_id" : browse_node_id ,
204+ "condition" : condition ,
205+ "currency_of_preference" : currency_of_preference ,
206+ "delivery_flags" : delivery_flags ,
207+ "languages_of_preference" : languages_of_preference ,
208+ "max_price" : max_price ,
209+ "merchant" : merchant ,
210+ "min_price" : min_price ,
211+ "min_reviews_rating" : min_reviews_rating ,
212+ "min_saving_percent" : min_saving_percent ,
213+ "search_index" : search_index ,
214+ "sort_by" : sort_by ,
215+ }
216+ )
207217
208218 arguments .check_search_args (** kwargs )
209219 request = requests .get_search_items_request (self , ** kwargs )
210220 self ._throttle ()
211221 return requests .get_search_items_response (self , request )
212222
213-
214223 def get_variations (
215224 self ,
216225 asin : str ,
@@ -252,22 +261,23 @@ def get_variations(
252261
253262 asin = arguments .get_items_ids (asin )[0 ]
254263
255- kwargs .update ({
256- 'asin' : asin ,
257- 'variation_count' : variation_count ,
258- 'variation_page' : variation_page ,
259- 'condition' : condition ,
260- 'currency_of_preference' : currency_of_preference ,
261- 'languages_of_preference' : languages_of_preference ,
262- 'merchant' : merchant
263- })
264+ kwargs .update (
265+ {
266+ "asin" : asin ,
267+ "variation_count" : variation_count ,
268+ "variation_page" : variation_page ,
269+ "condition" : condition ,
270+ "currency_of_preference" : currency_of_preference ,
271+ "languages_of_preference" : languages_of_preference ,
272+ "merchant" : merchant ,
273+ }
274+ )
264275
265276 arguments .check_variations_args (** kwargs )
266277 request = requests .get_variations_request (self , ** kwargs )
267278 self ._throttle ()
268279 return requests .get_variations_response (self , request )
269280
270-
271281 def get_browse_nodes (
272282 self ,
273283 browse_node_ids : List [str ],
@@ -293,17 +303,18 @@ def get_browse_nodes(
293303 ``ItemsNotFoundException``
294304 """
295305
296- kwargs .update ({
297- 'browse_node_ids' : browse_node_ids ,
298- 'languages_of_preference' : languages_of_preference
299- })
306+ kwargs .update (
307+ {
308+ "browse_node_ids" : browse_node_ids ,
309+ "languages_of_preference" : languages_of_preference ,
310+ }
311+ )
300312
301313 arguments .check_browse_nodes_args (** kwargs )
302314 request = requests .get_browse_nodes_request (self , ** kwargs )
303315 self ._throttle ()
304316 return requests .get_browse_nodes_response (self , request )
305317
306-
307318 def _throttle (self ):
308319 wait_time = self ._throttling - (time .time () - self ._last_query_time )
309320 if wait_time > 0 :
0 commit comments