From 871f2470f8716d41ba3f5eb6dae6adf435daef3e Mon Sep 17 00:00:00 2001 From: Andy Lu Date: Wed, 15 Sep 2021 17:19:40 +0000 Subject: [PATCH 1/3] Allow headers and params to pass through --- tap_zendesk/http.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tap_zendesk/http.py b/tap_zendesk/http.py index e27bfaf..4448032 100644 --- a/tap_zendesk/http.py +++ b/tap_zendesk/http.py @@ -29,16 +29,18 @@ def call_api(url, params, headers): -def get_cursor_based(url, access_token, cursor=None): +def get_cursor_based(url, access_token, cursor=None, **kwargs): # something like this headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': 'Bearer {}'.format(access_token), + **kwargs.get('headers', {}) } params = { 'page[size]': 100, + **kwargs.get('params', {}) } if cursor: From ce6d07ada977742b64e0c662e0c9cf7d77229b22 Mon Sep 17 00:00:00 2001 From: Andy Lu Date: Wed, 15 Sep 2021 17:20:05 +0000 Subject: [PATCH 2/3] Call API with bookmark --- tap_zendesk/streams.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tap_zendesk/streams.py b/tap_zendesk/streams.py index 5a9438c..47f7924 100644 --- a/tap_zendesk/streams.py +++ b/tap_zendesk/streams.py @@ -380,8 +380,9 @@ class SatisfactionRatings(Stream): def sync(self, state): bookmark = self.get_bookmark(state) - - ratings = self.get_objects() + epoch_bookmark = int(bookmark.timestamp()) + params = {'start_time': epoch_bookmark} + ratings = self.get_objects(params=params) for rating in ratings: if utils.strptime_with_tz(rating['updated_at']) >= bookmark: self.update_bookmark(state, rating['updated_at']) From 558ab90cba80c0f5e573caad4ed4fb5f30e91af6 Mon Sep 17 00:00:00 2001 From: Andy Lu Date: Wed, 15 Sep 2021 17:25:03 +0000 Subject: [PATCH 3/3] Fix addition: allow kwargs to get passed through --- tap_zendesk/streams.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tap_zendesk/streams.py b/tap_zendesk/streams.py index 47f7924..fa03a2c 100644 --- a/tap_zendesk/streams.py +++ b/tap_zendesk/streams.py @@ -66,13 +66,13 @@ def __init__(self, client=None, config=None): self.client = client self.config = config - def get_objects(self): + def get_objects(self, **kwargs): ''' Cursor based object retrieval ''' url = self.endpoint.format(self.config['subdomain']) - for page in http.get_cursor_based(url, self.config['access_token']): + for page in http.get_cursor_based(url, self.config['access_token'], **kwargs): yield from page[self.item_key] def get_bookmark(self, state):