
    .iY                     t    d dl Z d dlmZ d dlmZ d dlmZ d dlmZ  e j                  e
      Z G d d      Zy)    N)BotType)Company)AppointmentRepository)AppointmentNotificationServicec                       e Zd Zed        Zy)GHLAppointmentServicec           
      >   t         j                  j                  | d         j                         }|st	        d      t        j                  | j                  d      xs d| j                  d      | d   |t        j                  j                  | d   d	d
      }	 t        j                  || j                  d      | j                  d      | j                  d      d       |S # t        $ r,}t        j                  d|j                   |       Y d }~|S d }~ww xY w)N
company_id)ghl_company_idzCompany not foundcustomer_nameUnknowncustomer_phoneappointment_datetimebooking_typezwebhook-no-call)nameappointment_phonescheduled_datecompanybot_typer   twilio_call_sidvehicle_makevehicle_modelvehicle_year)makemodelyear)extrazBFailed to send appointment notifications for appointment id=%s: %s)r   objectsfilterfirst
ValueErrorr   create_appointmentgetr   SERVICE_BOTvaluer   process	Exceptionloggerwarningid)validated_datar   appointmentexcs       [/var/www/html/dp2/backend_v2.1/server/apps/appointments/services/ghl_appointment_service.pybook_ghl_appointmentz*GHLAppointmentService.book_ghl_appointment   s!   //((),7 ) 

%' 	 011+>>"&&7D9!/!3!34D!E,-CD++11*>:0@
 	*22*..~>+//@*..~>   	NNT 
 	s   AC' '	D0!DDN)__name__
__module____qualname__staticmethodr/        r.   r   r      s    ! !r5   r   )loggingapps.calls.constantsr   apps.companies.modelsr   apps.appointments.repositoriesr   apps.appointments.servicesr   	getLoggerr0   r(   r   r4   r5   r.   <module>r<      s2     ( ) @ E 
		8	$$ $r5   