diff --git a/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/d913b0f2-cc51-4e55-a44c-8ba1697b9239.json b/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/d913b0f2-cc51-4e55-a44c-8ba1697b9239.json index 558223e7b925f..84b99570642b4 100644 --- a/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/d913b0f2-cc51-4e55-a44c-8ba1697b9239.json +++ b/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/d913b0f2-cc51-4e55-a44c-8ba1697b9239.json @@ -2,7 +2,7 @@ "sourceDefinitionId": "d913b0f2-cc51-4e55-a44c-8ba1697b9239", "name": "Paypal Transaction", "dockerRepository": "airbyte/source-paypal-transaction", - "dockerImageTag": "0.1.2", + "dockerImageTag": "0.1.3", "documentationUrl": "https://docs.airbyte.io/integrations/sources/paypal-transaction", "icon": "paypal.svg" } diff --git a/airbyte-config/init/src/main/resources/seed/destination_specs.yaml b/airbyte-config/init/src/main/resources/seed/destination_specs.yaml index 8d81c1adf9c4f..149093a4ace98 100644 --- a/airbyte-config/init/src/main/resources/seed/destination_specs.yaml +++ b/airbyte-config/init/src/main/resources/seed/destination_specs.yaml @@ -3457,7 +3457,7 @@ supported_destination_sync_modes: - "overwrite" - "append" -- dockerImage: "airbyte/destination-snowflake:0.3.20" +- dockerImage: "airbyte/destination-snowflake:0.3.21" spec: documentationUrl: "https://docs.airbyte.io/integrations/destinations/snowflake" connectionSpecification: 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 31750399f70f2..9235f813eaa08 100644 --- a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml @@ -469,7 +469,7 @@ - name: Paypal Transaction sourceDefinitionId: d913b0f2-cc51-4e55-a44c-8ba1697b9239 dockerRepository: airbyte/source-paypal-transaction - dockerImageTag: 0.1.2 + dockerImageTag: 0.1.3 documentationUrl: https://docs.airbyte.io/integrations/sources/paypal-transaction icon: paypal.svg sourceType: api diff --git a/airbyte-config/init/src/main/resources/seed/source_specs.yaml b/airbyte-config/init/src/main/resources/seed/source_specs.yaml index 62eb4f80348fe..56e1fef01dca2 100644 --- a/airbyte-config/init/src/main/resources/seed/source_specs.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_specs.yaml @@ -4804,7 +4804,7 @@ supportsNormalization: false supportsDBT: false supported_destination_sync_modes: [] -- dockerImage: "airbyte/source-paypal-transaction:0.1.2" +- dockerImage: "airbyte/source-paypal-transaction:0.1.3" spec: documentationUrl: "https://docs.airbyte.io/integrations/sources/paypal-transactions" connectionSpecification: diff --git a/airbyte-integrations/connectors/source-paypal-transaction/Dockerfile b/airbyte-integrations/connectors/source-paypal-transaction/Dockerfile index ef14562d18733..d0f4b175fa160 100644 --- a/airbyte-integrations/connectors/source-paypal-transaction/Dockerfile +++ b/airbyte-integrations/connectors/source-paypal-transaction/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.2 +LABEL io.airbyte.version=0.1.3 LABEL io.airbyte.name=airbyte/source-paypal-transaction diff --git a/airbyte-integrations/connectors/source-paypal-transaction/README.md b/airbyte-integrations/connectors/source-paypal-transaction/README.md index 98e55ff6675af..d4fa2d383d783 100644 --- a/airbyte-integrations/connectors/source-paypal-transaction/README.md +++ b/airbyte-integrations/connectors/source-paypal-transaction/README.md @@ -99,7 +99,8 @@ Customize `acceptance-test-config.yml` file to configure tests. See [Source Acce If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py. To run your integration tests with acceptance tests, from the connector root, run ``` -python -m pytest integration_tests -p integration_tests.acceptance +docker build . --no-cache -t airbyte/source-paypal-transaction:dev \ +&& python -m pytest -p source_acceptance_test.plugin ``` To run your integration tests with docker diff --git a/airbyte-integrations/connectors/source-paypal-transaction/source_paypal_transaction/source.py b/airbyte-integrations/connectors/source-paypal-transaction/source_paypal_transaction/source.py index 766be4255c8eb..e05f656f75b45 100644 --- a/airbyte-integrations/connectors/source-paypal-transaction/source_paypal_transaction/source.py +++ b/airbyte-integrations/connectors/source-paypal-transaction/source_paypal_transaction/source.py @@ -2,6 +2,7 @@ # Copyright (c) 2021 Airbyte, Inc., all rights reserved. # +import json import logging import time from abc import ABC @@ -16,6 +17,30 @@ from dateutil.parser import isoparse +class PaypalHttpException(Exception): + """HTTPError Exception with detailed info""" + + def __init__(self, error: requests.exceptions.HTTPError): + self.error = error + + def __str__(self): + message = repr(self.error) + + if self.error.response.content: + content = self.error.response.content.decode() + try: + details = json.loads(content) + except json.decoder.JSONDecodeError: + details = content + + message = f"{message} Details: {details}" + + return message + + def __repr__(self): + return self.__str__() + + def get_endpoint(is_sandbox: bool = False) -> str: if is_sandbox: endpoint = "https://api-m.sandbox.paypal.com" @@ -227,6 +252,12 @@ def stream_slices( return slices + def _send_request(self, request: requests.PreparedRequest, request_kwargs: Mapping[str, Any]) -> requests.Response: + try: + return super()._send_request(request, request_kwargs) + except requests.exceptions.HTTPError as http_error: + raise PaypalHttpException(http_error) + class Transactions(PaypalTransactionStream): """List Paypal Transactions on a specific date range @@ -351,11 +382,28 @@ def check_connection(self, logger, config) -> Tuple[bool, any]: # Try to initiate a stream and validate input date params try: + # validate input date ranges Transactions(authenticator=authenticator, **config).validate_input_dates() - except Exception as e: - return False, e - return True, None + # validate if Paypal API is able to extract data for given start_data + start_date = isoparse(config["start_date"]) + end_date = start_date + timedelta(days=1) + stream_slice = { + "start_date": start_date.isoformat(), + "end_date": end_date.isoformat(), + } + records = Transactions(authenticator=authenticator, **config).read_records( + sync_mode=None, + stream_slice=stream_slice + ) + # Try to read one value from records iterator + next(records, None) + return True, None + except Exception as e: + if "Data for the given start date is not available" in repr(e): + return False, f"Data for the given start date ({config['start_date']}) is not available, please use more recent start date" + else: + return False, e def streams(self, config: Mapping[str, Any]) -> List[Stream]: """ diff --git a/docs/integrations/sources/paypal-transaction.md b/docs/integrations/sources/paypal-transaction.md index f9023b31105b5..c21d6cdaaaa46 100644 --- a/docs/integrations/sources/paypal-transaction.md +++ b/docs/integrations/sources/paypal-transaction.md @@ -57,6 +57,7 @@ Transactions sync is performed with default `stream_slice_period` = 1 day, it me | Version | Date | Pull Request | Subject | | :--- | :--- | :--- | :--- | +| 0.1.3 | 2021-12-16 | [8580](https://github.com/airbytehq/airbyte/pull/8580) | Added more logs during `check connection` stage | | 0.1.2 | 2021-11-08 | [7499](https://github.com/airbytehq/airbyte/pull/7499) | Remove base-python dependencies | | 0.1.1 | 2021-08-03 | [5155](https://github.com/airbytehq/airbyte/pull/5155) | fix start\_date\_min limit | | 0.1.0 | 2021-06-10 | [4240](https://github.com/airbytehq/airbyte/pull/4240) | PayPal Transaction Search API |