Skip to content
Snippets Groups Projects
Commit 08273644 authored by Robert Habermann's avatar Robert Habermann
Browse files

extend Readme and some cleanup

parent 7d68a652
No related branches found
No related tags found
No related merge requests found
......@@ -104,7 +104,6 @@ More Examples
True
>>> client.ticket_get_by_id(1)
<Ticket: 1>
>>> my_ticket = client.result[0]
>>> my_ticket.TicketNumber
......@@ -134,8 +133,51 @@ u'Welcome to OTRS!'
[<DynamicField: ProcessManagementActivityID: None>, <DynamicField: ProcessManagementProcessID: None>]
Searching
---------
Get Tickets
-----------
>>> client.ticket_get_by_id(1, articles=True, attachments=True, dynamic_fields=True)
<Ticket: 1>
>>> client.ticket_get_by_list([1, 3, 4], dynamic_fields=False)
[<Ticket: 1>, <Ticket: 3>, <Ticket: 4>]
Update Tickets
--------------
>>> client.ticket_update(1, Title="New Title")
{u'TicketID': u'1', u'TicketNumber': u'2010080210123456'}
>>> my_article = Article({"Subject": "Subj", "Body": "New Body"})
>>> client.ticket_update(1, article=my_article)
{u'ArticleID': u'3',
u'TicketID': u'1',
u'TicketNumber': u'2010080210123456'}
>>> df = DynamicField("ExternalTicket", "1234")
>>> client.ticket_update(1, dynamic_field_list=[df])
{u'TicketID': u'1', u'TicketNumber': u'2010080210123456'}
Create Tickets
--------------
OTRS requires that new Tickets have several fields filled with valid values and that an
Article is present for the new Ticket.
>>> new_ticket = Ticket.create_basic(Title="This is the Title",
Queue="Raw",
State=u"new",
Priority=u"3 normal",
CustomerUser="root@localhost")
>>> first_article = Article({"Subject": "Subj", "Body": "New Body"})
>>> client.ticket_create(new_ticket, first_article)
{u'ArticleID': u'9', u'TicketID': u'7', u'TicketNumber': u'2016110528000013'}
Search for Tickets
------------------
- get list of Tickets created before a date (e.g. Jan 01, 2011)
......
......@@ -229,7 +229,7 @@ class Attachment(object):
return "<{0}>".format(self.__class__.__name__)
def to_dct(self):
"""represent AttachmentList and related Attachment objects as dict
"""represent Attachment object as dict
Returns:
**dict**: Attachment represented as dict.
......@@ -300,7 +300,7 @@ class Attachment(object):
"""dummy data (for testing)
Returns:
**Attachment**: A Attachment object.
**Attachment**: An Attachment object.
"""
return Attachment.create_basic("YmFyCg==", "text/plain", "dümmy.txt")
......@@ -402,13 +402,20 @@ class DynamicField(object):
class Ticket(object):
"""PyOTRS Ticket class """
"""PyOTRS Ticket class
Args:
tid (int): OTRS Ticket ID as integer
"""
def __init__(self, dct):
for key, value in dct.items():
if isinstance(value, dict):
dct[key] = Ticket(value)
self.__dict__ = dct
self.tid = int(self.__dict__['TicketID'])
self.list_articles = self._parse_articles()
self.list_dynamic_fields = self._parse_dynamic_fields()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment