@@ -172,30 +172,9 @@ def create_registration(self, registration_in: RegistrationIn) -> Union[JSONResp
172172
173173 # Capture registration to KonfHub
174174 if event .konfhubId :
175- phone_number_with_no_zero = registration_in .contactNumber .lstrip ('0' )
176- konfhub_registration_details = RegistrationDetail (
177- name = f'{ registration_in .firstName } { registration_in .lastName } ' ,
178- email_id = registration_in .email ,
179- quantity = 1 ,
180- designation = registration_in .title ,
181- organisation = registration_in .organization ,
182- t_shirt_size = registration_in .shirtSize ,
183- phone_number = phone_number_with_no_zero ,
184- dial_code = CommonConstants .PH_DIAL_CODE ,
185- country_code = CommonConstants .PH_COUNTRY_CODE ,
186- )
187- konfhub_capture_registration_in = KonfHubCaptureRegistrationIn (
188- event_id = event .konfhubId ,
189- registration_tz = CommonConstants .PH_TIMEZONE ,
190- registration_details = {
191- registration_in .ticketTypeId : [konfhub_registration_details ],
192- },
193- )
194- status , _ , message = self .__konfhub_gateway .capture_registration (
195- konfhub_capture_registration_in , event .konfhubApiKey
196- )
197- if status != HTTPStatus .OK :
198- return JSONResponse (status_code = status , content = {'message' : message })
175+ konfhub_response = self .register_konfhub (registration_in = registration_in , event_id = event_id , event = event )
176+ if konfhub_response != HTTPStatus .OK :
177+ return konfhub_response
199178
200179 registration_data = self .__convert_data_entry_to_dict (registration )
201180
@@ -252,36 +231,9 @@ def create_registration_approval_flow(
252231 return JSONResponse (status_code = status , content = {'message' : message })
253232
254233 if event .konfhubId :
255- ticket_type_id = registration_in .ticketTypeId
256- if not ticket_type_id :
257- _ , ticket_types_entries , _ = self .__ticket_type_repository .query_ticket_types (event_id = event_id )
258- ticket_types_list = [ticket_type .konfhubId for ticket_type in ticket_types_entries or []]
259- ticket_type_id = ticket_types_list [0 ]
260-
261- phone_number_with_no_zero = registration_in .contactNumber .lstrip ('0' )
262- konfhub_registration_details = RegistrationDetail (
263- name = f'{ registration_in .firstName } { registration_in .lastName } ' ,
264- email_id = registration_in .email ,
265- quantity = 1 ,
266- designation = registration_in .title ,
267- organisation = registration_in .organization ,
268- t_shirt_size = registration_in .shirtSize ,
269- phone_number = phone_number_with_no_zero ,
270- dial_code = CommonConstants .PH_DIAL_CODE ,
271- country_code = CommonConstants .PH_COUNTRY_CODE ,
272- )
273- konfhub_capture_registration_in = KonfHubCaptureRegistrationIn (
274- event_id = event .konfhubId ,
275- registration_tz = CommonConstants .PH_TIMEZONE ,
276- registration_details = {
277- ticket_type_id : [konfhub_registration_details ],
278- },
279- )
280- status , _ , message = self .__konfhub_gateway .capture_registration (
281- konfhub_capture_registration_in , event .konfhubApiKey
282- )
283- if status != HTTPStatus .OK :
284- return JSONResponse (status_code = status , content = {'message' : message })
234+ konfhub_response = self .register_konfhub (registration_in = registration_in , event_id = event_id , event = event )
235+ if konfhub_response != HTTPStatus .OK :
236+ return konfhub_response
285237
286238 registration_data = self .__convert_data_entry_to_dict (registration )
287239
@@ -510,6 +462,40 @@ def collect_pre_signed_url(self, registration: RegistrationOut):
510462
511463 return registration
512464
465+ def register_konfhub (self , registration_in : RegistrationIn , event_id : str , event : Event ):
466+ ticket_type_id = registration_in .ticketTypeId
467+ if not ticket_type_id :
468+ _ , ticket_types_entries , _ = self .__ticket_type_repository .query_ticket_types (event_id = event_id )
469+ ticket_types_list = [ticket_type .konfhubId for ticket_type in ticket_types_entries or []]
470+ ticket_type_id = ticket_types_list [0 ]
471+
472+ phone_number_with_no_zero = registration_in .contactNumber .lstrip ('0' )
473+ konfhub_registration_details = RegistrationDetail (
474+ name = f'{ registration_in .firstName } { registration_in .lastName } ' ,
475+ email_id = registration_in .email ,
476+ quantity = 1 ,
477+ designation = registration_in .title ,
478+ organisation = registration_in .organization ,
479+ t_shirt_size = registration_in .shirtSize ,
480+ phone_number = phone_number_with_no_zero ,
481+ dial_code = CommonConstants .PH_DIAL_CODE ,
482+ country_code = CommonConstants .PH_COUNTRY_CODE ,
483+ )
484+ konfhub_capture_registration_in = KonfHubCaptureRegistrationIn (
485+ event_id = event .konfhubId ,
486+ registration_tz = CommonConstants .PH_TIMEZONE ,
487+ registration_details = {
488+ ticket_type_id : [konfhub_registration_details ],
489+ },
490+ )
491+ status , _ , message = self .__konfhub_gateway .capture_registration (
492+ konfhub_capture_registration_in , event .konfhubApiKey
493+ )
494+ if status != HTTPStatus .OK :
495+ return JSONResponse (status_code = status , content = {'message' : message })
496+
497+ return status
498+
513499 @staticmethod
514500 def __convert_data_entry_to_dict (data_entry ):
515501 """Converts a data entry to a dictionary.
0 commit comments