
    J|i
                     z    d dl Z d dlZd dlmZ d dlmZmZmZ  e j                  e      Z	 G d d      Z
ddefdZy)	    N)PhoneNumberFormat)format_datetime
to_pacific	str_to_dtc                   .    e Zd Ze	 	 	 	 	 	 	 	 dd       Zy)AppointmentNotificationContextNc           	          | r| j                   xs d}| j                  }| j                  }| j                  r| j                  j                   nd}| j                  r| j                  j                  nd }| j
                  r| j
                  n|xs d}	 |rt        |      n
t        |      }t        |      }	|	sd\  }
}n|	\  }
}t        |      }|||||
|||r|dS ddS # t        $ r&}t        j                  d|        |}
d}Y d }~Fd }~ww xY w)NUnknown
DealershipzN/A)NNzunable to parse in ctx )customer_namecustomer_numbercompany
bdc_numberdatetimebooking_typedealership_name)nameappointment_phonescheduled_dater   r   r   r   r   r   	Exceptionloggerwarningformat_phone)appointmentr   r   booking_datetimeservicecustomer_phonedt_to_pacificr   
pacific_dt	formatteddate_strtime_streformatted_customer_phones                 X/var/www/html/dp2/backend_v2.1/server/apps/appointments/services/notification_context.pybuildz$AppointmentNotificationContext.build
   sD    ',,9	M(::N*992=2E2Ek))..<G;F;N;N,,77TXJ ++ ((& 	 ! +,/0 
 (
3I%/"(%."( $0#?  +7$#*1w	
 		
 8D	
 		
  	NN4QC89'HH		s   0C 	D'DD)NNNNNNTN)__name__
__module____qualname__staticmethodr'        r&   r   r   	   s,    !9
 9
r-   r   numberc                 ,   | sy 	 t        j                  | |      }t        j                  |      s| S t        j                  |t        j
                        j                  dd      S # t        $ r$}t        j                  d|        | cY d }~S d }~ww xY w)N  zunbale to format phone number )
phonenumbersparseis_valid_numberformat_numberr   NATIONALreplacer   r   r   )r.   regionphoneexcs       r&   r   r   G   s    
""662++E2M))&&
 '#r
	  7u=>s"   ,A& 3A& &	B/BBB)US)loggingr2   r   utils.timezone_utilsr   r   r   	getLoggerr(   r   r   strr   r,   r-   r&   <module>r@      s=      * G G			8	$;
 ;
| r-   