@@ -33,10 +33,10 @@ class Event(AdminAPIBase):
3333 One of the events available through the Tito IO AdminAPI
3434 """
3535
36- def __init__ (self , account_slug :str , event_slug :str ,
36+ def __init__ (self , * , account_slug :str , event_slug :str ,
3737 json_content :Optional [dict [str , Any ]]= None ,
3838 api_key : Optional [str ] = None ,
39- allow_automatic_json_retrieval = False ) -> None :
39+ allow_automatic_json_retrieval : bool = False ) -> None :
4040 super ().__init__ (json_content = json_content , api_key = api_key ,
4141 allow_automatic_json_retrieval = allow_automatic_json_retrieval )
4242 self .__account_slug = account_slug
@@ -201,15 +201,24 @@ def test_mode(self) -> bool:
201201 return self ._json_content ['test_mode' ]
202202
203203 def duplicate_event (self , title :str , slug :Optional [str ]= None ) -> "Event" :
204+ """
205+ Duplicate the event and then update the title and optionally the new slug for the
206+ created event
207+ :param title: New event title
208+ :param slug: New event slug, a value of None will leave the automatically created slug in
209+ place
210+ :return: The newly created event
211+ """
204212 self ._post_response ('duplication' , value = {})
205213 for _ in range (120 ):
206214 time .sleep (1 )
207215 duplication_status = self ._get_duplication_status ()
208216 status = duplication_status ['status' ]
209- if duplication_status ['status' ] == 'processing' :
217+ if status == 'processing' :
218+ # pylint:disable-next=bad-builtin
210219 print ('Duplication in progress' )
211220 continue
212- if duplication_status [ ' status' ] == 'complete' :
221+ if status == 'complete' :
213222 new_slug = duplication_status ['slug' ]
214223 new_title = duplication_status ['title' ]
215224 new_event = Event (account_slug = self .__account_slug ,
@@ -221,9 +230,14 @@ def duplicate_event(self, title:str, slug:Optional[str]=None) -> "Event":
221230 raise ValueError (f'New event has different title to reported value:{ new_title } ' )
222231 new_event .title = title
223232 if slug is not None :
233+ # The update slug method is a powerful option that is not normally exposed
234+ # to the users so is private
235+ # pylint:disable-next=protected-access
224236 new_event ._update_slug (slug )
225237 return new_event
226238
239+ raise ValueError ('Unhandled {status=}' )
240+
227241 raise RuntimeError ('Timeout During Event Duplication' )
228242
229243 def _get_duplication_status (self ) -> dict [str , Any ]:
@@ -232,9 +246,8 @@ def _get_duplication_status(self) -> dict[str, Any]:
232246 raise RuntimeError ('Duplication response does not have a value of _type=_duplication' )
233247 return duplication_status
234248
235- def _delete_event (self ):
249+ def _delete_event (self ) -> None :
236250 """
237251 Delete the event
238252 """
239253 self ._delete_response ()
240-
0 commit comments