示例#1
0
    def __call__(self,
                 ticket_id,
                 get_articles=False,
                 get_dynamic_fields=False,
                 get_attachments=False,
                 *args,
                 **kwargs):
        """Get a ticket by id ; beware, TicketID != TicketNumber.

        @param ticket_id : the TicketID of the ticket
        @param get_articles : grab articles linked to the ticket
        @param get_dynamic_fields : include dynamic fields in result
        @param get_attachments : include attachments in result

        @return a `Ticket`, Ticket.articles() will give articles if relevant.
        Ticket.articles()[i].attachments() will return the attachments for
        an article, wheres Ticket.articles()[i].save_attachments(<folderpath>)
        will save the attachments of article[i] to the specified folder.
        """
        params = {'TicketID': str(ticket_id)}
        params.update(kwargs)
        if get_articles:
            params['AllArticles'] = True
        if get_dynamic_fields:
            params['DynamicFields'] = True
        if get_attachments:
            params['Attachments'] = True

        ret = self.req('TicketGet', **params)
        return TicketObject.from_xml(self._unpack_resp_one(ret))
示例#2
0
    def __call__(self, ticket_id, get_articles=False,
                 get_dynamic_fields=False,
                 get_attachments=False, *args, **kwargs):
        """Get a ticket by id ; beware, TicketID != TicketNumber.

        @param ticket_id : the TicketID of the ticket
        @param get_articles : grab articles linked to the ticket
        @param get_dynamic_fields : include dynamic fields in result
        @param get_attachments : include attachments in result

        @return a `Ticket`, Ticket.articles() will give articles if relevant.
        Ticket.articles()[i].attachments() will return the attachments for
        an article, wheres Ticket.articles()[i].save_attachments(<folderpath>)
        will save the attachments of article[i] to the specified folder.
        """
        params = {'TicketID': str(ticket_id)}
        params.update(kwargs)
        if get_articles:
            params['AllArticles'] = True
        if get_dynamic_fields:
            params['DynamicFields'] = True
        if get_attachments:
            params['Attachments'] = True

        ret = self.req('TicketGet', **params)
        return TicketObject.from_xml(self._unpack_resp_one(ret))
示例#3
0
 def test_ticket_from_xml_with_articles(self):
     xml = etree.fromstring(SAMPLE_TICKET_W_ARTICLES)
     t = Ticket.from_xml(xml)
     self.assertEqual(t.TicketID, 32)
     self.assertEqual(t.CustomerUserID, '*****@*****.**')
     articles = t.articles()
     self.assertIsInstance(articles, list)
     self.assertEqual(len(articles), 1)
     self.assertIsInstance(articles[0], Article)
     self.assertEqual(articles[0].AgeTimeUnix, 863982)
示例#4
0
 def test_ticket_from_xml_with_articles(self):
     xml = etree.fromstring(SAMPLE_TICKET_W_ARTICLES)
     t = Ticket.from_xml(xml)
     self.assertEqual(t.TicketID, 32)
     self.assertEqual(t.CustomerUserID, '*****@*****.**')
     articles = t.articles()
     self.assertIsInstance(articles, list)
     self.assertEqual(len(articles), 1)
     self.assertIsInstance(articles[0], Article)
     self.assertEqual(articles[0].AgeTimeUnix, 863982)
示例#5
0
 def test_ticket_from_xml(self):
     xml = etree.fromstring(SAMPLE_TICKET)
     t = Ticket.from_xml(xml)
     self.assertEqual(t.TicketID, 32)
     self.assertEqual(t.CustomerUserID, '*****@*****.**')
示例#6
0
 def test_ticket_from_xml(self):
     xml = etree.fromstring(SAMPLE_TICKET)
     t = Ticket.from_xml(xml)
     self.assertEqual(t.TicketID, 32)
     self.assertEqual(t.CustomerUserID, '*****@*****.**')