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

Fix/satisfaction ratings start #67

Merged
merged 3 commits into from
Sep 15, 2021
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
4 changes: 3 additions & 1 deletion tap_zendesk/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 5 additions & 4 deletions tap_zendesk/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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'])
Expand Down