diff --git a/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/77225a51-cd15-4a13-af02-65816bd0ecf4.json b/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/77225a51-cd15-4a13-af02-65816bd0ecf4.json index d10a442f9c04..494d089c3e15 100644 --- a/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/77225a51-cd15-4a13-af02-65816bd0ecf4.json +++ b/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/77225a51-cd15-4a13-af02-65816bd0ecf4.json @@ -2,6 +2,6 @@ "sourceDefinitionId": "77225a51-cd15-4a13-af02-65816bd0ecf4", "name": "Square", "dockerRepository": "airbyte/source-square", - "dockerImageTag": "0.1.0", + "dockerImageTag": "0.1.1", "documentationUrl": "https://docs.airbyte.io/integrations/sources/square" } diff --git a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml index 0ab6f14de2e0..ba62225a1f76 100644 --- a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml @@ -356,7 +356,7 @@ - sourceDefinitionId: 77225a51-cd15-4a13-af02-65816bd0ecf4 name: Square dockerRepository: airbyte/source-square - dockerImageTag: 0.1.0 + dockerImageTag: 0.1.1 documentationUrl: https://docs.airbyte.io/integrations/sources/square - sourceDefinitionId: 325e0640-e7b3-4e24-b823-3361008f603f name: Zendesk Sunshine diff --git a/airbyte-integrations/connectors/source-square/Dockerfile b/airbyte-integrations/connectors/source-square/Dockerfile index eb8116a45789..3da622a68275 100644 --- a/airbyte-integrations/connectors/source-square/Dockerfile +++ b/airbyte-integrations/connectors/source-square/Dockerfile @@ -12,5 +12,5 @@ RUN pip install . ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py" ENTRYPOINT ["python", "/airbyte/integration_code/main.py"] -LABEL io.airbyte.version=0.1.0 +LABEL io.airbyte.version=0.1.1 LABEL io.airbyte.name=airbyte/source-square diff --git a/airbyte-integrations/connectors/source-square/source_square/source.py b/airbyte-integrations/connectors/source-square/source_square/source.py index 53ec57864b4f..912d13d564c2 100644 --- a/airbyte-integrations/connectors/source-square/source_square/source.py +++ b/airbyte-integrations/connectors/source-square/source_square/source.py @@ -87,17 +87,13 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp records = json_response.get(self.data_field, []) if self.data_field is not None else json_response yield from records - def _send_request(self, request: requests.PreparedRequest) -> requests.Response: + def _send_request(self, request: requests.PreparedRequest, request_kwargs: Mapping[str, Any]) -> requests.Response: try: - return super()._send_request(request) + return super()._send_request(request, request_kwargs) except requests.exceptions.HTTPError as e: square_exception = parse_square_error_response(e) if square_exception: self.logger.error(str(square_exception)) - # Exiting is made for not to have a huge traceback in the airbyte log. - # The explicit square error message already been out with the command above. - exit(1) - raise e @@ -310,6 +306,14 @@ def request_params(self, **kwargs) -> MutableMapping[str, Any]: params_payload["limit"] = self.items_per_page_limit return params_payload + # This stream is tricky because once in a while it returns 404 error 'Not Found for url'. + # Thus the retry strategy was implemented. + def should_retry(self, response: requests.Response) -> bool: + return response.status_code == 404 or super().should_retry(response) + + def backoff_time(self, response: requests.Response) -> Optional[float]: + return 3 + class Customers(SquareStreamPageParam): """ 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]]]: "No locations found. Orders cannot be extracted without locations. " "Check https://developer.squareup.com/explorer/square/locations-api/list-locations" ) - exit(1) + yield from [] separated_locations = separate_items_by_count(location_ids, self.locations_per_requets) for location in separated_locations: diff --git a/docs/integrations/sources/square.md b/docs/integrations/sources/square.md index ae51d12d1928..6bef3160a5f7 100644 --- a/docs/integrations/sources/square.md +++ b/docs/integrations/sources/square.md @@ -79,4 +79,5 @@ Some Square API endpoints has different page size limitation | Version | Date | Pull Request | Subject | | :------ | :-------- | :----- | :------ | -| 0.1.0 | 2021-06-30 | [4439](https://github.com/airbytehq/airbyte/pull/4439) | Initial release supporting the Square API | \ No newline at end of file +| 0.1.1 | 2021-07-09 | [4645](https://github.com/airbytehq/airbyte/pull/4645) | Update _send_request method due to Airbyte CDK changes | +| 0.1.0 | 2021-06-30 | [4439](https://github.com/airbytehq/airbyte/pull/4439) | Initial release supporting the Square API |