From bd9ad421447526ced8e8c3ab26e4c78c91ead43b Mon Sep 17 00:00:00 2001 From: ahmedsabriz <80135041+ahmedsabriz@users.noreply.github.com> Date: Sun, 8 Sep 2024 12:31:33 +0200 Subject: [PATCH] enable listing section articles from all locales includig sideloads --- zenpy/lib/api.py | 15 +++++++++++---- zenpy/lib/endpoint.py | 5 +++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/zenpy/lib/api.py b/zenpy/lib/api.py index 0f29b3a..4e7efb6 100644 --- a/zenpy/lib/api.py +++ b/zenpy/lib/api.py @@ -2432,10 +2432,17 @@ def update_access_policy(self, help_centre_object, access_policy): class SectionApi(HelpCentreApiBase, CRUDApi, TranslationApi, SubscriptionApi, AccessPolicyApi): @extract_id(Section) - def articles(self, section, locale='en-us'): - return self._query_zendesk(self.endpoint.articles, - 'article', - id=section, locale=locale) + def articles(self, section, locale="en-us", include=None): + # Set locale to None to search all locales. Not available for anonymous users + if not locale: + return self._query_zendesk(self.endpoint.articles, + "article", + id=section, include=include) + else: + return self._query_zendesk(self.endpoint.articles, + "article", + id=section, locale=locale, + include=include) def create(self, section): return CRUDRequest(self).post(section, diff --git a/zenpy/lib/endpoint.py b/zenpy/lib/endpoint.py index f3ea0be..6a0089e 100644 --- a/zenpy/lib/endpoint.py +++ b/zenpy/lib/endpoint.py @@ -172,6 +172,11 @@ def __call__(self, id, **kwargs): parameters['page[size]'] = 100 elif value is not False: parameters['page[size]'] = value + elif key == "include": + if is_iterable_but_not_string(value): + parameters[key] = ",".join(value) + elif value: + parameters[key] = value else: parameters[key] = value return Url(self.endpoint % dict(id=id), params=parameters)