Skip to content

Commit 91015f4

Browse files
committed
fix discover + add missing endpoints
1 parent 4f39f48 commit 91015f4

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tap_zendesk/streams.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class Users(Stream):
218218
name = "users"
219219
replication_method = "INCREMENTAL"
220220
replication_key = "updated_at"
221+
endpoint = 'https://{}.zendesk.com/api/v2/users'
221222

222223
def _add_custom_fields(self, schema):
223224
try:
@@ -577,6 +578,7 @@ class TicketForms(Stream):
577578
name = "ticket_forms"
578579
replication_method = "INCREMENTAL"
579580
replication_key = "updated_at"
581+
endpoint = 'https://{}.zendesk.com/api/v2/ticket_forms'
580582

581583
def sync(self, state):
582584
bookmark = self.get_bookmark(state)
@@ -628,6 +630,7 @@ def sync(self, state):
628630
class SLAPolicies(Stream):
629631
name = "sla_policies"
630632
replication_method = "FULL_TABLE"
633+
endpoint = 'https://{}.zendesk.com/api/v2/slas/policies'
631634

632635
def sync(self, state): # pylint: disable=unused-argument
633636
for policy in self.client.sla_policies():
@@ -642,16 +645,18 @@ def check_access(self):
642645
class TalkPhoneNumbers(Stream):
643646
name = 'talk_phone_numbers'
644647
replication_method = "FULL_TABLE"
648+
endpoint = 'https://{}.zendesk.com/api/v2/channels/voice/phone_numbers'
645649

646650
def sync(self, state): # pylint: disable=unused-argument
647651
for phone_number in self.client.talk.phone_numbers():
648652
yield (self.stream, phone_number)
649653

650654

651-
class TalkCalls(Stream):
655+
class TalkCalls(CursorBasedExportStream):
652656
name = 'talk_calls'
653657
replication_method = "INCREMENTAL"
654658
replication_key = 'updated_at'
659+
endpoint = 'https://{}.zendesk.com/api/v2/channels/voice/stats/incremental/calls'
655660

656661
def sync(self, state):
657662
bookmark = self.get_bookmark(state)
@@ -668,6 +673,17 @@ def sync(self, state):
668673
self.update_bookmark(state, call.updated_at)
669674
yield (self.stream, call)
670675

676+
def check_access(self):
677+
'''
678+
Check whether the permission was given to access stream resources or not.
679+
'''
680+
url = self.endpoint.format(self.config['subdomain'])
681+
# Convert start_date parameter to timestamp to pass with request param
682+
start_time = datetime.datetime.strptime(self.config['start_date'], START_DATE_FORMAT).timestamp()
683+
HEADERS['Authorization'] = 'Bearer {}'.format(self.config["access_token"])
684+
685+
http.call_api(url, self.request_timeout, params={'start_time': f'{start_time:.0f}', 'per_page': 1}, headers=HEADERS)
686+
671687

672688
STREAMS = {
673689
"tickets": Tickets,

0 commit comments

Comments
 (0)