From e1cb4a5a0bdb2bf29ec3624fd4337bc6c1b8d03f Mon Sep 17 00:00:00 2001 From: Robert Habermann <mail@rhab.de> Date: Thu, 14 Apr 2016 22:34:29 +0200 Subject: [PATCH] fix docs --- pyotrs/client.py | 97 ++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 53 deletions(-) diff --git a/pyotrs/client.py b/pyotrs/client.py index 74d7de0..9920ab7 100644 --- a/pyotrs/client.py +++ b/pyotrs/client.py @@ -8,6 +8,8 @@ Date: 2015-07-20 https://otrs.github.io/doc/api/otrs/5.0/Perl/index.html + +``` Kernel::GenericInterface::Operation GenericInterface Operation interface Kernel::GenericInterface::Operation @@ -20,12 +22,7 @@ Kernel::GenericInterface::Operation ::Ticket::TicketGet GenericInterface Ticket Get Operation backend ::Ticket::TicketSearch GenericInterface Ticket Search Operation backend ::Ticket::TicketUpdate GenericInterface Ticket TicketUpdate Operation backend - -Session implemented in Class *Client(object)* -TicketCreate implemented in Class *TicketCreate(Client)* -TicketGet implemented in Class *TicketGet(Client)* -TicketSearch implemented in Class *TicketSearch(Client)* -TicketUpdate implemented in Class *TicketUpdate(Client)* +``` """ @@ -172,7 +169,7 @@ class Client(object): """ check whether Session ID (self.session_id) is currently valid Returns: - True if valid; otherwise False + bool: True if valid, False otherwise. Raises: SessionError is self.session_id is not set @@ -322,7 +319,7 @@ class Client(object): all_articles (bool): will request OTRS to include all Articles (default: False) Returns: - Ticket as dict + dict: Ticket """ @@ -357,7 +354,7 @@ class Client(object): ResponseJSONParseError Returns: - True if get was successful; otherwise False + bool: True if successful, False otherwise. """ @@ -456,7 +453,7 @@ class Client(object): **kwargs Returns: - List of tickets that were found + list: tickets that were found Notes: If value of kwargs is a datetime object then this object will be @@ -493,7 +490,7 @@ class Client(object): pattern (str) Returns: - List of tickets that were found + list: tickets that were found """ @@ -519,7 +516,7 @@ class Client(object): ResponseJSONParseError Returns: - True if search was successful; otherwise False + bool: True if search successful, False otherwise. """ @@ -583,9 +580,7 @@ class Client(object): # public methods # * ticket_update_add_article # * ticket_update_set_dynamic_field_value - # * ticket_update_set_state - # * ticket_update_set_state_pending - # * ticket_update_set_title + # * ticket_update_set_pending def ticket_update_add_article(self, ticket_id, article_subject, article_body): """ ticket_update_by_ticket_id_set_scout_id @@ -596,7 +591,7 @@ class Client(object): article_body (str): Returns: - True if update was successful; otherwise False + bool: True if update successful, False otherwise. """ url = "{0.baseurl}/otrs/nph-genericinterface.pl/Webservice/" \ @@ -622,17 +617,17 @@ class Client(object): logger.error("Exception: {0}".format(err)) return False - def ticket_update_set_dynamic_field_value(self, - ticket_id, - **kwargs): - """ ticket_update_set_dynamic_field_value + def ticket_update_set_dynamic_fields(self, + ticket_id, + **kwargs): + """ ticket_update_set_dynamic_fields Args: ticket_id (int): **kwargs Returns: - True if update was successful; otherwise False + bool: True if update successful, False otherwise. """ @@ -660,36 +655,11 @@ class Client(object): logger.error("Exception: {0}".format(err)) return False - @staticmethod - def datetime_to_pending_time_str(datetime_obj=None): - """ datetime_to_pending_time_str - - Args: - datetime_obj: - - Returns: - str representing the REST pending time string format - - Examples: - >>> sorted(Client.datetime_to_pending_time_str(datetime.datetime(1970, 1, 1, 0, 0)).items()) - [('Day', 1), ('Hour', 0), ('Minute', 0), ('Month', 1), ('Year', 1970)] - - """ - pending_time_str = { - "Year": datetime_obj.year, - "Month": datetime_obj.month, - "Day": datetime_obj.day, - "Hour": datetime_obj.hour, - "Minute": datetime_obj.minute - } - - return pending_time_str - - def ticket_update_set_state_pending(self, - ticket_id, - new_state="pending reminder", - pending_days=1, - pending_hours=0): + def ticket_update_set_pending(self, + ticket_id, + new_state="pending reminder", + pending_days=1, + pending_hours=0): """ ticket_update_set_state_pending Args: @@ -699,7 +669,7 @@ class Client(object): pending_hours (int): defaults to 0 Returns: - True if update was successful; otherwise False + bool: True if update successful, False otherwise. """ url = "{0.baseurl}/otrs/nph-genericinterface.pl/Webservice/" \ @@ -724,6 +694,27 @@ class Client(object): logger.error("Exception: {0}".format(err)) return False + @staticmethod + def datetime_to_pending_time_str(datetime_obj=None): + """ datetime_to_pending_time_str + + Args: + datetime_obj: + + Returns: + str: representing the pending time string format for OTRS REST interface + + """ + pending_time_str = { + "Year": datetime_obj.year, + "Month": datetime_obj.month, + "Day": datetime_obj.day, + "Hour": datetime_obj.hour, + "Minute": datetime_obj.minute + } + + return pending_time_str + def _update_by_ticket_id(self, url, payload): """ update_by_ticket_id @@ -736,7 +727,7 @@ class Client(object): OTRSAPIError Returns: - True if update was successful; otherwise False + bool: True if update successful, False otherwise. """ -- GitLab