Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Source Square: Update _send_request method due to changes in Airbyte CDK #4645

Merged
merged 8 commits into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-square/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -367,12 +363,18 @@ 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)
return [None]
TymoshokDmytro marked this conversation as resolved.
Show resolved Hide resolved

separated_locations = separate_items_by_count(location_ids, self.locations_per_requets)
for location in separated_locations:
yield {"location_ids": location}

def read_records(self, stream_slice: Mapping[str, Any] = None, **kwargs) -> Iterable[Mapping[str, Any]]:
TymoshokDmytro marked this conversation as resolved.
Show resolved Hide resolved
if not stream_slice:
yield from []

yield from super().read_records(stream_slice=stream_slice, **kwargs)


class SourceSquare(AbstractSource):
api_version = "2021-06-16" # Latest Stable Release
Expand Down
3 changes: 2 additions & 1 deletion docs/integrations/sources/square.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| 0.1.0 | 2021-06-30 | [4439](https://github.com/airbytehq/airbyte/pull/4439) | Initial release supporting the Square API |
TymoshokDmytro marked this conversation as resolved.
Show resolved Hide resolved
| 0.1.1 | 2021-07-09 | [4645](https://github.com/airbytehq/airbyte/pull/4645) | Update _send_request method due to Airbyte CDK changes |