Skip to content

Commit 9dfd314

Browse files
committed
Added Ticket Reference and Answers to custom questions
1 parent d3f5a53 commit 9dfd314

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/pytito/admin/ticket.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ def _end_point(self) -> str:
5656
return super()._end_point +\
5757
f'/{self.__account_slug}/{self.__event_slug}/tickets/{self.__ticket_slug}'
5858

59+
def _populate_json(self) -> None:
60+
self._json_content = self._get_response(endpoint='')['ticket']
61+
if self.__ticket_slug != self._json_content['slug']:
62+
raise ValueError('slug in json content does not match expected value')
63+
if self._json_content['view'] != 'extended':
64+
raise ValueError('expected the extended view of the ticket')
65+
5966
@property
6067
def state(self) -> TicketState:
6168
"""
@@ -69,3 +76,22 @@ def name(self) -> str:
6976
Name of the ticket holder (First Name + Last Name)
7077
"""
7178
return self._json_content['name']
79+
80+
@property
81+
def reference(self) -> str:
82+
"""
83+
Ticket reference (this is shown in guest emails) and therefore with is what ticket holder
84+
will consider to be their: "Ticket Number"
85+
"""
86+
return self._json_content['reference']
87+
88+
@property
89+
def answers(self) -> str:
90+
"""
91+
Answers to ticket specific questions
92+
"""
93+
# The answers are part of the extended data for a ticket, therefore if it is not present
94+
# try getting the extended view
95+
if 'answers' not in self._json_content:
96+
self._populate_json()
97+
return self._json_content['answers']

0 commit comments

Comments
 (0)