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

chore: use cursor base pagination for full refresh streams zender support #196

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -5,7 +5,7 @@

from setuptools import find_packages, setup

MAIN_REQUIREMENTS = ["airbyte-cdk", "pytz", "requests-futures~=1.0.0", "pendulum~=2.1.2"]
MAIN_REQUIREMENTS = ["airbyte-cdk==0.67", "pytz", "requests-futures~=1.0.0", "pendulum~=2.1.2"]

TEST_REQUIREMENTS = ["pytest~=6.1", "pytest-mock~=3.6", "connector-acceptance-test", "requests-mock==1.9.3"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,27 +408,17 @@ def path(self, **kwargs):
def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]:
if self._ignore_pagination:
return None
next_page = self._parse_next_page_number(response)
if not next_page:
self._finished = True
return None
return next_page
meta = response.json().get("meta",{}) if response.content else {}
return {"page[after]": meta.get("after_cursor")} if meta.get("has_more") else None

def request_params(self, next_page_token: Mapping[str, Any] = None, **kwargs) -> MutableMapping[str, Any]:
params = super().request_params(next_page_token=next_page_token, **kwargs)
params.update(
{
"page": next_page_token or 1,
"per_page": self.page_size,
}
)
params = {"page[size]": self.page_size}
if next_page_token:
params.update(next_page_token)
return params


class SourceZendeskSupportOffsetPaginationStream(SourceZendeskSupportFullRefreshStream):
"""
TODO: Migrate incremental streams to SourceZendeskSupportPaginationStream also and see if we can remove this class.
"""
class SourceZendeskSupportTimeBasePaginationStream(SourceZendeskSupportFullRefreshStream):

cursor_field = "updated_at"
next_page_field = "next_page"
Expand Down Expand Up @@ -535,7 +525,7 @@ def request_params(
return params


class SourceZendeskIncrementalExportStream(SourceZendeskSupportOffsetPaginationStream):
class SourceZendeskIncrementalExportStream(SourceZendeskSupportTimeBasePaginationStream):
"""Incremental Export from Tickets stream:
https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-ticket-export-time-based

Expand Down Expand Up @@ -720,7 +710,7 @@ class TicketFields(SourceZendeskSupportStream):
"""TicketFields stream: https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/"""


class TicketForms(SourceZendeskSupportOffsetPaginationStream):
class TicketForms(SourceZendeskSupportTimeBasePaginationStream):
"""TicketForms stream: https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms"""

"""
Expand Down
Loading