
    $yh%                         d dl mZmZmZmZmZmZmZmZ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      Z G d
 de      Z G d de      Z G d de      Z G d de      Z G d de      Zy)    )	ColumnIntegerStringDateTimeText
ForeignKeyEnumBooleanNumeric)func)Base)
encryption)datetimec                   2   e Zd ZdZ eedd      Z eed      Z e ed      d      Z	 e ed      d      Z
 eed      Z e ed      d      Z ee ej                               Z ee ej                          ej                         	      Zy
)Company	companiesTprimary_keyindexFnullable      defaultr   onupdateN)__name__
__module____qualname____tablename__r   r   iduser_idr   company_namecompany_reg_numbertypestatusr   r   now
created_at
updated_at     %/var/www/html/fluten_python/models.pyr   r      s    M	T	6BWu-G&+6Lse<'E*DF3K%0F($((*5J($((*xtxxzJJr,   r   c                   V   e Zd ZdZ eedd      Z eed      Z e ed      d      Z	 e ed      d      Z
 e edd	d
d            Z eed      Z e edd      d      Z ee ej$                               Z ee ej$                          ej$                               Zy)BotbotsTr   Fr   r      IncomingOutgoing
SchedulingOthersactiveinactiver   r   N)r   r   r    r!   r   r   r"   
company_idr   bot_namegenderr	   purposer   bot_structurer'   r   r   r(   r)   r*   r+   r,   r-   r/   r/      s    M	T	6B%0JfSkE2HF1I.FT*j,IJG4%0MD:.AF($((*5J($((*xtxxzJJr,   r/   c                       e Zd ZdZ eedd      Z eedd      Z eed      Z	 ee
 ej                               Z ee
 ej                          ej                               Zy	)
OperationalSettingsoperational_settingsTr   Funiquer   r   r   r   N)r   r   r    r!   r   r   r"   r8   r   settingr   r   r(   r)   r*   r+   r,   r-   r>   r>       sa    *M	T	6Bu=JTE*G($((*5J($((*xtxxzJJr,   r>   c                       e Zd ZdZ eedd      Z ee      Z ee      Z e e	dd            Z
 eed      Z ee ej                               Z ee ej                          ej                               Zy)	CompanyPackagePaymentcompany_package_paymentTr   
      r   r   N)r   r   r    r!   r   r   r"   r8   packager   current_balancemin_balancer   r   r(   r)   r*   r+   r,   r-   rD   rD   )   su    -M	T	6BJWoGWR^,O"-K($((*5J($((*xtxxzJJr,   rD   c                   ^   e Zd ZdZ eedd      Z e ed      d      Z e ed      d      Z	 eed      Z
 eed      Z e ed      d      Z eed      Z eed      Z ee ej"                         d      Z ee ej"                          ej"                         d	      Zy
)PackagepackagesT)r   autoincrementr   Fr      )server_defaultr   )rP   r   r   N)r   r   r    r!   r   r   r"   r   package_name	pack_code
is_defaultr0   r;   price_monthlyprice_yearlyr   r   r(   r)   r*   r+   r,   r-   rL   rL   4   s    M	T	>B&+6LvbzD1I$/J'E*DVC[51G7U3M'E2LeLJhdhhj[`aJr,   rL   c                   $   e Zd ZdZ eedd      Z ee ed            Z e e	d      d      Z
 e e	d            Z e e	d	      d
      Z ee ej                               Z ee ej                          ej                               Zy)PhoneNumberphone_numbersTr   companies.id   Fr   r   2   r6   r   r   N)r   r   r    r!   r   r   r"   r   r8   r   phone_numbervapi_phone_idr'   r   r   r(   r)   r*   r+   r,   r-   rW   rW   B   s    #M	T	6BN!;<J&*u5L6#;'MF2J1F($((*5J($((*xtxxzJJr,   rW   c                       e Zd ZdZ eedd      Z e ed      dd      Z ee e	d            Z
 ee e	d            Z e ed	      d
      Z e ed            Z e ed            Z e ed      d
      Z eed      Z eed
      Z eed
      Z fdZed        Zed        Zed        Zed        Z xZS )CompanyPhonecompany_phoneTr   $   Fr@   rY   zbots.idrZ   r   r   r1   r   c                    |j                  dt        j                               |d<   |j                  dt        j                               |d<   d|vrddlm} |j
                  |d<   d|v r0t        |d   t              r|d   j                         dk(  rdnd|d<   d	|v rAd
|v r=|j                  d	       d|j                  d
       }t        j                  |      |d<   t        | 4  di | y )Nr)   r*   	serverUrlr   )settingsr'   r6   r1   
twilio_sidtwilio_auth_token,provider_keysr+   )getr   utcnowcommon.configrd   
SERVER_URL
isinstancestrlowerpopr   encryptsuper__init__)selfkwargsrd   rh   	__class__s       r-   rs   zCompanyPhone.__init__\   s    %zz,8IJ|%zz,8IJ| f$."*"5"5F; v*VH-=s"C$*8$4$:$:$<$HqaF8 6!&9V&C%zz,78&**EX:Y9Z[M&0&8&8&GF?#"6"r,   c                     | j                   r9t        j                  | j                         }t        |j	                  d            S y)z0Returns tuple of (twilio_sid, twilio_auth_token)rg   )NN)rh   r   decrypttuplesplit)rt   	decrypteds     r-   twilio_credentialszCompanyPhone.twilio_credentialsp   s:     "**4+=+=>I-..r,   c                      | j                   d   S )Nr   r|   rt   s    r-   re   zCompanyPhone.twilio_sidx       &&q))r,   c                      | j                   d   S )Nr1   r~   r   s    r-   rf   zCompanyPhone.twilio_auth_token|   r   r,   c                      | j                   dk(  S )z,Returns True if status is 1, False otherwiser1   )r'   r   s    r-   	is_activezCompanyPhone.is_active   s     {{ar,   )r   r   r    r!   r   r   r"   r   org_idr   r8   bot_idr\   rh   r]   rc   r'   r   r)   r*   rs   propertyr|   re   rf   r   __classcell__)rv   s   @r-   r_   r_   M   s    #M	T	6BF2Jte<FN!;<JGZ	23F&*u5L6#;'M6#;'Mvc{U3IGQ'F51J51J#(   * * * *    r,   r_   N)
sqlalchemyr   r   r   r   r   r   r	   r
   r   sqlalchemy.sqlr   common.databaser   common.encryptionr   r   r   r/   r>   rD   rL   rW   r_   r+   r,   r-   <module>r      sz    b b b    ( 
Kd 
KK$ KK$ K	KD 	Kbd b	K$ 	K6 4 6 r,   