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

🎉 New Source: Recharge #3466

Merged
merged 9 commits into from
May 20, 2021
Merged

Conversation

yevhenii-ldv
Copy link
Contributor

What

closes #2308

How

Describe the solution

Pre-merge Checklist

  • Run integration tests
  • Publish Docker images

Recommended reading order

  1. schemas.py
  2. streams.py
  3. source.py

@yevhenii-ldv
Copy link
Contributor Author

yevhenii-ldv commented May 18, 2021

/test connector=source-recharge

🕑 source-recharge https://github.com/airbytehq/airbyte/actions/runs/853435223
❌ source-recharge https://github.com/airbytehq/airbyte/actions/runs/853435223

@yevhenii-ldv
Copy link
Contributor Author

yevhenii-ldv commented May 18, 2021

/test connector=source-recharge

🕑 source-recharge https://github.com/airbytehq/airbyte/actions/runs/853458429
✅ source-recharge https://github.com/airbytehq/airbyte/actions/runs/853458429

@@ -0,0 +1,7 @@
*
!Dockerfile
!Dockerfile.test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed


dependencies {
implementation files(project(':airbyte-integrations:bases:source-acceptance-test').airbyteDocker.outputs)
implementation files(project(':airbyte-integrations:bases:base-python').airbyteDocker.outputs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we don't need this anymore

@@ -0,0 +1,21 @@
{
"addresses": {
"created_at": "2024-05-18T00:00:00"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you are not going to be around at that time?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set other dates

from setuptools import find_packages, setup

MAIN_REQUIREMENTS = [
"airbyte-cdk",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets pin version, for example ~=0.1

@@ -0,0 +1,27 @@
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one has old header

super().__init__(**kwargs)
self._start_date = pendulum.parse(start_date)

cursor_field = "created_at"
Copy link
Contributor

@keu keu May 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets keep all class attributes on top of the Class


def read_records(self, stream_slice: Optional[Mapping[str, Any]] = None, **kwargs) -> Iterable[Mapping[str, Any]]:
owner_resources = ["customer", "store", "subscription"]
for owner in owner_resources:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure that logic that saves state works correctly here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is Not Incremental stream

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oopsii


primary_key = ["shop", "store"]

def get_stream_data(self, response_data: Any) -> List[dict]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets move this logic inside parent class:

  • declare data_path property, default return self.name
  • if data_path is not none response_data = response_data.get(self.name, [])
  • set data_path to None here
    WDYT?

Copy link
Contributor

@keu keu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good in general

@yevhenii-ldv yevhenii-ldv requested a review from keu May 19, 2021 14:43
@yevhenii-ldv
Copy link
Contributor Author

yevhenii-ldv commented May 19, 2021

/test connector=source-recharge

🕑 source-recharge https://github.com/airbytehq/airbyte/actions/runs/857252220
❌ source-recharge https://github.com/airbytehq/airbyte/actions/runs/857252220

from airbyte_cdk.sources.streams.http import HttpStream


class RechargeStream(HttpStream, ABC):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really clean implementation. Well done!


class RechargeTokenAuthenticator(TokenAuthenticator):
def get_auth_header(self) -> Mapping[str, Any]:
return {"X-Recharge-Access-Token": self._token}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW you can use TokenAuthenticator and pass the auth header instead of creating a custom authenticator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it but doesn't work in this case. I only need the token in the value, and if I specify auth_method as an empty string, then I get the following value:
{"X-Recharge-Access-Token": f" self._token"}
And the requests library swears for the presence of a space before the token itself.

list(Shop(authenticator=auth).read_records(SyncMode.full_refresh))
return True, None
except Exception as error:
return False, f"Unable to connect to Recharge API with the provided credentials - {error}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to use repr(error)


### Performance considerations

The Recharge connector should not run into Recharge API limitations under normal usage. Please [create an issue](https://github.com/airbytehq/airbyte/issues) if you see any rate limit issues that are not automatically retried successfully.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Recharge connector should not run into Recharge API limitations under normal usage. Please [create an issue](https://github.com/airbytehq/airbyte/issues) if you see any rate limit issues that are not automatically retried successfully.
The Recharge connector should gracefully handle Recharge API limitations under normal usage. Please [create an issue](https://github.com/airbytehq/airbyte/issues) if you see any rate limit issues that are not automatically retried successfully.

@yevhenii-ldv
Copy link
Contributor Author

yevhenii-ldv commented May 20, 2021

/test connector=source-recharge

🕑 source-recharge https://github.com/airbytehq/airbyte/actions/runs/860148818
✅ source-recharge https://github.com/airbytehq/airbyte/actions/runs/860148818

@yevhenii-ldv
Copy link
Contributor Author

yevhenii-ldv commented May 20, 2021

/publish connector=connectors/source-recharge

🕑 connectors/source-recharge https://github.com/airbytehq/airbyte/actions/runs/860220716
✅ connectors/source-recharge https://github.com/airbytehq/airbyte/actions/runs/860220716

@yevhenii-ldv yevhenii-ldv merged commit 3647c3c into master May 20, 2021
@yevhenii-ldv yevhenii-ldv deleted the ykurochkin/new-connector-recharge branch May 20, 2021 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New source: Recharge
4 participants