Skip to content

Commit 3add914

Browse files
🐛 Source Square: Update _send_request method due to changes in Airbyte CDK (#4645)
1 parent 76a86c3 commit 3add914

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/77225a51-cd15-4a13-af02-65816bd0ecf4.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"sourceDefinitionId": "77225a51-cd15-4a13-af02-65816bd0ecf4",
33
"name": "Square",
44
"dockerRepository": "airbyte/source-square",
5-
"dockerImageTag": "0.1.0",
5+
"dockerImageTag": "0.1.1",
66
"documentationUrl": "https://docs.airbyte.io/integrations/sources/square"
77
}

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@
356356
- sourceDefinitionId: 77225a51-cd15-4a13-af02-65816bd0ecf4
357357
name: Square
358358
dockerRepository: airbyte/source-square
359-
dockerImageTag: 0.1.0
359+
dockerImageTag: 0.1.1
360360
documentationUrl: https://docs.airbyte.io/integrations/sources/square
361361
- sourceDefinitionId: 325e0640-e7b3-4e24-b823-3361008f603f
362362
name: Zendesk Sunshine

airbyte-integrations/connectors/source-square/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ RUN pip install .
1212
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1313
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1414

15-
LABEL io.airbyte.version=0.1.0
15+
LABEL io.airbyte.version=0.1.1
1616
LABEL io.airbyte.name=airbyte/source-square

airbyte-integrations/connectors/source-square/source_square/source.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,13 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp
8787
records = json_response.get(self.data_field, []) if self.data_field is not None else json_response
8888
yield from records
8989

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:
9191
try:
92-
return super()._send_request(request)
92+
return super()._send_request(request, request_kwargs)
9393
except requests.exceptions.HTTPError as e:
9494
square_exception = parse_square_error_response(e)
9595
if square_exception:
9696
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-
10197
raise e
10298

10399

@@ -310,6 +306,14 @@ def request_params(self, **kwargs) -> MutableMapping[str, Any]:
310306
params_payload["limit"] = self.items_per_page_limit
311307
return params_payload
312308

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+
313317

314318
class Customers(SquareStreamPageParam):
315319
""" 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]]]:
367371
"No locations found. Orders cannot be extracted without locations. "
368372
"Check https://developer.squareup.com/explorer/square/locations-api/list-locations"
369373
)
370-
exit(1)
374+
yield from []
371375

372376
separated_locations = separate_items_by_count(location_ids, self.locations_per_requets)
373377
for location in separated_locations:

docs/integrations/sources/square.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,5 @@ Some Square API endpoints has different page size limitation
7979

8080
| Version | Date | Pull Request | Subject |
8181
| :------ | :-------- | :----- | :------ |
82-
| 0.1.0 | 2021-06-30 | [4439](https://github.com/airbytehq/airbyte/pull/4439) | Initial release supporting the Square API |
82+
| 0.1.1 | 2021-07-09 | [4645](https://github.com/airbytehq/airbyte/pull/4645) | Update _send_request method due to Airbyte CDK changes |
83+
| 0.1.0 | 2021-06-30 | [4439](https://github.com/airbytehq/airbyte/pull/4439) | Initial release supporting the Square API |

0 commit comments

Comments
 (0)