
    #i                         d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ  G d d	e      Z G d
 dej                        Z G d dej                        Z G d dej                        Zy)    N)models)timezone)AbstractTimeStampModel)Call)BotType)Companyc                      e Zd Z ej                  d      Z ej                         Z ej                  dd      Z	 ej                  ddd      Z
 ej                  d ej                               Z ej                  ddddd	      Z ej                  eej"                  dd
      Z ej                  eej"                  dd
      Z ej                  d      Zd Zy)Appointment   
max_lengthTnullblank)r   r   r   )r   choices   zType of appointment booking)r   r   r   db_index	help_text)	on_deleter   r   c           	          | j                   r| j                   nd}d| j                   d| j                   d| j                  dd| d	S )NUnknownzAppointment z - z on z%Y-%m-%d %H:%Mz ())booking_typeidnamescheduled_date)selfbookings     A/var/www/html/dp2/backend_v2.1/server/apps/appointments/models.py__str__zAppointment.__str__*   sU    '+'8'8$##i477)3tyyk 2%%n5 6y	
    N)__name__
__module____qualname__r   	CharFieldr   DateTimeFieldr   SmallIntegerFieldofftimeappointment_phoner   model_choicesbot_typer   
ForeignKeyr   SET_NULLcallr   companytwilio_call_sidr     r!   r   r
   r
      s    6s+D)V))+N&f&&D=G((( (v''%%%'H $6##/L 6//D
  f//G
 'f&&#6O
r!   r
   c                      e Zd ZdZ ej
                  dej                  d      Z ej                  d      Z
 ej                  dd      Z ej                  dd	      Z ej                         Z ej                  d
      Z ej"                  dd	      Z ej                  d      Z ej(                  dd	      Z ej"                  ej.                  d      Z G d d      Zd Zd Zy)WebhookEventzk
    Stores every incoming webhook exactly as received for audit, debugging,
    replay and analytics.
    TFprimary_keydefaulteditable2   r   d   )r   r   r   r6   )r   )r6   r   c                   h    e Zd ZdgZdZ ej                  ddg       ej                  dg      gZy)WebhookEvent.Metaz-received_atzWebhook Eventsource
event_typefields	processedN)r"   r#   r$   orderingverbose_name_pluralr   Indexindexesr1   r!   r   Metar<   L   s:    "#-FLL< 89FLL.
r!   rF   c                 z    d| _         d| _        t        j                         | _        | j                  g d       y )NT)rA   successprocessed_atupdate_fields)rA   rH   r   nowrI   saver   s    r   mark_successzWebhookEvent.mark_successT   s-    $LLN		 H	Ir!   c                     d| _         d| _        t        |      | _        t	        j
                         | _        | j                  g d       y )NTF)rA   rH   error_messagerI   rJ   )rA   rH   strrQ   r   rL   rI   rM   )r   errors     r   mark_failedzWebhookEvent.mark_failedZ   s9     Z$LLN		 Y	Zr!   N)r"   r#   r$   __doc__r   	UUIDFielduuiduuid4r   r%   r=   r>   	JSONFieldheadersraw_payloadBooleanFieldrA   r&   rI   rH   	TextFieldrQ   r   rL   received_atrF   rO   rT   r1   r!   r   r3   r3   3   s     
		


B V,F!!!S4@JfD5G"&""$K###E2I'6''T>L!f!!t,G$F$$$d;M&&&&x||dKK
 
J[r!   r3   c                   t    e Zd Z ej                  dd      Z ej                  d      Zd Z G d d      Z	y	)
FeatureFlagr9   T)r   uniqueFr:   c                 D    | j                    d| j                  rd S d S )Nz: ONOFF)keyenabledrN   s    r   r    zFeatureFlag.__str__f   s)    ((2dlld>??>??r!   c                       e Zd ZdZy)FeatureFlag.MetazFeature FlagsN)r"   r#   r$   rC   r1   r!   r   rF   rh   i   s    -r!   rF   N)
r"   r#   r$   r   r%   re   r\   rf   r    rF   r1   r!   r   r`   r`   b   s8    
&

c$
7C!f!!%0G@. .r!   r`   c                      e Zd Z ej                  dej                  d      Z ej                  d      Z	 ej                         Z ej                  dd      Z ej                  dd      Z ej                  dd      Z ej                  dd      Z ej                  dd      Z ej                  dd      Z ej                  dd      Z ej                  dd	      Z ej                  dd      Z ej,                  d
      Z ej,                  dd      Z ej,                  dd      Z G d d      Zy)OutboundMessageTFr4   
   r   r      pending)r   r6   )auto_now_addc                   ^    e Zd Z ej                  ddg       ej                  dg      gZy)OutboundMessage.Metachannelstatusr?   provider_message_idN)r"   r#   r$   r   rD   rE   r1   r!   r   rF   rp      s.    FLLH 56FLL!6 78
r!   rF   N)r"   r#   r$   r   rV   rW   rX   r   r%   rq   r]   tosubjecttemplate_namerY   contextmessage_payloadrs   r0   retell_call_idrr   rQ   r&   
created_atsent_atdelivered_atrF   r1   r!   r   rj   rj   m   s9    
		dDJJ	OBf"-G				BfD5G$F$$$d;MfD5G&f&&D=O*&**DA&f&&D=O%V%%4t<NVY?F$F$$$d;M%%%48J"f""D9G'6''T>L
 
r!   rj   )rW   	django.dbr   django.utilsr   coresite.mixinr   apps.calls.modelsr   apps.calls.constantsr   apps.companies.modelsr   r
   Modelr3   r`   rj   r1   r!   r   <module>r      s[      ! 1 " ( )%
( %
P,[6<< ,[^.&,, .)
fll )
r!   