diff --git a/serviceHelpers/models/ZendeskTicket.py b/serviceHelpers/models/ZendeskTicket.py index e128da4..56a0958 100644 --- a/serviceHelpers/models/ZendeskTicket.py +++ b/serviceHelpers/models/ZendeskTicket.py @@ -2,6 +2,8 @@ import json from datetime import datetime +from serviceHelpers.models.ZendeskUser import ZendeskUser + # 2021-11-25T12:00:15Z _ZD_FORMAT = r"%Y-%m-%dT%H:%M:%SZ" @@ -22,8 +24,10 @@ def __init__(self, host) -> None: self.assignee_id = None self.requester_id = None self.requester_name = "" + self.requester = None self.group_id = 0 - self.lo = logging.getLogger("zendeskHelper.zendeskTicket") + self.logger = logging.getLogger("zendeskHelper.zendeskTicket") + self.custom_fields = {} pass def from_string(self, str): @@ -31,7 +35,7 @@ def from_string(self, str): try: self.from_dict(json.loads(str)) except Exception as e: - self.lo.error("Couldn't parse a ticket string into a dict") + self.logger.error("Couldn't parse a ticket string into a dict") return self def from_dict(self, source: dict): @@ -54,7 +58,7 @@ def from_dict(self, source: dict): else self.updated_ts ) except ValueError as e: - self.lo.error( + self.logger.error( "Date found but not parsed properly : %s", source["updated_at"] ) self.summary = source["subject"] if "subject" in source else self.summary @@ -68,7 +72,12 @@ 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 - + for custom_field in source["custom_fields"]: + try: + if custom_field["value"] is not None: + self.custom_fields[custom_field["id"]] = custom_field["value"] + except KeyError as err: + self.logger.warning("Couldn't properly get a custom field - %s", err) return self def __str__(self) -> str: diff --git a/setup.py b/setup.py index aef8620..8ace394 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name="hex-helpers", - version="2.3.0", + version="2.4.0", description="A series of light helpers for `freshdesk`,`gmail`,`habitica`,`hue lights`,`jira`,`slack`,`trello`", long_description=README, long_description_content_type="text/markdown",