@@ -161,7 +161,7 @@ def preview_response(resp_data: Any, max_len: int = 200) -> str:
161161 text = json .dumps (resp_data [:2 ], indent = 2 ) + f"\n ... ({ len (resp_data )} items)"
162162 else :
163163 text = str (resp_data )
164-
164+
165165 if len (text ) > max_len :
166166 return text [:max_len ] + "..."
167167 return text
@@ -174,28 +174,28 @@ def preview_response(resp_data: Any, max_len: int = 200) -> str:
174174def run_sync_requests (profile : str = "chrome_120" , verbose : bool = True ) -> list [RequestResult ]:
175175 """Run requests using sync client."""
176176 results : list [RequestResult ] = []
177-
177+
178178 print (f"\n { '=' * 70 } " )
179179 print (f" GAKIDO DUMMY API REQUESTS (Sync)" )
180180 print (f" Profile: { profile } " )
181181 print (f"{ '=' * 70 } " )
182-
182+
183183 with Client (impersonate = profile , timeout = 15.0 ) as client :
184184 for api_name , api_config in DUMMY_APIS .items ():
185185 print (f"\n --- { api_name } : { api_config ['description' ]} ---" )
186-
186+
187187 for endpoint_name , endpoint_path in api_config ["endpoints" ].items ():
188188 url = make_url (api_config , endpoint_path )
189-
189+
190190 try :
191191 resp = client .get (url )
192-
192+
193193 try :
194194 data = resp .json ()
195195 preview = preview_response (data )
196196 except Exception :
197197 preview = resp .text [:200 ]
198-
198+
199199 result = RequestResult (
200200 api_name = api_name ,
201201 endpoint_name = endpoint_name ,
@@ -204,11 +204,11 @@ def run_sync_requests(profile: str = "chrome_120", verbose: bool = True) -> list
204204 status_code = resp .status_code ,
205205 response_preview = preview ,
206206 )
207-
207+
208208 if verbose :
209209 status = "✅" if result .success else "❌"
210210 print (f" { status } { endpoint_name :20s} HTTP { resp .status_code } " )
211-
211+
212212 except Exception as e :
213213 result = RequestResult (
214214 api_name = api_name ,
@@ -219,9 +219,9 @@ def run_sync_requests(profile: str = "chrome_120", verbose: bool = True) -> list
219219 )
220220 if verbose :
221221 print (f" ❌ { endpoint_name :20s} ERROR: { str (e )[:50 ]} " )
222-
222+
223223 results .append (result )
224-
224+
225225 return results
226226
227227
@@ -232,28 +232,28 @@ def run_sync_requests(profile: str = "chrome_120", verbose: bool = True) -> list
232232async def run_async_requests (profile : str = "chrome_120" , verbose : bool = True ) -> list [RequestResult ]:
233233 """Run requests using async client."""
234234 results : list [RequestResult ] = []
235-
235+
236236 print (f"\n { '=' * 70 } " )
237237 print (f" GAKIDO DUMMY API REQUESTS (Async)" )
238238 print (f" Profile: { profile } " )
239239 print (f"{ '=' * 70 } " )
240-
240+
241241 async with AsyncClient (impersonate = profile , timeout = 15.0 ) as client :
242242 for api_name , api_config in DUMMY_APIS .items ():
243243 print (f"\n --- { api_name } : { api_config ['description' ]} ---" )
244-
244+
245245 for endpoint_name , endpoint_path in api_config ["endpoints" ].items ():
246246 url = make_url (api_config , endpoint_path )
247-
247+
248248 try :
249249 resp = await client .get (url )
250-
250+
251251 try :
252252 data = resp .json ()
253253 preview = preview_response (data )
254254 except Exception :
255255 preview = resp .text [:200 ]
256-
256+
257257 result = RequestResult (
258258 api_name = api_name ,
259259 endpoint_name = endpoint_name ,
@@ -262,11 +262,11 @@ async def run_async_requests(profile: str = "chrome_120", verbose: bool = True)
262262 status_code = resp .status_code ,
263263 response_preview = preview ,
264264 )
265-
265+
266266 if verbose :
267267 status = "✅" if result .success else "❌"
268268 print (f" { status } { endpoint_name :20s} HTTP { resp .status_code } " )
269-
269+
270270 except Exception as e :
271271 result = RequestResult (
272272 api_name = api_name ,
@@ -277,9 +277,9 @@ async def run_async_requests(profile: str = "chrome_120", verbose: bool = True)
277277 )
278278 if verbose :
279279 print (f" ❌ { endpoint_name :20s} ERROR: { str (e )[:50 ]} " )
280-
280+
281281 results .append (result )
282-
282+
283283 return results
284284
285285
@@ -292,7 +292,7 @@ def run_crud_examples(profile: str = "chrome_120") -> None:
292292 print (f"\n { '=' * 70 } " )
293293 print (f" CRUD OPERATIONS EXAMPLES" )
294294 print (f"{ '=' * 70 } " )
295-
295+
296296 with Client (impersonate = profile , timeout = 15.0 ) as client :
297297 # POST - Create
298298 print ("\n --- POST (Create) ---" )
@@ -308,7 +308,7 @@ def run_crud_examples(profile: str = "chrome_120") -> None:
308308 )
309309 print (f" POST /posts: HTTP { resp .status_code } " )
310310 print (f" Response: { resp .json ()} " )
311-
311+
312312 # PUT - Update
313313 print ("\n --- PUT (Update) ---" )
314314 put_data = {
@@ -324,7 +324,7 @@ def run_crud_examples(profile: str = "chrome_120") -> None:
324324 )
325325 print (f" PUT /posts/1: HTTP { resp .status_code } " )
326326 print (f" Response: { resp .json ()} " )
327-
327+
328328 # PATCH - Partial Update
329329 print ("\n --- PATCH (Partial Update) ---" )
330330 patch_data = {"title" : "Patched Title Only" }
@@ -335,12 +335,12 @@ def run_crud_examples(profile: str = "chrome_120") -> None:
335335 )
336336 print (f" PATCH /posts/1: HTTP { resp .status_code } " )
337337 print (f" Response: { resp .json ()} " )
338-
338+
339339 # DELETE
340340 print ("\n --- DELETE ---" )
341341 resp = client .delete ("https://jsonplaceholder.typicode.com/posts/1" )
342342 print (f" DELETE /posts/1: HTTP { resp .status_code } " )
343-
343+
344344 # POST with form data
345345 print ("\n --- POST (Form Data) ---" )
346346 resp = client .post (
@@ -361,7 +361,7 @@ def run_specific_examples(profile: str = "chrome_120") -> None:
361361 print (f"\n { '=' * 70 } " )
362362 print (f" SPECIFIC API EXAMPLES" )
363363 print (f"{ '=' * 70 } " )
364-
364+
365365 with Client (impersonate = profile , timeout = 15.0 ) as client :
366366 # Random User
367367 print ("\n --- Random User ---" )
@@ -370,22 +370,22 @@ def run_specific_examples(profile: str = "chrome_120") -> None:
370370 print (f" Name: { user ['name' ]['first' ]} { user ['name' ]['last' ]} " )
371371 print (f" Email: { user ['email' ]} " )
372372 print (f" Country: { user ['location' ]['country' ]} " )
373-
373+
374374 # Random Joke
375375 print ("\n --- Random Joke ---" )
376376 resp = client .get ("https://official-joke-api.appspot.com/random_joke" )
377377 joke = resp .json ()
378378 print (f" Setup: { joke ['setup' ]} " )
379379 print (f" Punchline: { joke ['punchline' ]} " )
380-
380+
381381 # IP Info
382382 print ("\n --- Your IP Info ---" )
383383 resp = client .get ("https://ipinfo.io/json" )
384384 ip_info = resp .json ()
385385 print (f" IP: { ip_info .get ('ip' , 'N/A' )} " )
386386 print (f" City: { ip_info .get ('city' , 'N/A' )} " )
387387 print (f" Country: { ip_info .get ('country' , 'N/A' )} " )
388-
388+
389389 # Random Quote
390390 print ("\n --- Random Quote ---" )
391391 try :
@@ -400,7 +400,7 @@ def run_specific_examples(profile: str = "chrome_120") -> None:
400400 print (f" (Quote API returned { resp .status_code } )" )
401401 except Exception as e :
402402 print (f" (Quote API error: { str (e )[:50 ]} )" )
403-
403+
404404 # DummyJSON Product
405405 print ("\n --- Random Product ---" )
406406 resp = client .get ("https://dummyjson.com/products/1" )
@@ -419,14 +419,14 @@ def print_summary(results: list[RequestResult]) -> None:
419419 total = len (results )
420420 passed = sum (1 for r in results if r .success )
421421 failed = total - passed
422-
422+
423423 print (f"\n { '=' * 70 } " )
424424 print (f" SUMMARY" )
425425 print (f"{ '=' * 70 } " )
426426 print (f" Total requests: { total } " )
427427 print (f" Successful: { passed } ({ passed / total * 100 :.1f} %)" )
428428 print (f" Failed: { failed } " )
429-
429+
430430 if failed > 0 :
431431 print ("\n Failed requests:" )
432432 for r in results :
@@ -487,9 +487,9 @@ def main() -> None:
487487 action = "store_true" ,
488488 help = "Suppress verbose output" ,
489489 )
490-
490+
491491 args = parser .parse_args ()
492-
492+
493493 if args .crud :
494494 run_crud_examples (args .profile )
495495 elif args .examples :
0 commit comments