diff --git a/serviceHelpers/models/ZendeskTicket.py b/serviceHelpers/models/ZendeskTicket.py index c8e276b..0d455e7 100644 --- a/serviceHelpers/models/ZendeskTicket.py +++ b/serviceHelpers/models/ZendeskTicket.py @@ -29,6 +29,7 @@ def __init__(self, host) -> None: self.comments = [] self.logger = logging.getLogger("zendeskHelper.zendeskTicket") self.custom_fields = {} + self.ticket_form_id = 0 pass def from_string(self, str): @@ -73,6 +74,7 @@ def from_dict(self, source: dict): self.group_id = source["group_id"] if "group_id" in source else self.group_id self.status = source["status"] if "status" in source else self.status self.priority = source["priority"] if "priority" in source else self.priority + self.ticket_form_id = source["ticket_form_id"] if "ticket_form_id" in source else self.ticket_form_id for custom_field in source["custom_fields"]: try: if custom_field["value"] is not None: @@ -92,5 +94,6 @@ def __str__(self) -> str: "assignee_id": self.assignee_id, "requester_id": self.requester_id, "group_id": self.group_id, + "ticket_form_id" : self.ticket_form_id } return json.dumps(dict, sort_keys=True) diff --git a/tests/test_zendesk.py b/tests/test_zendesk.py index 1898b52..bc0c6dc 100644 --- a/tests/test_zendesk.py +++ b/tests/test_zendesk.py @@ -209,7 +209,15 @@ def test_custom_fields(): isinstance(ticket.custom_fields[field_id], (bool, str)) assert True +def test_get_form_id_in_ticket(): + zend = zendesk(ZENDESK_HOST, ZENDESK_KEY) + target_id = 1239674 + + tickets = zend.search_for_tickets(f"{target_id}") + ticket = tickets[1239674] + ticket: ZendeskTicket + assert ticket.ticket_form_id is not 0 def test_get_form_details(): "fetches a test form and checks that the returned name matches the expected value"