Skip to content

Commit

Permalink
Properly quote query string for freshdesk API (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
FellipeMendonca and P21FellipeMendonca authored May 21, 2020
1 parent d483fff commit 934b420
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions freshdesk/v2/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,17 @@ def filter_tickets(self, query, **kwargs):
query = "(ticket_field:integer OR ticket_field:'string') AND ticket_field:boolean"
"""
if(len(query) > 512):
raise AttributeError('Query string can have up to 512 characters')

url = 'search/tickets?'
page = 1 if not 'page' in kwargs else kwargs['page']
per_page = 30

tickets = []
while True:
this_page = self._api._get(url + 'page=%d&query=%s'
% (page, repr(query)), kwargs)
this_page = self._api._get(url + 'page={}&query="{}"'.format(page, query),
kwargs)
this_page = this_page['results']
tickets += this_page
if len(this_page) < per_page or page == 10 or 'page' in kwargs:
Expand Down

0 comments on commit 934b420

Please sign in to comment.