Skip to content
Open
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
21 changes: 13 additions & 8 deletions zenpy/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ class IncrementalApi(Api):
IncrementalApi supports the incremental endpoint.
"""

def incremental(self, start_time, include=None, per_page=None):
def incremental(self, start_time, include=None, per_page=None, support_type_scope=None):
"""
Retrieve bulk data from the incremental API.

Expand All @@ -794,7 +794,7 @@ def incremental(self, start_time, include=None, per_page=None):
"""
return self._query_zendesk(self.endpoint.incremental, self.object_type,
start_time=start_time, include=include,
per_page=per_page)
per_page=per_page, support_type_scope=support_type_scope)


class IncrementalCursorApi(IncrementalApi):
Expand All @@ -803,7 +803,8 @@ def incremental(self,
paginate_by_time=False,
cursor=None,
include=None,
per_page=None):
per_page=None,
support_type_scope=None):
"""
Incrementally retrieve Tickets or Users.

Expand Down Expand Up @@ -836,6 +837,7 @@ def incremental(self,
:param include: list of objects to sideload. `Side-loading API Docs
<https://developer.zendesk.com/rest_api/docs/core/side_loading>`__.
:param per_page: number of results per page, up to max 1000
:param support_type_scope: one of "agent","ai_agent","all". Default: "agent"
"""
if (all_are_none(start_time, cursor)
or all_are_not_none(start_time, cursor)):
Expand All @@ -845,21 +847,24 @@ def incremental(self,
if start_time is not None and paginate_by_time is True:
return super(IncrementalCursorApi, self).incremental(start_time=start_time,
include=include,
per_page=per_page)
per_page=per_page,
support_type_scope=support_type_scope)

elif start_time is not None and paginate_by_time is False:
return self._query_zendesk(self.endpoint.incremental.cursor_start,
self.object_type,
start_time=start_time,
include=include,
per_page=per_page)
per_page=per_page,
support_type_scope=support_type_scope)

elif cursor and paginate_by_time is False:
return self._query_zendesk(self.endpoint.incremental.cursor,
self.object_type,
cursor=cursor,
include=include,
per_page=per_page)
per_page=per_page,
support_type_scope=support_type_scope)
else:
raise ValueError(
"Can't set cursor param and paginate_by_time=True")
Expand Down Expand Up @@ -1590,7 +1595,7 @@ def restore(self, tickets):

return self._put(url, payload=None)

def events(self, start_time, include=None, per_page=None):
def events(self, start_time, include=None, per_page=None, support_type_scope=None):
"""
Retrieve TicketEvents

Expand All @@ -1600,7 +1605,7 @@ def events(self, start_time, include=None, per_page=None):
"""
return self._query_zendesk(self.endpoint.events, 'ticket_event',
start_time=start_time, include=include,
per_page=per_page)
per_page=per_page, support_type_scope=support_type_scope)

@extract_id(Ticket)
def audits(self, ticket=None, include=None, **kwargs):
Expand Down
5 changes: 4 additions & 1 deletion zenpy/lib/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def __call__(self, **kwargs):
'limit',
'cursor',
'filter_by',
'support_type_scope'
):
parameters[key] = value
elif key == 'since':
Expand Down Expand Up @@ -209,7 +210,7 @@ class IncrementalEndpoint(BaseEndpoint):
:param include: list of items to sideload
"""

def __call__(self, start_time=None, include=None, per_page=None):
def __call__(self, start_time=None, include=None, per_page=None, support_type_scope=None):
if start_time is None:
raise ZenpyException(
"Incremental Endpoint requires a start_time parameter!")
Expand All @@ -227,6 +228,8 @@ def __call__(self, start_time=None, include=None, per_page=None):
params.update(dict(include=",".join(include)))
else:
params.update(dict(include=include))
if support_type_scope:
params["support_type_scope"] = support_type_scope
return Url(self.endpoint, params=params)


Expand Down