
    Owin
                         d dl mZ d dlmZ d dlmZ d dlmZ  G d dej                        Z	 G d dej                        Z G d	 d
ej                        Z G d dej                        Zy)    )serializers)Appointment)parse_datetime)timezonec                       e Zd Z ej                         Z ej                         Z ej                         Z ej                         Zd Z	d Z
d Zd Z G d d      Zy)AppointmentSerializerc                 t    |j                   r,|j                   j                  r|j                   j                  S y N)callfrom_numberselfobjs     F/var/www/html/dp2/backend_v2.1/server/apps/appointments/serializers.pyget_customer_numberz)AppointmentSerializer.get_customer_number   s(    88,,88'''    c                 t    |j                   r,|j                   j                  r|j                   j                  S y r
   )r   idr   s     r   get_call_idz!AppointmentSerializer.get_call_id   s$    8888;;r   c                 t    |j                   r,|j                   j                  r|j                   j                  S y r
   )r   call_idr   s     r   get_partner_call_idz)AppointmentSerializer.get_partner_call_id   s(    88((88###r   c                 t    |j                   r,|j                   j                  r|j                   j                  S y r
   )r   
transcriptr   s     r   get_transcriptz$AppointmentSerializer.get_transcript   s(    88++88&&&r   c                        e Zd ZeZg dZg dZy)AppointmentSerializer.Meta)r   namer   scheduled_dateofftimetwilio_call_sidpartner_call_idcustomer_number
created_atr   bot_type)r   r$   
updated_atr#   r"   r   r   N)__name__
__module____qualname__r   modelfieldsread_only_fields r   r   Metar   !   s    
 }r   r.   N)r'   r(   r)   r   SerializerMethodFieldr"   r#   r   r   r   r   r   r   r.   r-   r   r   r   r      sb    7k779O7k779O2224J/k//1G



} }r   r   c                       e Zd ZdZ ej
                   ej                  d      d      Z ej
                  d      Zy)BookAppointmentInputSerializerz
    Permissive input serializer for webhook payloads. It validates top-level
    'args' and 'call' as dicts but does not enforce strict inner schema so
    small webhook changes won't break validation.
    T)allow_blankF)childrequired)r4   N)	r'   r(   r)   __doc__r   	DictField	CharFieldargsr   r-   r   r   r1   r1   2   sB    
 !;  #k##5D !;  %0Dr   r1   c                   .    e Zd Z ej                         Zy)WebhookSuccessSerializerN)r'   r(   r)   r   r7   messager-   r   r   r:   r:   >   s    #k##%Gr   r:   c                       e Zd Z ej                         Z ej                  dd      Z ej                  dd      Z ej                         Z ej                         Z
d Zy)GHLAppointmentInputSerializerFT)r4   r2   c                     t        |      }|st        j                  d      t        j                  |      r$t        j
                  |t        j                        }|S )NzInvalid datetime format)r   r   ValidationErrorr   is_naive
make_awareutc)r   valuedts      r   validate_appointment_datetimez;GHLAppointmentInputSerializer.validate_appointment_datetimeH   sJ    E"--.GHHR $$R6B	r   N)r'   r(   r)   r   r7   
company_idcustomer_namecustomer_phoneappointment_datetimeIntegerFieldbooking_typerE   r-   r   r   r=   r=   A   s`    &&&(J)K))5dKM*[**EtLN0;002+;++-Lr   r=   N)rest_frameworkr   apps.appointments.modelsr   django.utils.dateparser   django.utilsr   ModelSerializerr   
Serializerr1   r:   r=   r-   r   r   <module>rR      s\    & 0 1 !)}K77 )}V
1[%;%; 
1&{55 &K$:$: r   