@@ -218,6 +218,7 @@ class Users(Stream):
218
218
name = "users"
219
219
replication_method = "INCREMENTAL"
220
220
replication_key = "updated_at"
221
+ endpoint = 'https://{}.zendesk.com/api/v2/users'
221
222
222
223
def _add_custom_fields (self , schema ):
223
224
try :
@@ -577,6 +578,7 @@ class TicketForms(Stream):
577
578
name = "ticket_forms"
578
579
replication_method = "INCREMENTAL"
579
580
replication_key = "updated_at"
581
+ endpoint = 'https://{}.zendesk.com/api/v2/ticket_forms'
580
582
581
583
def sync (self , state ):
582
584
bookmark = self .get_bookmark (state )
@@ -628,6 +630,7 @@ def sync(self, state):
628
630
class SLAPolicies (Stream ):
629
631
name = "sla_policies"
630
632
replication_method = "FULL_TABLE"
633
+ endpoint = 'https://{}.zendesk.com/api/v2/slas/policies'
631
634
632
635
def sync (self , state ): # pylint: disable=unused-argument
633
636
for policy in self .client .sla_policies ():
@@ -642,16 +645,18 @@ def check_access(self):
642
645
class TalkPhoneNumbers (Stream ):
643
646
name = 'talk_phone_numbers'
644
647
replication_method = "FULL_TABLE"
648
+ endpoint = 'https://{}.zendesk.com/api/v2/channels/voice/phone_numbers'
645
649
646
650
def sync (self , state ): # pylint: disable=unused-argument
647
651
for phone_number in self .client .talk .phone_numbers ():
648
652
yield (self .stream , phone_number )
649
653
650
654
651
- class TalkCalls (Stream ):
655
+ class TalkCalls (CursorBasedExportStream ):
652
656
name = 'talk_calls'
653
657
replication_method = "INCREMENTAL"
654
658
replication_key = 'updated_at'
659
+ endpoint = 'https://{}.zendesk.com/api/v2/channels/voice/stats/incremental/calls'
655
660
656
661
def sync (self , state ):
657
662
bookmark = self .get_bookmark (state )
@@ -668,6 +673,17 @@ def sync(self, state):
668
673
self .update_bookmark (state , call .updated_at )
669
674
yield (self .stream , call )
670
675
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
+
671
687
672
688
STREAMS = {
673
689
"tickets" : Tickets ,
0 commit comments