code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
if self.api and self.department_id: return self.api._get_department(self.department_id)
def department(self)
| Description: The ID of the department to which the chat is directed
5.552603
5.589606
0.99338
if self.api and self.zendesk_ticket_id: return self.api._get_zendesk_ticket(self.zendesk_ticket_id)
def zendesk_ticket(self)
| Description: The ID of the Zendesk Support ticket created from this chat. Available only if using version 2 of the Zendesk Chat-Support integration
4.060231
4.082221
0.994613
expected_type = self.api._object_mapping.class_for_type(self.api.object_type) if not isinstance(zenpy_objects, collections.Iterable): zenpy_objects = [zenpy_objects] for zenpy_object in zenpy_objects: if type(zenpy_object) is not expected_type: ra...
def check_type(self, zenpy_objects)
Ensure the passed type matches this API's object_type.
2.648311
2.26485
1.169309
s1 = FIRST_CAP_REGEX.sub(r'\1_\2', name) return ALL_CAP_REGEX.sub(r'\1_\2', s1).lower()
def to_snake_case(name)
Given a name in camelCase return in snake_case
2.775206
2.755262
1.007239
if isinstance(start_time, datetime): if is_timezone_aware(start_time): start_time = start_time.astimezone(pytz.utc) else: log.warning( "Non timezone-aware datetime object passed to IncrementalEndpoint. " "The Zendesk API expects UTC time, ...
def to_unix_ts(start_time)
Given a datetime object, returns its value as a unix timestamp
3.927419
3.911575
1.004051
return hasattr(obj, '__iter__') and not isinstance(obj, str) and not isinstance(obj, bytes)
def is_iterable_but_not_string(obj)
Determine whether or not obj is iterable but not a string (eg, a list, set, tuple etc).
2.773256
2.504934
1.107117
if result_key.endswith('ies'): return re.sub('ies$', 'y', result_key) elif result_key.endswith('uses'): return re.sub("uses$", "us", result_key) elif result_key.endswith('addresses'): # Special case for '*addresses' return result_key[:-2] elif result_key.endswith('s'): ...
def as_singular(result_key)
Given a result key, return in the singular form
3.175277
3.025365
1.049552
# Not at all guaranteed to work in all cases... if result_key.endswith('y'): return re.sub("y$", "ies", result_key) elif result_key.endswith('address'): return result_key + 'es' elif result_key.endswith('us'): return re.sub("us$", "uses", result_key) elif not result_key....
def as_plural(result_key)
Given a result key, return in the plural form.
2.939188
2.737564
1.073651
def outer(func): def inner(*args, **kwargs): def id_of(x): return x.id if type(x) in object_types else x new_args = [id_of(arg) for arg in args] new_kwargs = {k: id_of(v) for k, v in kwargs.items()} return func(*new_args, **new_kwargs) ...
def extract_id(*object_types)
Decorator for extracting id from passed parameters for specific types.
2.258603
2.029392
1.112946
if hasattr(obj, 'to_dict'): return obj.to_dict(serialize=serialize) elif isinstance(obj, datetime): return obj.date().isoformat() elif isinstance(obj, date): return obj.isoformat() elif isinstance(obj, ProxyDict): return dict(obj) elif isinstance(obj, ProxyList):...
def json_encode(obj, serialize)
Handle encoding complex types.
2.025481
1.982317
1.021774
log.debug("{}: {} - {}".format(http_method.__name__.upper(), url, kwargs)) if self.ratelimit is not None: # This path indicates we're taking a proactive approach to not hit the rate limit response = self._ratelimit(http_method=http_method, url=url, **kwargs) else...
def _call_api(self, http_method, url, **kwargs)
Execute a call to the Zendesk API. Handles rate limiting, checking the response from Zendesk and deserialization of the Zendesk response. All communication with Zendesk should go through this method. :param http_method: The requests method to call (eg post, put, get). :param url: The ur...
3.793036
3.738922
1.014473
if self.ratelimit_budget is not None: self.ratelimit_budget -= seconds_waited if self.ratelimit_budget < 1: raise RatelimitBudgetExceeded("Rate limit budget exceeded!")
def check_ratelimit_budget(self, seconds_waited)
If we have a ratelimit_budget, ensure it is not exceeded.
3.063992
2.453191
1.248982
def time_since_last_call(): if self.callsafety['lastcalltime'] is not None: return int(time() - self.callsafety['lastcalltime']) else: return None lastlimitremaining = self.callsafety['lastlimitremaining'] if time_since_last_cal...
def _ratelimit(self, http_method, url, **kwargs)
Ensure we do not hit the rate limit.
3.730562
3.663738
1.018239
if self.ratelimit is not None: self.callsafety['lastcalltime'] = time() self.callsafety['lastlimitremaining'] = int(response.headers.get('X-Rate-Limit-Remaining', 0))
def _update_callsafety(self, response)
Update the callsafety data structure
4.518982
4.371659
1.033699
try: pretty_response = response.json() except ValueError: pretty_response = response for handler in self._response_handlers: if handler.applies_to(self, response): log.debug("{} matched: {}".format(handler.__name__, pretty_response)) ...
def _process_response(self, response, object_mapping=None)
Attempt to find a ResponseHandler that knows how to process this response. If no handler can be found, raise an Exception.
4.645497
4.204093
1.104994
if self._dirty_object is None: return if not is_iterable_but_not_string(self._dirty_object): self._dirty_object = [self._dirty_object] log.debug("Cleaning objects: {}".format(self._dirty_object)) for o in self._dirty_object: if isinstance(o, ...
def _clean_dirty_objects(self)
Clear all dirty attributes for the last object or list of objects successfully submitted to Zendesk.
2.56772
2.426075
1.058385
# If it's a dict this object has already been serialized. if not type(zenpy_object) == dict: log.debug("Setting dirty object: {}".format(zenpy_object)) self._dirty_object = zenpy_object return json.loads(json.dumps(zenpy_object, default=json_encode_for_zendesk))
def _serialize(self, zenpy_object)
Serialize a Zenpy object to JSON
5.162438
4.996489
1.033213
_id = endpoint_kwargs.get('id', None) if _id: item = self.cache.get(object_type, _id) if item: return item else: return self._get(url=self._build_url(endpoint(*endpoint_args, **endpoint_kwargs))) elif 'ids' in endpoint...
def _query_zendesk(self, endpoint, object_type, *endpoint_args, **endpoint_kwargs)
Query Zendesk for items. If an id or list of ids are passed, attempt to locate these items in the relevant cache. If they cannot be found, or no ids are passed, execute a call to Zendesk to retrieve the items. :param endpoint: target endpoint. :param object_type: object type we are ex...
3.072701
2.710222
1.133745
if response.status_code > 299 or response.status_code < 200: log.debug("Received response code [%s] - headers: %s" % (response.status_code, str(response.headers))) try: _json = response.json() err_type = _json.get("error", '') if e...
def _check_response(self, response)
Check the response code returned by Zendesk. If it is outside the 200 range, raise an exception of the correct type. :param response: requests Response object.
2.699852
2.652735
1.017762
if not issubclass(type(self), ChatApiBase) and not self.subdomain: raise ZenpyException("subdomain is required when accessing the Zendesk API!") if self.subdomain: endpoint.netloc = '{}.{}'.format(self.subdomain, self.domain) else: endpoint.netloc = ...
def _build_url(self, endpoint)
Build complete URL
5.932238
5.647451
1.050427
if not isinstance(api_objects, collections.Iterable): api_objects = [api_objects] return CRUDRequest(self).put(api_objects, update_many_external=True)
def update_by_external_id(self, api_objects)
Update (PUT) one or more API objects by external_id. :param api_objects:
6.810454
7.360334
0.925291
if not isinstance(api_objects, collections.Iterable): api_objects = [api_objects] return CRUDRequest(self).delete(api_objects, destroy_many_external=True)
def delete_by_external_id(self, api_objects)
Delete (DELETE) one or more API objects by external_id. :param api_objects:
6.873914
8.057651
0.853092
return self._query_zendesk(self.endpoint.tags, 'tag', id=ticket_id)
def tags(self, ticket_id)
Lists the most popular recent tags in decreasing popularity from a specific ticket.
11.575822
12.517543
0.924768
return self._query_zendesk(self.endpoint.incremental, self.object_type, start_time=start_time, include=include)
def incremental(self, start_time, include=None)
Retrieve bulk data from the incremental API. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param start_time: The time of the oldest object you are interested in.
7.087132
8.645245
0.819772
return self._query_zendesk(self.endpoint.incremental, self.object_type, start_time=start_time, **kwargs)
def incremental(self, start_time, **kwargs)
Retrieve bulk data from the chat incremental API. :param fields: list of fields to retrieve. `Chat API Docs <https://developer.zendesk.com/rest_api/docs/chat/incremental_export#usage-notes-resource-expansion>`__. :param start_time: The time of the oldest object you are interested in.
7.533616
9.992722
0.75391
url = self._build_url(self.endpoint.show(user, identity)) return self._get(url)
def show(self, user, identity)
Show the specified identity for the specified user. :param user: user id or User object :param identity: identity id object :return: Identity
5.961467
9.956161
0.598772
return UserIdentityRequest(self).put(self.endpoint.update, user, identity)
def update(self, user, identity)
Update specified identity for the specified user :param user: User object or id :param identity: Identity object to be updated. :return: The updated Identity
18.322918
31.519049
0.581328
return UserIdentityRequest(self).put(self.endpoint.make_primary, user, identity)
def make_primary(self, user, identity)
Set the specified user as primary for the specified user. :param user: User object or id :param identity: Identity object or id :return: list of user's Identities
17.155933
21.283501
0.806067
return UserIdentityRequest(self).put(self.endpoint.request_verification, user, identity)
def request_verification(self, user, identity)
Sends the user a verification email with a link to verify ownership of the email address. :param user: User id or object :param identity: Identity id or object :return: requests Response object
14.819879
22.340294
0.66337
return UserIdentityRequest(self).put(self.endpoint.verify, user, identity)
def verify(self, user, identity)
Verify an identity for a user :param user: User id or object :param identity: Identity id or object :return: the verified Identity
24.515774
31.790947
0.771156
return self._query_zendesk(self.endpoint.groups, 'group', id=user, include=include)
def groups(self, user, include=None)
Retrieve the groups for this user. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param user: User object or id
11.93595
19.250502
0.620033
return self._query_zendesk(self.endpoint.organizations, 'organization', id=user, include=include)
def organizations(self, user, include=None)
Retrieve the organizations for this user. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param user: User object or id
11.45039
19.333147
0.592267
return self._query_zendesk(self.endpoint.requested, 'ticket', id=user, include=include)
def requested(self, user, include=None)
Retrieve the requested tickets for this user. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param user: User object or id
14.110286
20.980034
0.672558
return self._query_zendesk(self.endpoint.cced, 'ticket', id=user, include=include)
def cced(self, user, include=None)
Retrieve the tickets this user is cc'd into. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param user: User object or id
11.854955
17.784374
0.666594
return self._query_zendesk(self.endpoint.assigned, 'ticket', id=user, include=include)
def assigned(self, user, include=None)
Retrieve the assigned tickets for this user. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param user: User object or id
13.918363
19.905087
0.699236
return self._query_zendesk(self.endpoint.group_memberships, 'group_membership', id=user, include=include)
def group_memberships(self, user, include=None)
Retrieve the group memberships for this user. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param user: User object or id
8.634759
12.518665
0.689751
return self._query_zendesk(self.endpoint.related, 'user_related', id=user)
def related(self, user)
Returns the UserRelated information for the requested User :param user: User object or id :return: UserRelated
18.438663
22.139265
0.832849
return self._query_zendesk(self.endpoint.me, 'user', include=include)
def me(self, include=None)
Return the logged in user :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading#abilities>`__.
14.270985
19.044413
0.749353
return self._query_zendesk(self.endpoint.user_fields, 'user_field', id=user)
def user_fields(self, user)
Retrieve the user fields for this user. :param user: User object or id
15.967255
18.646372
0.85632
return self._query_zendesk(self.endpoint.organization_memberships, 'organization_membership', id=user)
def organization_memberships(self, user)
Retrieve the organization memberships for this user. :param user: User object or id
12.371166
16.834324
0.734878
url = self._build_url(self.endpoint.deleted(id=user)) deleted_user = self._delete(url) self.cache.delete(deleted_user) return deleted_user
def permanently_delete(self, user)
Permanently delete user. User should be softly deleted first. Zendesk API `Reference <https://developer.zendesk.com/rest_api/docs/core/users#permanently-delete-user>`__. Note: This endpoint does not support multiple ids or list of `User` objects. :param user: User object or id. :return...
5.630176
7.169709
0.785273
return self._get(self._build_url(self.endpoint.skips(id=user)))
def skips(self, user)
Skips for user. Zendesk API `Reference <https://developer.zendesk.com/rest_api/docs/core/ticket_skips>`__.
11.921407
11.288368
1.056079
url = self._build_url(self.endpoint.set_password(id=user)) return self._post(url, payload=dict(password=password))
def set_password(self, user, password)
Sets the password for the passed user. Zendesk API `Reference <https://developer.zendesk.com/rest_api/docs/support/users#set-a-users-password>`__. :param user: User object or id :param password: new password
5.274696
6.490568
0.812671
return UploadRequest(self).post(fp, token=token, target_name=target_name, content_type=content_type)
def upload(self, fp, token=None, target_name=None, content_type=None)
Upload a file to Zendesk. :param fp: file object, StringIO instance, content, or file path to be uploaded :param token: upload token for uploading multiple files :param target_name: name of the file inside Zendesk :return: :class:`Upload` object containing a token and...
3.116657
4.87216
0.639687
attachment = self(id=attachment_id) if os.path.isdir(destination): destination = os.path.join(destination, attachment.file_name) return self._download_file(attachment.content_url, destination)
def download(self, attachment_id, destination)
Download an attachment from Zendesk. :param attachment_id: id of the attachment to download :param destination: destination path. If a directory, the file will be placed in the directory with the filename from the Attachment object. :return: the path the file was wri...
3.188873
4.060877
0.785267
return self._query_zendesk(self.endpoint.organization_fields, 'organization_field', id=organization)
def organization_fields(self, organization)
Retrieve the organization fields for this organization. :param organization: Organization object or id
15.727479
19.848358
0.792382
return self._query_zendesk(self.endpoint.organization_memberships, 'organization_membership', id=organization)
def organization_memberships(self, organization)
Retrieve tche organization fields for this organization. :param organization: Organization object or id
11.855497
16.933214
0.700133
return self._query_zendesk(self.endpoint.external, 'organization', id=external_id, include=include)
def external(self, external_id, include=None)
Locate an Organization by it's external_id attribute. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param external_id: external id of organization
10.375397
13.37662
0.775637
return self._query_zendesk(self.endpoint.apply, 'result', id=macro)
def apply(self, macro)
Show what a macro would do Zendesk API `Reference <https://developer.zendesk.com/rest_api/docs/core/macros#show-changes-to-ticket>`__. :param macro: Macro object or id.
41.969063
37.604237
1.116073
return self._query_zendesk(self.endpoint.organizations, 'ticket', id=organization, include=include)
def organizations(self, organization, include=None)
Retrieve the tickets for this organization. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param organization: Organization object or id
13.532048
22.946894
0.589712
return self._query_zendesk(self.endpoint.recent, 'ticket', id=None, include=include)
def recent(self, include=None)
Retrieve the most recent tickets
14.025689
11.639753
1.204982
return self._query_zendesk(self.endpoint.comments, 'comment', id=ticket, include_inline_images=repr(include_inline_images).lower())
def comments(self, ticket, include_inline_images=False)
Retrieve the comments for a ticket. :param ticket: Ticket object or id :param include_inline_images: Boolean. If `True`, inline image attachments will be returned in each comments' `attachments` field alongside non-inline attachments
7.313061
10.335538
0.707565
endpoint_kwargs = dict() if isinstance(tickets, collections.Iterable): endpoint_kwargs['destroy_ids'] = [i.id for i in tickets] else: endpoint_kwargs['id'] = tickets.id url = self._build_url(self.endpoint.deleted(**endpoint_kwargs)) deleted_ticket...
def permanently_delete(self, tickets)
Permanently delete ticket. `See Zendesk API docs <https://developer.zendesk.com/rest_api/docs/support/tickets#delete-ticket-permanently>`_ Ticket should be softly deleted first with regular `delete` method. :param tickets: Ticket object or list of tickets objects :return: JobStatus object
4.386769
4.443865
0.987152
return self._query_zendesk(self.endpoint.events, 'ticket_event', start_time=start_time, include=include)
def events(self, start_time, include=None)
Retrieve TicketEvents :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param start_time: time to retrieve events from.
7.155817
10.164335
0.704012
if ticket is not None: return self._query_zendesk(self.endpoint.audits, 'ticket_audit', id=ticket, include=include) else: return self._query_zendesk(self.endpoint.audits.cursor, 'ticket_audit', include=include, **kwargs)
def audits(self, ticket=None, include=None, **kwargs)
Retrieve TicketAudits. If ticket is passed, return the tickets for a specific audit. If ticket_id is None, a TicketAuditGenerator is returned to handle pagination. The way this generator works is a different to the other Zenpy generators as it is cursor based, allowing you to change the directi...
3.880365
4.261478
0.910568
return self._query_zendesk(self.endpoint.metrics, 'ticket_metric', id=ticket)
def metrics(self, ticket)
Retrieve TicketMetric. :param ticket: Ticket object or id
16.333103
20.269415
0.8058
return self._query_zendesk(self.endpoint.metrics.incremental, 'ticket_metric_events', start_time=start_time)
def metrics_incremental(self, start_time)
Retrieve TicketMetric incremental :param start_time: time to retrieve events from.
11.994892
11.094993
1.081109
url = self._build_url(self.endpoint.macro(ticket, macro)) macro_effect = self._get(url) macro_effect._set_dirty() return macro_effect
def show_macro_effect(self, ticket, macro)
Apply macro to ticket. Returns what it *would* do, does not alter the ticket. :param ticket: Ticket or ticket id to target :param macro: Macro or macro id to use
6.541201
8.694062
0.752376
return TicketMergeRequest(self).post(target, source, target_comment=target_comment, source_comment=source_comment)
def merge(self, target, source, target_comment=None, source_comment=None)
Merge the ticket(s) or ticket ID(s) in source into the target ticket. :param target: ticket id or object to merge tickets into :param source: ticket id, object or list of tickets or ids to merge into target :param source_comment: optional comment for the source ticket(s) :param target_c...
5.206113
5.6968
0.913866
return self._get(self._build_url(self.endpoint.skips(id=ticket)))
def skips(self, ticket)
Skips for ticket See Zendesk API `Reference <https://developer.zendesk.com/rest_api/docs/core/ticket_skips>`__.
12.881364
13.172143
0.977925
return self._query_zendesk(self.endpoint.show, 'custom_field_option', ticket_field, custom_field_option)
def show(self, ticket_field, custom_field_option)
Return CustomFieldOption :param ticket_field: TicketFieldOption or id :param custom_field_option: CustomFieldOption or id
6.628979
7.788786
0.851093
url = self._build_url(self.endpoint.show(item, variant)) return self._get(url)
def show(self, item, variant)
Show a variant. :param item: Item object or id :param variant: Variant object or id :return:
5.944291
7.482704
0.794404
return self._query_zendesk(self.endpoint.comments, 'comment', id=request_id)
def comments(self, request_id)
Return comments for request
12.487195
12.71716
0.981917
return self._query_zendesk(self.endpoint.search, 'request', *args, **kwargs)
def search(self, *args, **kwargs)
Search for requests. See the `Zendesk docs <https://developer.zendesk.com/rest_api/docs/core/requests#searching-requests>`__ for more information on the syntax.
12.821023
11.248309
1.139818
return self._get(self._build_url(self.endpoint.memberships(id=group, include=include)))
def memberships(self, group, include=None)
Return the GroupMemberships for this group. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param group: Group object or id
7.861854
13.437015
0.585089
return self._get(self._build_url(self.endpoint.memberships_assignable(id=group, include=include)))
def memberships_assignable(self, group, include=None)
Return memberships that are assignable for this group. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param group: Group object or id
7.150909
11.484933
0.622634
return self._get(self._build_url(self.endpoint.active(include=include)))
def active(self, include=None)
Return all active views.
10.163829
8.564262
1.186772
return self._get(self._build_url(self.endpoint.compact(include=include)))
def compact(self, include=None)
Return compact views - See: Zendesk API `Reference <https://developer.zendesk.com/rest_api/docs/core/views#list-views---compact>`__
11.384197
10.68856
1.065082
return self._get(self._build_url(self.endpoint.execute(id=view, include=include)))
def execute(self, view, include=None)
Execute a view. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param view: View or view id
13.023325
18.496727
0.704088
return self._get(self._build_url(self.endpoint.tickets(id=view, include=include)))
def tickets(self, view, include=None)
Return the tickets in a view. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param view: View or view id
9.131228
16.335655
0.558975
return self._get(self._build_url(self.endpoint.count(id=view, include=include)))
def count(self, view, include=None)
Return a ViewCount for a view. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param view: View or view id
9.822429
15.91813
0.617059
return self._get(self._build_url(self.endpoint(count_many=views, include=include)))
def count_many(self, views, include=None)
Return many ViewCounts. :param include: list of objects to sideload. `Side-loading API Docs <https://developer.zendesk.com/rest_api/docs/core/side_loading>`__. :param views: iterable of View or view ids
9.073748
13.523141
0.670979
return self._get(self._build_url(self.endpoint.export(id=view, include=include)))
def export(self, view, include=None)
Export a view. Returns an Export object. :param include: list of objects to sideload. `Side-loading API Docs :param view: View or view id :return:
11.783735
17.230042
0.683906
return self._get(self._build_url(self.endpoint.search(*args, **kwargs)))
def search(self, *args, **kwargs)
Search views. See Zendesk API `Reference <https://developer.zendesk.com/rest_api/docs/core/views#search-views>`__. :param args: query is the only accepted arg. :param kwargs: search parameters
8.221811
13.468843
0.610432
return self._put(self._build_url(self.endpoint.make_default(user, group_membership)), payload={})
def make_default(self, user, group_membership)
Set the passed GroupMembership as default for the specified user. :param user: User object or id :param group_membership: GroupMembership object or id
8.87861
11.468946
0.774144
return CRUDRequest(self).post(article, create=True, id=section)
def create(self, section, article)
Create (POST) an Article - See: Zendesk API `Reference <https://developer.zendesk.com/rest_api/docs/help_center/articles#create-article>`__. :param section: Section ID or object :param article: Article to create
29.306862
40.484825
0.723897
return self._query_zendesk(self.endpoint.comments, object_type='comment', id=article)
def comments(self, article)
Retrieve comments for an article :param article: Article ID or object
15.627121
23.931845
0.652984
return self._query_zendesk(self.endpoint.inline, 'article_attachment', id=article)
def inline(self, article)
Returns all inline attachments associated with article_id where (Such attachments has ``inline=True`` flag). Inline attachments and its url can be referenced in the HTML body of the article. :param article: Numeric article id or :class:`Article` object. :return: Generator with all associated i...
23.461637
24.306313
0.965249
return self._query_zendesk(self.endpoint.block, 'article_attachment', id=article)
def block(self, article)
Returns all block attachments associated with article_id (Such attachments has ``inline=False``). Block attachments are displayed as separated files attached to Article. :param article: Numeric article id or :class:`Article` object. :return: Generator with all associated block attachments.
26.579536
25.475292
1.043346
return HelpdeskAttachmentRequest(self).post(self.endpoint.create, article=article, attachments=attachment, inline=inline, ...
def create(self, article, attachment, inline=False, file_name=None, content_type=None)
This function creates attachment attached to article. :param article: Numeric article id or :class:`Article` object. :param attachment: File object or os path to file :param inline: If true, the attached file is shown in the dedicated admin UI for inline attachments and its url can ...
4.462094
5.836545
0.764509
return HelpdeskAttachmentRequest(self).post(self.endpoint.create_unassociated, attachments=attachment, inline=inline, file_name=file_name, ...
def create_unassociated(self, attachment, inline=False, file_name=None, content_type=None)
You can use this endpoint for bulk imports. It lets you upload a file without associating it to an article until later. Check Zendesk documentation `important notes <https://developer.zendesk.com/rest_api/docs/help_center/article_attachments#create-unassociated-attachment> :param attach...
4.764802
5.887125
0.80936
return HelpdeskAttachmentRequest(self).delete(self.endpoint.delete, article_attachment)
def delete(self, article_attachment)
This function completely wipes attachment from Zendesk Helpdesk article. :param article_attachment: :class:`ArticleAttachment` object or numeric article attachment id. :return: status_code == 204 on success
24.132545
20.45245
1.179934
return HelpdeskAttachmentRequest(self).post(self.endpoint.bulk_attachments, article=article, attachments=attachments)
def bulk_attachments(self, article, attachments)
This function implements associating attachments to an article after article creation (for unassociated attachments). :param article: Article id or :class:`Article` object :param attachments: :class:`ArticleAttachment` object, or list of :class:`ArticleAttachment` objects, up to 20 supp...
14.49983
20.358191
0.712236
return self._query_zendesk(self.endpoint.recipients_incremental, 'recipients', start_time=start_time)
def recipients_incremental(self, start_time)
Retrieve NPS Recipients incremental :param start_time: time to retrieve events from.
7.973359
10.653016
0.74846
return self._query_zendesk(self.endpoint.responses_incremental, 'responses', start_time=start_time)
def responses_incremental(self, start_time)
Retrieve NPS Responses incremental :param start_time: time to retrieve events from.
8.46961
11.527784
0.734713
def dirty_callback(): self._set_dirty() if isinstance(element, list): element = ProxyList(element, dirty_callback=dirty_callback) elif isinstance(element, dict): element = ProxyDict(element, dirty_callback=dirty_callback) # If it is a Zenpy ...
def _wrap_element(self, element)
We want to know if an item is modified that is stored in this dict. If the element is a list or dict, we wrap it in a ProxyList or ProxyDict, and if it is modified execute a callback that updates this instance. If it is a ZenpyObject, then the callback updates the parent object.
4.95822
3.594973
1.379209
self._response_json = self.get_next_page(page_num=page_num, page_size=page_size) self.update_attrs() self.position = 0 self.values = self.process_page()
def handle_pagination(self, page_num=None, page_size=None)
Handle retrieving and processing the next page of results.
4.931665
4.212169
1.170814
for key, value in self._response_json.items(): if key != 'results' and type(value) not in (list, dict): setattr(self, key, value)
def update_attrs(self)
Add attributes such as count/end_time that can be present
4.532826
4.024601
1.12628
url = self._response_json.get(self.next_page_attr, None) if url is None: raise StopIteration() params, url = self.process_url(page_num, page_size, url) response = self.response_handler.api._get(url, raw_response=True, params=params) return response.json()
def get_next_page(self, page_num, page_size)
Retrieve the next page of results.
4.742524
4.462507
1.062749
params = dict() if page_num is not None: url = re.sub('page=\d+', '', url) params['page'] = page_num if page_size is not None: url = re.sub('per_page=\d+', '', url) params['per_page'] = page_size return params, url
def process_url(self, page_num, page_size, url)
When slicing, remove the per_page and page parameters and pass to requests in the params dict
2.166502
1.826464
1.186173
if self.api and self.author_id: return self.api._get_user(self.author_id)
def author(self)
| Comment: The id of the user who wrote the article (set to the user who made the request on create by default)
5.636757
4.878736
1.155372
if self.api and self.section_id: return self.api._get_section(self.section_id)
def section(self)
| Comment: The id of the section to which this article belongs
5.686084
5.133894
1.107558
if self.api and self.article_id: return self.api._get_article(self.article_id)
def article(self)
| Comment: Id of the associated article, if present
5.201397
4.454455
1.167684
if self.api and self.topic_id: return self.api._get_topic(self.topic_id)
def topic(self)
| Comment: The id of the topic that the post belongs to
5.49231
5.24401
1.047349
if self.api and self.category_id: return self.api._get_category(self.category_id)
def category(self)
| Comment: The id of the category to which this section belongs
5.336277
5.109749
1.044333
if self.api and self.user_segment_id: return self.api._get_user_segment(self.user_segment_id)
def user_segment(self)
| Comment: The id of the user segment to which this section belongs
4.043135
4.113008
0.983012
if self.api and self.user_id: return self.api._get_user(self.user_id)
def user(self)
| Comment: The id of the user who has this subscription
5.142657
4.996274
1.029298
if self.api and self.created_by_id: return self.api._get_user(self.created_by_id)
def created_by(self)
| Comment: The id of the user who created the translation
4.597278
5.031124
0.913768
if self.api and self.updated_by_id: return self.api._get_user(self.updated_by_id)
def updated_by(self)
| Comment: The id of the user who last updated the translation
4.905086
5.109046
0.960079
if self.api and self.organization_ids: return self.api._get_organizations(self.organization_ids)
def organizations(self)
| Comment: The ids of the organizations that have access
6.206599
5.536325
1.121068