@@ -87,17 +87,13 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp
87
87
records = json_response .get (self .data_field , []) if self .data_field is not None else json_response
88
88
yield from records
89
89
90
- def _send_request (self , request : requests .PreparedRequest ) -> requests .Response :
90
+ def _send_request (self , request : requests .PreparedRequest , request_kwargs : Mapping [ str , Any ] ) -> requests .Response :
91
91
try :
92
- return super ()._send_request (request )
92
+ return super ()._send_request (request , request_kwargs )
93
93
except requests .exceptions .HTTPError as e :
94
94
square_exception = parse_square_error_response (e )
95
95
if square_exception :
96
96
self .logger .error (str (square_exception ))
97
- # Exiting is made for not to have a huge traceback in the airbyte log.
98
- # The explicit square error message already been out with the command above.
99
- exit (1 )
100
-
101
97
raise e
102
98
103
99
@@ -310,6 +306,14 @@ def request_params(self, **kwargs) -> MutableMapping[str, Any]:
310
306
params_payload ["limit" ] = self .items_per_page_limit
311
307
return params_payload
312
308
309
+ # This stream is tricky because once in a while it returns 404 error 'Not Found for url'.
310
+ # Thus the retry strategy was implemented.
311
+ def should_retry (self , response : requests .Response ) -> bool :
312
+ return response .status_code == 404 or super ().should_retry (response )
313
+
314
+ def backoff_time (self , response : requests .Response ) -> Optional [float ]:
315
+ return 3
316
+
313
317
314
318
class Customers (SquareStreamPageParam ):
315
319
""" Docs: https://developer.squareup.com/reference/square_2021-06-16/customers-api/list-customers """
@@ -367,7 +371,7 @@ def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, Any]]]:
367
371
"No locations found. Orders cannot be extracted without locations. "
368
372
"Check https://developer.squareup.com/explorer/square/locations-api/list-locations"
369
373
)
370
- exit ( 1 )
374
+ yield from []
371
375
372
376
separated_locations = separate_items_by_count (location_ids , self .locations_per_requets )
373
377
for location in separated_locations :
0 commit comments