Exemplo n.º 1
0
    def list_comments(self, ticket_id, **kwargs):
        url = "tickets/%d/conversations?" % ticket_id
        page = kwargs.get("page", 1)
        per_page = kwargs.get("per_page", 100)

        comments = []

        # Skip pagination by looping over each page and adding comments if 'page' key is not in kwargs.
        # else return the requested page and break the loop
        while True:
            this_page = self._api._get(url + "page=%d&per_page=%d" % (page, per_page), kwargs)
            comments += this_page
            if len(this_page) < per_page or "page" in kwargs:
                break
            page += 1

        return [Comment(**c) for c in comments]
Exemplo n.º 2
0
 def create_reply(self, ticket_id, body, **kwargs):
     url = "tickets/%d/reply" % ticket_id
     data = {"body": body}
     data.update(kwargs)
     return Comment(**self._api._post(url, data=json.dumps(data)))
Exemplo n.º 3
0
 def list_comments(self, ticket_id):
     url = "tickets/%d/conversations" % ticket_id
     comments = []
     for c in self._api._get(url):
         comments.append(Comment(**c))
     return comments
Exemplo n.º 4
0
 def create_note(self, ticket_id, body, **kwargs):
     url = 'tickets/%d/notes' % ticket_id
     data = {'body': body}
     data.update(kwargs)
     return Comment(**self._api._post(url, data=json.dumps(data)))