Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable listing section articles from all locales includig sideloads #654

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
15 changes: 11 additions & 4 deletions zenpy/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions zenpy/lib/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down