
    f0f                    ^   d dl mZ d dlmZ d dlmZ d dlT d dlZd dlmZ d dl	m
Z
 d dlmZ d dlZd dlT d d	lmZ 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mZ d dlmZ d dlm Z  d dl!Z!d dlZd dl"Z"d dl#Z#d dl$m%Z% d dl&T d dl'm(Z( d dl)m*Z* d dl)m+Z+ d dl,Z,d dl-T d dl.m/Z/ d dl0m1Z1m2Z2m3Z3 d dl4m5Z5 d dl6m7Z7 d dl,Z,e
j8        Z9e
j:        Z;e
j<        Z=e
j>        Z?e
j@        ZAe
jB        ZC e5e9e;          ZDd ZEd ZF G d de          ZG G d de          ZH G d d e          ZI G d! d"e          ZJ G d# d$e          ZK G d% d&e          ZL G d' d(e          ZM G d) d*e          ZN G d+ d,e          ZO G d- d.e          ZP G d/ d0e          ZQ G d1 d2e          ZR G d3 d4e          ZS G d5 d6e          ZT G d7 d8e          ZU G d9 d:e          ZV G d; d<e          ZW G d= d>e          ZX G d? d@e          ZY G dA dBe          ZZ G dC dDe          Z[ G dE dFe          Z\ G dG dHe          Z] G dI dJe          Z^ G dK dLe          Z_ G dM dNe          Z` G dO dPe          Za G dQ dRe          Zb G dS dTe          Zc G dU dVe          Zd G dW dXe          ZedS )Y    )APIView)Responsestatus)*N)datetime)settings)django_pbkdf2_sha256)get_authorization_header)RefreshToken)TokenBackend)EmailMultiAlternatives)
exceptions)renderredirect)mail)render_to_string)messages)	timesince)Max)Q)FCMNotification)	SyncGrant	ChatGrant
VideoGrant)Client)AccessTokenc                  .   t           j                                                                        } | rb| j        sdS | j        }|dd          }t          |          dz   }t          |          }|                    d          }dt          |          z   S dS )NTRANS000001      TRANS)UserTranscationobjectsalllasttranscation_idintstrzfilllastObjtheIds     7/var/www/html/Manimaran/manimaran/worker_panel/views.pygenerateTranscationsIdr/   2   s    

!
%
%
'
'
,
,
.
. 		 
-%abb	%E

1%E

%A%	U		    c                  .   t           j                                                                        } | rb| j        sdS | j        }|dd          }t          |          dz   }t          |          }|                    d          }dt          |          z   S dS )NPOUT0001   r!   POUT) ServiceProviderPayoutTranscationr$   r%   r&   r'   r(   r)   r*   r+   s     r.   gernatePayoutIdr6   B   s    
*
2
6
6
8
8
=
=
?
? 		 
*%abb	%E

1%E

%A%	E

		r0   c                       e Zd Zd ZdS )workerRegisterc                    	 |j                             d          }|s(t          t          j        ddt          j                  S |j                             d          }|s(t          t          j        ddt          j                  S |j                             d                                          }|s(t          t          j        ddt          j                  S t          j                            |	          	                                }|r(t          t          j        d
dt          j                  S |j                             d          }|s(t          t          j        ddt          j                  S |j                             d          }|s(t          t          j        ddt          j                  S ||k    r(t          t          j        ddt          j                  S |}t          j        |          }	t          j                            |d          	                                }
t          j                            |	|||d          }d                    d t          d          D                       }dt          |j                  z   dz   |z   }t          t"          j                  |z   }||_        |                                 d}t+          dd|i          }|}d}|}t-          j        ||||g|           ddlm} |                                }d }t+          d!||||d"          }|}d}d#}t-          j        ||||g|           t          t          j        d$d          S # t8          $ rN}t;          |           t          t          j        t          |          dt          j                  cY d }~S d }~ww xY w)%N
first_namezfirst_name is requiredstatus_codestatus_messager   	last_namezlast_name is requiredemailEmail is requiredr?   z)This email is already registered with us.passwordPassword is requiredconfirm_passwordzConfirm Password is requiredz+Password and Confirm Password are not same.F)r?   is_email_verifiedT)rB   r?   r:   r>   	is_worker c                 d    g | ]-}t          j        t          j        t          j        z             .S  randomchoicestringascii_lettersdigits.0ns     r.   
<listcomp>z'workerRegister.post.<locals>.<listcomp>n   s,    ]]]afmF$86=$HII]]]r0      &/api-worker/worker-email-verification//Email Verificationuser_email_verification.htmllinksupport@olfix.co.ukhtml_messager   )datezNew Worker Registeredznew_worker_registered.html)r:   r>   r?   r]   zsuperadmin@yopmail.comzGYou have been successfully registered with us.Please verify your email.)datagetr   r   HTTP_400_BAD_REQUESTlowerUserr$   filterfirsthandlerhashcreatejoinranger)   r?   r	   BASE_URLemail_verify_linksaver   r   	send_mailr   r]   todayHTTP_200_OK	ExceptionprintHTTP_500_INTERNAL_SERVER_ERROR)selfrequestr:   r>   r?   check_emailrB   rD   string_passwordfinal_passwordcheck_customerObjcustomerObjran_numbaselinkcompletelinksubjectr\   plain_message
from_emailtor]   rn   es                          r.   postzworkerRegister.postR   s   1O  ..:
 N6#>Phiiqw  rM  N  N  N  N|,,9
 M6#>Pghhpv  qL  M  M  M  M<G$$**,,5
 I6#>Pcddlr  mH  I  I  I  I$$5$117799; a6#>P{||  EK  E`  a  a  a  alz**8
 L6#>Pfggou  pK  L  L  L  Ll&&'9::
 T6#>Pnoow}  xS  T  T  T  T"""6#>P}~~  GM  Gb  c  c  c  c&?L11>|**5U*SSYY[[|""n5T^ir  @D"  E  E;WW]]SXY[S\S\]]]^^77#k>O:P:PPSVVY``8h'((83<#+; !7"#AFLCYZZ<=%:2>'=*rdVVVV::<<5$7"#?PZgpy~  GL  BM  BM  N  N<=%: 2>'=*rdVVVV
&"4  GP  Q  Q  R  R  R	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOsO   AN  AN  
AN   AN  <AN   AN  -N  2FN   
O
AOOON__name__
__module____qualname__r   rI   r0   r.   r8   r8   Q   s(        2O 2O 2O 2O 2Or0   r8   c                       e Zd Zd ZdS )workerEmailVerificationc                 b   	 t          | j        j                  }t          |           |                    d          d         }t
          j                            ||                                          }d|_	        |
                                 t          j                            |d           t          j                            d|j        z   dz   |j        z   d	z   d
           t!          |d          S # t"          $ r)}t          |           t!          |d          cY d }~S d }~ww xY w)NrV   )r?   rk   Tr   )workeramountzA new service provider  z! has been registered successfullynew_service_provider)messagetypezemail_verified_success.htmlzemail_verified_unsuccess.html)r)   rt   pathrq   splitrb   r$   rc   rd   rE   rl   ServiceProviderWalletrg   AdminNotificationsr:   r>   r   rp   )rs   rt   rY   
user_emailuser_objr   s         r.   r_   zworkerEmailVerification.get   s9   :
dl
 
 4;;;

3#:l!!*$!OOUUWW8 $8==??? ''1'EEE$$/HI\/\]`/`aias/s  uX  0X  ^t$  u  u  u
6
7
77	 : : :888
8
9
9999999:s   C8C; ;
D.D)#D.)D.Nr   r   r   r_   rI   r0   r.   r   r      s#        : : : : :r0   r   c                       e Zd Zd ZdS )workerLoginc           
         	 |j                             d          }|s(t          t          j        ddt          j                  S |j                             d          }|s(t          t          j        ddt          j                  S t
          j                            |                                          }|dk    r(t          t          j        d	dt          j                  S t
          j                            |d
d          	                                }|rd
                    d t          d          D                       }dt          |j                  z   dz   |z   }t          t          j                  |z   }||_        |                                 d}	t%          dd|i          }
|
}d}|}t'          j        |	|||g|
           t          t          j        ddt          j                  S t
          j                            |dd          	                                }|s(t          t          j        ddt          j                  S |j        dk    r(t          t          j        ddt          j                  S |j        (t          t          j        ddt          j                  S |j                             d          }|s(t          t          j        ddt          j                  S ||_        |                                 |j        }t1          j        |j                             d          |          }|rt5          j        |          }|j        |j        |j        |j        |j        t          |          t          |j                  |j         |j!        d	}t          t          j"        d|d           S t          t          j        d!dt          j                  S # tF          $ rN}tI          |           t          t          j%        t          |          dt          j%                  cY d }~S d }~ww xY w)"Nr?   r@   r;   r   rB   rC   rA   r   z:This email does not exist in our database, please registerFr!   )r?   rE   rF   rG   c                 d    g | ]-}t          j        t          j        t          j        z             .S rI   rJ   rP   s     r.   rS   z$workerLogin.post.<locals>.<listcomp>   s,    ^^^qv}V%9FM%IJJ^^^r0   rT   rU   rV   rW   rX   rY   rZ   r[   z(Please check your email for verificationTzNo account foundz1Account not yet activated. Please contact supportz2This account is deleted.Please contact superadmin.device_tokenzDevice token is required)	idr?   r:   r>   r   refreshaccessis_profile_completedrE   zLogin Successfullyr<   r=   r^   zInvalid password)&r^   r_   r   r   r`   rb   r$   rc   countrd   rh   ri   r)   r?   r	   rj   rk   rl   r   r   rm   end_dater   rB   re   verifyr   for_userr   r:   r>   access_tokenr   rE   ro   rp   rq   rr   )rs   rt   r?   rB   usercheck_verificationrz   r{   r|   r}   r\   r~   r   r   userObjr   new_passcheckrefresh_tokenallDatar   s                        r.   r   zworkerLogin.post   s   ;O<G$$5
 I6#>Pcddlr  mH  I  I  I  Ilz**8
 L6#>Pfggou  pK  L  L  L  L<U++11334
aii6#>  QM  N  N  V\  Vq  r  r  r  r,,5U]^,__eegg `gg^^TYZ\T]T]^^^__G83?Q?W;X;XX[^^ahhHx())H4L+3("G#$BV\DZ[[L M&J	BN7M:t,WWWW6#>Pz{{  DJ  D_  `  `  `  `l!!QU!VV\\^^7
 H6#>Pbcckq  lG  H  H  H  Hn6#>  QD  E  E  MS  Mh  i  i  i  i"6#>  QE  F  F  NT  Ni  j  j  j  j,"">22<
 P6#>Pjkksy  tO  P  P  P  P&7
<<>>>8>',**:66x@@5 H )'22M*]$"(M""=-..#8 2		 		G 6#5G[cjkklll6#>Pbcckq  lG  H  H  H  H	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs[   AO8 AO8 
AO8 *DO8 <AO8 2O8 .O8 <AO8  CO8 'O8 8
QAQQQNr   rI   r0   r.   r   r      s(        <O <O <O <O <Or0   r   c                       e Zd Zd ZdS )getCategoryListc                 x   	 t           j                            d          }g }|D ],}|j        |j        |j        d}|                    |           -t          t          j	        d|d          S # t          $ r?}t          t          j        t          |          dt          j                  cY d }~S d }~ww xY w)NT)end_date__isnull)r   imagenameSuccessr   r;   r   )Categoryr$   rc   r   r   r   appendr   r   ro   rp   rr   r)   )rs   rt   category_objall_Datacatall_datar   s          r.   r_   zgetCategoryList.get   s    O"))4)@@<8  s
&YH H
 OOH
6#5yX`aa
b
bb	 O O O
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs   A-A0 0
B9:4B4.B94B9Nr   rI   r0   r.   r   r      s(        O O O O Or0   r   c                       e Zd Zd ZdS )getSubServiceListc                 $   	 |j                             d          }|s(t          t          j        ddt          j                  S t
          j                            |d          }g }|D ]=}|j        |j	        |j
        j        |j        |j        d}|                    |           >t          t          j        d|d	          S # t          $ r?}t          t          j        t#          |          dt          j                  cY d }~S d }~ww xY w)
Nmain_idzMain id is requiredr;   r   T)category_idr   )r   r   main_category_namesub_category_namer   r   r   )query_paramsr_   r   r   r`   SubCategoryr$   rc   r   r   categoryr   r   r   ro   rp   rr   r)   )rs   rt   r   sub_objsub_Datasubsub_datar   s           r.   r_   zgetSubServiceList.get   sb   O!%%i007
 K6#>Peffnt  oJ  K  K  K  K ''gRV'WW78  s
&,+Y H OOH
6#5yX`aa
b
bb	 O O O
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs%   AC A?C 
D4D
D
DNr   rI   r0   r.   r   r      (        O O O O Or0   r   c                       e Zd Zd Zd ZdS )workerUpdateProfilec                 V   	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j        |j        |j        |j        |j        |j        |j        |j        |j        |j        |j        d}t4          j	        
                    |j                  }g }|D ]X}	|	j        |	j        j        |	j        j        |	j        j        |	j        j        |	j        |	j        d}
|                     |
           Yt          t          j!        d||d          S # tD          $ rN}tG          |           t          t          j$        tK          |          d
t          j$                  cY d }~S d }~ww xY w)NnullrG   ;Authorization Header or Token is missing on Request HeadersHS256
algorithmsuser_idr!   r   rF   Worker does not exists.r;   r   r   Signature has expired)r   avatarr?   r:   r>   
experienceaddressphone_numberr   bank_details_filledis_otp_verifiedr   )r   service_namesub_service_name
service_idsub_service_idprice
time_takenr   r<   r=   r^   service)&r   stripr   AuthenticationFailedjwtdecoder	   
SECRET_KEYrb   r$   rc   rd   r   r   r`   r   r   r?   r:   r>   r   r   r   r   r   r   WorkerServicesservicesr   sub_servicesr   r   r   ro   rp   rq   rr   r)   )rs   rt   tokendecodedr   r   r   service_objservice_Datar   service_datar   s               r.   r_   zworkerUpdateProfile.get  sh   ,O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 O6#>Pijjrx  sN  O  O  O  Oo

)*A
B
BBk_N$"$(#8"6. 8  '...EE;< & &w
*$),1"%*-]$	 	L %%%%
&"4iW_jvww
x
xx	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs&   C	G DG 
H(AH#H(#H(c           	         	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|s(t          t          j        dd
t          j                  S |j                            d          }|s(t          t          j        dd
t          j                  S |j                            d          }|s(t          t          j        dd
t          j                  S |j                            d          }	|	s(t          t          j        dd
t          j                  S |j                            d          }
|
s(t          t          j        dd
t          j                  S t          j	        
                    |
                              |j                  }|r(t          t          j        dd
t          j                  S |j                            d          }|s(t          t          j        dd
t          j                  S t          j	        
                    |                              |j                  }|r(t          t          j        dd
t          j                  S |j                            d          }|rt'          j        |          }t*          j	        
                    |           }|r|D ]}|                                 |D ]}t/          |                    d!                    }t0          j	                            |          }t2          j	                            |j        j                  }t*          j	                            |||"           |j                            d#          }|j                            d$          }||_        ||_        |
|_        ||_        |	|_         ||_!        ||_"        |r
d%|z   |_#        |$                                 |j        |j#        |j        |j        |j        |j         |j        |j!        d&}t*          j	        
                    |j                   }g }|D ]6}|j        |j%        j        |j&        j        d'}|'                    |           7t          t          j(        d(||d)          S # tR          $ rN}tU          |           t          t          j+        tY          |          d
t          j+                  cY d }~S d }~ww xY w)*Nr   rG   r   r   r   r   r!   r   r   r;   r   r   r   r:   zFirst name is requiredr>   zLast name is requiredr   zAddress is requiredr   zexperience is requiredr?   r@   rA   r   z3This email is already associated with some account.r   zPhone number is required)r   z:This phone number is already associated with some account.r   r   r   )r   r   r   r   r   rV   )r   r   r?   r:   r>   r   r   r   )r   r   r   Profile updated successfullyr   )-r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   excluder   jsonloadsr   deleter(   r   r   r   rg   r:   r>   r?   r   r   r   r   r   rl   r   r   r   ro   rp   rq   rr   r)   )rs   rt   r   r   r   r   r:   r>   r   r   r?   email_checkr   check_phoner   sub_services_listall_worker_servicer   ser_idcat_objmain_objr   r   r   r   r   r   r   s                               r.   r   zworkerUpdateProfile.post3  s   YO#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 O6#>Pijjrx  sN  O  O  O  Oo

)*A
B
BB  ..:
 N6#>Phiiqw  rM  N  N  N  N|,,9
 M6#>Pghhpv  qL  M  M  M  M\i((7
 K6#>Peffnt  oJ  K  K  K  K  ..:
 N6#>Phiiqw  rM  N  N  N  N<G$$5
 I6#>Pcddlr  mH  I  I  I  I$$U$33;;x{;KK; k6#>  QF  G  G  OU  Oj  k  k  k  k,"">22<
 P6#>Pjkksy  tO  P  P  P  P$$L$AAIIX[IYY; r6#>  QM  N  N  V\  Vq  r  r  r  r,"">22< \
<00'/666II &  nn$ \ \'++d##$$V"&&F&33W $$'*:*=$>>X""(XSZ"[[[[LX&&6!,**+ABB#8!88>8#8'8#78   ZHO==??? k_N$"$(	 	8  '...EE;< & &w
*"%*- L %%%%
&"4Fdlt  @L  M  M  N  N  N	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs^   C	U= A"U= /AU= 3AU= 7AU= ;AU= ?A"U= "AU= &A"U= 	H3U= =
WAW
WWNr   r   r   r_   r   rI   r0   r.   r   r     s@        -O -O -O^ZO ZO ZO ZO ZOr0   r   c                       e Zd Zd ZdS )phoneOtpVerificationc                     	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|s(t          t          j        dd
t          j                  S |j        |k    rCd|_        |                                 t          t          j        dd
t          j                  S t          t          j        dd
t          j                  S # t*          $ rN}t-          |           t          t          j        t1          |          d
t          j                  cY d }~S d }~ww xY w)Nr   rG   r   r   r   r   r!   r   r   r;   r   r   r   otpzOTP is requiredTzOTP verified successfully.zOTP is not correct)r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   r  r   rl   ro   rp   rq   rr   r)   )rs   rt   r   r   r   r   r  r   s           r.   r   zphoneOtpVerification.post  s=   O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 O6#>Pijjrx  sN  O  O  O  Oo

)*A
B
BB
,

5
!
!3
 G6#>Pabbjp  kF  G  G  G  Glc#HMMOOO6#5Gcddlrl~6#>Pdeems  nI  J  J  J  J	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs3   C	F% A"F% /AF% ='F% %
G=/AG82G=8G=Nr   rI   r0   r.   r  r    (        O O O O Or0   r  c                       e Zd Zd ZdS )workerChangePasswordc                 4   	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|s(t          t          j        dd
t          j                  S |j                            d          }|s(t          t          j        dd
t          j                  S |j                            d          }|s(t          t          j        dd
t          j                  S |                    |          dk    r(t          t          j        dd
t          j                  S |}	|                    |	           |                                 t          t          j        dd
          S # t*          $ rN}
t-          |
           t          t          j        t1          |
          d
t          j                  cY d }
~
S d }
~
ww xY w)Nr   rG   r   r   r   r   r!   r   User does not exists.r;   r   r   r   old_passwordzold password is requirednew_passwordznew password is requirednew_confirm_passwordz new confirm password is requiredFz$Does not match with the old passwordzPassword Changed Successfully)r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   check_passwordset_passwordrl   ro   rp   rq   rr   r)   )rs   rt   r   r   r   r   r
  r  r  rB   r   s              r.   r   zworkerChangePassword.post  s   O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 M6#>Pghhpv  qL  M  M  M  Mo

)*A
B
BB,"">22<
 P6#>Pjkksy  tO  P  P  P  P,"">22<
 P6#>Pjkksy  tO  P  P  P  P!,**+ABB
 X6#>Prss  |B  |W  X  X  X  Xl++u446#>Pvww  @F  @[  \  \  \  \"8"""==???
&"4Feff
g
gg	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOsB   C	H? A"H? /AH? 3AH? 7A H? 8AH? ?
J	AJJJNr   rI   r0   r.   r  r    s(        O O O O Or0   r  c                       e Zd Zd ZdS )UploadImagesc                 N   	 |j         }|                    d          }g }|D ]&}t          |          }|                    |           't	          t
          j        d|d          S # t          $ r4}t	          dt          |          it
          j	                  cY d }~S d }~ww xY w)Nimagesr   r   r   r   )
r^   getlistuploadTheImagesr   r   r   ro   rp   r)   rr   )rs   rt   r^   r  
image_urlsr   
image_pathr   s           r.   r   zUploadImages.post  s    	V
,4LL""6: " "u ''Jj!!!!
&"4iWabb
c
cc	 V V V
Is1vv&v/T
U
U
UUUUUUUVs   A#A& &
B$0)BB$B$Nr   rI   r0   r.   r  r    s(        
V 
V 
V 
V 
Vr0   r  c                       e Zd Zd Zd ZdS )uploadWorkImagec                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|j        d	k    rt          j        d
          t          j	        
                    |          }g }|D ]&}|j        |j        d}	|                    |	           't#          t          j        d|d          S # t&          $ rN}
t)          |
           t#          t          j        t-          |
          dt          j                  cY d }
~
S d }
~
ww xY w)Nr   rG   r   r   r   r   r!   r   r   r   )	worker_id)r   r   Uploaded successfully)r<   r=   r   r;   r   )r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   WorkerWorkImagesr   r   r   r   ro   rp   rq   rr   r)   )rs   rt   r   r   r   r   prvs_objr   r   r   r   s              r.   r_   zuploadWorkImage.get  s   O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8o

)*A
B
BB&--'-BB88  u
([ H OOH
&"4F]iqrr
s
ss	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs   D&D) )
F3AE<6F<Fc                 :   	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }t"          j	                            ||           t          t          j        dd
          S # t(          $ rN}t+          |           t          t          j        t/          |          d
t          j                  cY d }~S d }~ww xY w)Nr   rG   r   r   r   r   r!   r   r	  r;   r   r   r   r  r   r   r  )r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   r  rg   ro   rp   rq   rr   r)   )rs   rt   r   r   r   r   r  r   s           r.   r   zuploadWorkImage.post  s   O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 M6#>Pghhpv  qL  M  M  M  Mo

)*A
B
BB<H%%6""("@@@
&"4F]^^
_
__	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs&   C	E A5E 
FAFFFNr   rI   r0   r.   r  r    s:        O O O0O O O O Or0   r  c                       e Zd Zd ZdS )deleteWorkImagec                 v   	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j                            d          }|s(t          t          j        dd
t          j                  S t"          j	                            |          }|                                 t          t          j        dd
          S # t(          $ rN}t+          |           t          t          j        t/          |          d
t          j                  cY d }~S d }~ww xY w)Nr   rG   r   r   r   r   r!   r   r	  r;   r   image_idzimage_id is requiredr   zDeleted successfully)r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   r  r   ro   rp   rq   rr   r)   )	rs   rt   r   r   r   r   r#  work_imgr   s	            r.   r   zdeleteWorkImage.post  s   O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 M6#>Pghhpv  qL  M  M  M  M  ,,8
 L6#>Pfggou  pK  L  L  L  L'+++::8??
&"4F\]]
^
^^	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs-   C	E  AE  AE   
F8*AF3-F83F8Nr   rI   r0   r.   r!  r!    r   r0   r!  c                       e Zd Zd Zd ZdS )addWorkerTimeSlotsc                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          t          j	        
                    |                                          }|r*t!          j        |j                  }|j        |j        |d}ni }t          t          j        d|d          S # t,          $ rN}	t/          |	           t          t          j        t3          |	          d
t          j                  cY d }	~	S d }	~	ww xY w)Nr   rG   r   r   r   r   r!   r   r	  r;   r   r   r   r   )r   r  
time_slotsr   r   )r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   WorkerTimeSlotsastliteral_evalslotsr   r  ro   rp   rq   rr   r)   )
rs   rt   r   r   r   r   check_slotsproduct_imagesr   r   s
             r.   r_   zaddWorkerTimeSlots.get"  s   O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 M6#>Pghhpv  qL  M  M  M  Mo

)*A
B
BB (///BBHHJJ; &{'899N^ *$ HH H
&"4iW_``
a
aa	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs&   C	E( BE( (
G 2AF;5G ;G c                 `   	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|s(t          t          j        dd
t          j                  S t"          j	        
                    |                                          }|r5t"          j	        
                    |                              |           n!t"          j	                            ||           t          t          j        dd
          S # t*          $ rN}t-          |           t          t          j        t1          |          d
t          j                  cY d }~S d }~ww xY w)Nr   rG   r   r   r   r   r!   r   r	  r;   r   r   r   	time_slotzTime solt is requiredr   )r,  )r   r,  r   )r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   r)  updaterg   ro   rp   rq   rr   r)   )	rs   rt   r   r   r   r   r0  r-  r   s	            r.   r   zaddWorkerTimeSlots.post?  sV   O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 M6#>Pghhpv  qL  M  M  M  Mo

)*A
B
BB  --9
 M6#>Pghhpv  qL  M  M  M  M (///BBHHJJ; F""H"55<<9<MMMM""H9"EEE
&"4iPP
Q
QQ	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs-   C	G A"G /B%G 
H-AH("H-(H-Nr   rI   r0   r.   r&  r&  !  s:        O O O:O O O O Or0   r&  c                       e Zd Zd ZdS )workerDeleteAccountc                     	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          t          j                    |_        |                                 t&          j	        
                    |j                  }|D ].}t          j                    |_        |                                 /t*          j	        
                    |j                  }|D ].}	t          j                    |	_        |	                                 /t,          j	        
                    |j                  }
|
D ].}t          j                    |_        |                                 /t          t          j        dd
          S # t0          $ rN}t3          |           t          t          j        t7          |          d
t          j                  cY d }~S d }~ww xY w)Nr   rG   r   r   r   r   r!   r   !Service provider does not exists.r;   r   r   r   r   r   service_providerzAccount deleted successfully)r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r   nowr   rl   HelpSupportr   r   Conversationro   rp   rq   rr   r)   )rs   rt   r   r   r   r   help_support_objhelpr   r   chat_objchatr   s                r.   r   zworkerDeleteAccount.postZ  s    O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 Y6#>Pstt  }C  }X  Y  Y  Y  Yo

)*A
B
BB|~~8==???!)000EE  tLNNDMIIKKKK'...EE;  w|~~GLLNNNN"))X[)II8  tLNNDMIIKKKK
&"4Fdee
f
ff	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs&   C	H5 E(H5 5
J?AJJJNr   rI   r0   r.   r3  r3  Y  s(        !O !O !O !O !Or0   r3  c                       e Zd Zd Zd ZdS )getMyServiceListc           	         	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          t          j	        
                    |j                  }g }|D ]N}|j        |j        |j        j        |j        |j        j        |j        |j        d}	|                    |	           Ot          t          j        d|d          S # t4          $ rN}
t7          |
           t          t          j        t;          |
          d
t          j                  cY d }
~
S d }
~
ww xY w)Nr   rG   r   r   r   r   r!   r   r5  r;   r   r   r   r   )r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r   r   services_idr   r   sub_services_idr   r   r   r   ro   rp   rq   rr   r)   )rs   rt   r   r   r   r   r   r   r   r   r   s              r.   r_   zgetMyServiceList.get  s   O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 Y6#>Pstt  }C  }X  Y  Y  Y  Yo

)*A
B
BB'...DD;8  w
*%$)-,1]$	 	H OOH
&"4Fdltuu
v
vv	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs&   C	F  B3F   
G
AGGGc                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|s(t          t          j        dd
t          j                  S |j                            d          }|s(t          t          j        dd
t          j                  S |j                            d          }|s(t          t          j        dd
t          j                  S t"          j	        
                    ||j                                      ||           t          t          j        dd
          S # t*          $ rN}	t-          |	           t          t          j        t1          |	          d
t          j                  cY d }	~	S d }	~	ww xY w)Nr   rG   r   r   r   r   r!   r   r5  r;   r   r   r   r   zService id is requiredr   zPrice is requiredr   zTime taken is required)rD  r  )r   r   success)r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   r   r   r1  ro   rp   rq   rr   r)   )
rs   rt   r   r   r   r   r   r   r   r   s
             r.   r   zgetMyServiceList.post  s   O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 Y6#>Pstt  }C  }X  Y  Y  Y  Yo

)*A
B
BB!!,//:
 N6#>Phiiqw  rM  N  N  N  N<G$$5
 I6#>Pcddlr  mH  I  I  I  I  ..:
 N6#>Phiiqw  rM  N  N  N  N  :(+ VV]]diu]  A  A  A
&"4iPP
Q
QQ	 O O O888
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs;   C	H A"H /AH 3AH 7AH 
I&AI!I&!I&Nr   rI   r0   r.   rA  rA  ~  s:        O O O>O O O O Or0   rA  c                       e Zd Zd ZdS )getWorkerNotificationsc                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          t          j	        
                    |j        d                              d          }g }|D ]B}|j        |j        |j        t)          |j                  dz   d}	|                    |	           Ct          t          j        d|d          S # t0          $ r?}
t          t          j        t5          |
          d
t          j                  cY d }
~
S d }
~
ww xY w)Nr   rG   r   r   r   r   r!   r   r	  r;   r   r   r   T)r   r   -id ago)r   r   notification_type
start_dater   r   )r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   WorkerNotificationsr   order_byr   r   r   rM  r   ro   rp   rr   r)   )rs   rt   r   r   r   r   
notify_objr   notifyalldatar   s              r.   r_   zgetWorkerNotifications.get  s   O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 M6#>Pghhpv  qL  M  M  M  Mo

)*A
B
BB#+22(+Y]2^^gghmnn:7  v
)!;F-..v5	 G NN7
6#5yX_``
a
aa	 O O O
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs%   C	F B;F 
G4GGGNr   rI   r0   r.   rH  rH    r  r0   rH  c                       e Zd Zd ZdS )deleteWorkerNotificationsc                    t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|s(t          t          j        dd
t          j                  S t"          j	        
                    |                              t'          j                               t          t          j        dd
          S )Nr   rG   r   r   r   r   r!   r   r	  r;   r   r   r   notification_idzNotification Id is requiredr   )r   z!Notification Deleted Successfully)r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   rN  r1  r   r9  ro   )rs   rt   r   r   r   r   rV  s          r.   r   zdeleteWorkerNotifications.post  s   
"7
+
+%
]evoo")<)<		()f	g	ggJuh1gYGGG'I'l!!w!;;AACC(	 L
&"=Ofggou  pK  L  L  L  L_

)*A
B
BB\%%&788/	 R
&"=Olmmu{  vQ  R  R  R  R$$$88???XXX	!3Ehii	j	jjr0   Nr   rI   r0   r.   rT  rT    s(        k k k k kr0   rT  c                       e Zd Zd ZdS )getWorkerBookingRequestc                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          t          j	        
                    dd|          }g }|D ]}i d|j        d|j        d|j        d|j        j        dz   |j        j        z   d|j        j        d|j        j        d|j        d|j        j        dz   |j        j        z   d|j        j        d|j        d|j        j        d|j        d|j        d|j        d|j        d|j         d |j!        |j"        |j#        |j$        |j%        d!}	|&                    |	           t          t          j'        d"|d#          S # tP          $ r?}
t          t          j)        tU          |
          d
t          j)                  cY d }
~
S d }
~
ww xY w)$Nr   rG   r   r   r   r   r!   r   r	  r;   r   r   r   TPending)is_paidbooking_statusr  r   
booking_id	user_namer   
user_imageuser_addressr  worker_nameworker_imager   r   booking_datebooking_timer\  booking_completedr   )platform_feesadmin_commission_feestotal_amountr[  r   r   )+r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   UserBookingsr   r]  r   r   r:   r>   r   r   r  r   rD  r   r   rc  rd  r\  re  r   rf  rg  rh  r[  r   ro   rp   rr   r)   )rs   rt   r   r   r   r   booking_objbooking_Databookingr   r   s              r.   r_   zgetWorkerBookingRequest.get  s"   (O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 M6#>Pghhpv  qL  M  M  M  Mo

)*A
B
BB%,,tIbj,ll;< " "w	7:7% w (3.1GG	
 ',% GL( " 7>,s2W^5MM GN) g- ,1 G( G( G( g,  2!" W]#$ *$:(+  H. !!!!
6#5yXdee
f
ff	 O O O
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs%   C	H) EH) )
I234I-'I2-I2Nr   rI   r0   r.   rX  rX    s(        )O )O )O )O )Or0   rX  c                       e Zd Zd ZdS )workerBookingDetailsc                 \   	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          | j        j                            d          }|s(t          t          j        d	d
t          j                  S t$          j	        
                    |dd|                                          }|s(t          t          j        dd
t          j                  S i d|j        d|j        d|j        d|j        d|j        j        dz   |j        j        z   d|j        j        d|j        d|j        j        d|j        d|j        d|j        d|j         d|j!        d|j"        d|j#        d |j$        d!|j%        d"|j&        i}t          t          j'        d#|d$          S # tP          $ r?}	t          t          j)        tU          |	          d
t          j)                  cY d }	~	S d }	~	ww xY w)%Nr   rG   r   r   r   r   r!   r   r	  r;   r   r   r   r]  TrZ  )r   r[  r\  r  zNo booking foundr   r  ra  r   rb  r   r   rc  rd  r\  re  r   rf  rg  rh  r[  r   r   )+r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   rt   r   r_   ri  r   r]  r   r  r   r:   r>   r   rD  r   r   rc  rd  r\  re  r   rf  rg  rh  r[  ro   rp   rr   r)   )
rs   rt   r   r   r   r   r]  rj  r   r   s
             r.   r_   zworkerBookingDetails.get  s~   'O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 M6#>Pghhpv  qL  M  M  M  Mo

)*A
B
BB)--l;;:
 M6#>Pghhpv  qL  M  M  M  M%,,
TZcpx,zz  A  A  C  C;
 H6#>Pbcckq  lG  H  H  H  H	;>;) {" &	
 ;%0369K9UU K&- k1 05 K, K, K, k0 6 [ [.  [>!" K,#$ {"% 8( 6#5yX`aa
b
bb	 O O O
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs3   C	I" A'I" 4AI" CI" "
J+,4J& J+&J+Nr   rI   r0   r.   rn  rn    s(        (O (O (O (O (Or0   rn  c                       e Zd Zd ZdS )acceptDeclineBookingc                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j        }|                    d          }|                    d          }|st          ddit          j                  S |st          ddit          j                  S |dk    s|dk    r>|dk    r0t"          j	        
                    ||                                          }	|	st          ddit          j                  S ||	_        |	                                 t          j	        
                    |	j        j                                                  }
t.          j	                            d|	j        z   dz   d|
           d}t5          t          j                  }|
j        }d}|}d|i}dd |d!}t;          |"                              |||||#          }nt"          j	        
                    ||                                          }	t          j	        
                    |	j        j                                                  }
|j                            d$          }|st          dd%it          j                  S t"          j	        
                    ||                                          }	|	st          ddit          j                  S ||	_        ||	_        d&|	_         |	                                 t.          j	                            d|	j        z   d'z   d|
           d(}t5          t          j                  }|
j        }d)}|}d|i}d*d+|d!}t;          |"                              |||||#          }tB          j	        "                                                                }tG          |	j$                  tG          |j%                  z   tG          |j&                  z   }tN          j	        
                    |j        ,                                          }tQ          d-|j)                   |tG          |j)                  k    rt          dd.it          j                  S tG          |j)                  tG          |          z
  }tQ          d/|           ||_)        |                                 tT          j	        
                    |
j        0                                          }tQ          d1|           tQ          d2|j)                   tV          j	                            tY                      |
|	t5          |          d2d34          }tG          |j)                  tG          |          z   }tQ          d5|           ||_)        |                                 t          t          j-        d6d
          S t          t          j-        d6d
          S t          dd7i          S # t\          $ r4}t          dt5          |          it          j/                  cY d }~S d }~ww xY w)8Nr   rG   r   r   r   r   r!   r   r	  r;   r   r   r   r]  status_typer   zbooking id  is requiredzstatus_type is requiredAcceptedDeclined)r   r  Booking not foundr   Your booking z  has been accepted successfully.appointment_bookingr   r   customerzYour booking has been acceptedzBooking Acceptedr   booking_acceptedzBOOKING ACCEPTEDr   titler   api_keyregistration_idmessage_titlemessage_bodydata_messageextra_notification_kwargscancellation_reasonzCancellation reason is requiredr8  z7 has been declined.Please check your wallet for refund.zYour booking has been declinedzBooking Declinedbooking_declinedzBOOKING DECLINEDr   service_wallet_objzJYou do not have sufficent balance in wallet for refund for service cancel.new_wallet_providerr6  rh  walletrefund)r'   r   rl  r   payment_modetranscation_typez
new walletr   z&Status type must be Accepted/Declined )0r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   ri  HTTP_404_NOT_FOUNDr\  rl   r   r   CustomerNotificationsrg   r]  r)   FIREBASE_SERVER_KEYr   r   notify_single_devicer  cancelled_byOtherSettingsr%   r(   r   platform_feeadmin_commissionr   rq   r   
UserWalletr#   r/   ro   rp   rr   )rs   rt   r   r   r   r   r^   r]  rs  appointment_objcust_objr   
server_keyr  r  r  r  r  resultr  other_amountrh  r  r  
wallet_objCustTransaction
new_walletr   s                               r.   r   zacceptDeclineBooking.postI  sb   eT#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 M6#>Pghhpv  qL  M  M  M  Mo

)*A
B
BB
,4&&:-((;
 ^Y89A\]]]]
 ^Y89A\]]]]Z;*#<#<j  #+22j82TTZZ\\_ Zy"56v?XYYYY&1_# ,%%)=)@%AAGGIIX"))//B\2\]2  F[  fn)  o  o  o/Wh233Z,_']\g"  2' \ j111FFWf  wD  S_  nz  UnF  o  oVV $+22j82TTZZ\\_,%%)=)@%AAGGIIX"<++,ABB hy"CDVMfgggg#+22j82TTZZ\\_ Zy"56v?XYYYY&1_#+>_($6_!"))//B\2\  ^W  3W  ]r  }E)  F  F  F/Wh233Z,_']\g"  2' \ j111FFWf  wD  S_  nz  UnF  o  oV#+//117799\-..L4M0N0NNsS_SpOqOqq\/7>>>TTZZ\\
 2 9:::s-45555y"nox~  yT  U  U  U  U1899C<M<MM
 !4555!4$++8;+??EEGGZ
>,'''
8J%&&&&.55G]G_G_em  wF  NQ  R^  N_  N_  ow  IQ5  R  R_j'((3|+<+<<Z
<
####Z__ V%7SSTTTF$6	RRSSSYGHIII	 T T T
Ic!ff%V-R
S
S
SSSSSSSTsZ   C	Z6 A.Z6 ;Z6 A%Z6  FZ6 AZ6 FZ6 5EZ6 	Z6 %Z6 6
[4 )[/)[4/[4Nr   rI   r0   r.   rq  rq  H  s-        fT fT fT fT fTr0   rq  c                       e Zd Zd ZdS )getWorkerBookingListc           	      Z   	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|s(t          t          j        dd
t          j                  S |dk    r#t"          j	        
                    |dd          }nK|dk    r#t"          j	        
                    |dd          }n"t"          j	        
                    |dd          }g }|D ]}	i d|	j        d|	j        d|	j        d|	j        j        dz   |	j        j        z   d|	j        j        d|	j        j        d|	j        d|	j        j        dz   |	j        j        z   d|	j        j        d |	j        j        j        d!|	j        j        j        d"|	j        d#|	j        j        d$|	j         d%|	j!        d%|	j!        d&|	j"        |	j#        |	j$        |	j%        |	j&        |	j'        |	j(        d'}
|)                    |
           t          t          j*        d(|d)          S # tV          $ r?}t          t          j,        t[          |          d
t          j,                  cY d }~S d }~ww xY w)*Nr   rG   r   r   r   r   r!   r   r	  r;   r   r   r   booking_typezbooking_type is requiredupcomingTrt  )r  r[  r\  complete	Completedru  r   r]  r^  r   r_  r`  r  ra  rb  r   r   r   r   rc  rd  r\  )re  r   rf  rg  rh  r[  r   r   ).r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   GETr_   ri  r   r]  r   r   r:   r>   r   r   r  r   r   r   r   rD  rc  rd  r\  re  r   rf  rg  rh  r[  r   ro   rp   rr   r)   )rs   rt   r   r   r   r   r  rj  rk  rl  r   r   s               r.   r_   zgetWorkerBookingList.get  s   4O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 M6#>Pghhpv  qL  M  M  M  Mo

)*A
B
BB+//.11<
 P6#>Pjkksy  tO  P  P  P  Pj  &--(Tbl-mmKK
""&--(Tcn-ooKK&--(Tcm-nnK< " "w	7:7% w (3.1GG	
 ',% GL( " 7>,s2W^5MM GN) '&/2 G(16 g- ,1 G( G(  G(!" g,#$ !2]*$:(/  H2 !!!!
6#5yXdee
f
ff	 O O O
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs,   C	K! A"K! /F1K! !
L*+4L%L*%L*Nr   rI   r0   r.   r  r    s(        5O 5O 5O 5O 5Or0   r  c                       e Zd Zd ZdS )myRatingReviewListingc           	         	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          t          j	        
                    |j                  }g }|D ]c}|j        |j        |j        |j        j        dz   |j        j        z   |j        j        |j        j        |j        d}	|                    |	           dt          t          j        d|d          S # t8          $ r?}
t          t          j        t=          |
          d
t          j                  cY d }
~
S d }
~
ww xY w)Nr   rG   r   r   r   r   r!   r   r	  r;   r   r   r   r7  r   r   ratingreviewcustomer_namer]  customer_avatar
created_atr   r   )r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   ServiceProviderRatingReviewsr   r  r  r   r:   r>   rl  r]  r   rM  r   ro   rp   rr   r)   )rs   rt   r   r   r   r   
review_objr   r  r   r   s              r.   r_   zmyRatingReviewListing.get  s   O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 M6#>Pghhpv  qL  M  M  M  Mo

)*A
B
BB,4;;x{;[[:8 
 
v9mm[+C/0EE.+{)# H OOH
6#5yX`aa
b
bb	 O O O
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs%   C	F CF 
G4GGGNr   rI   r0   r.   r  r    s(        O O O O Or0   r  c                       e Zd Zd ZdS )myRatingReviewDetailsc                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|s(t          t          j        dd
t          j                  S t"          j	        
                    ||j                                                  }|s(t          t          j        dd
t          j                  S |j        |j        |j        |j        j        dz   |j        j        z   |j        j        |j        j        |j        d}t          t          j        d|d          S # t:          $ r?}	t          t          j        t?          |	          d
t          j                  cY d }	~	S d }	~	ww xY w)Nr   rG   r   r   r   r   r!   r   r	  r;   r   r   r   	review_idzreview_id is required)r   r8  zNo review foundr   r  r   r   ) r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r  r_   r  r   r  r  r   r:   r>   rl  r]  r   rM  ro   rp   rr   r)   )
rs   rt   r   r   r   r   r  r  r   r   s
             r.   r_   zmyRatingReviewDetails.get  s   O#G,,5mu%++--2*=*=

)*g
h
hhZx2wiHHH7Y7|""!"<<BBDD8
 M6#>Pghhpv  qL  M  M  M  Mo

)*A
B
BB{{++9
 M6#>Pghhpv  qL  M  M  M  M,4;;^f^i;jjpprr:
 G6#>Pabbjp  kF  G  G  G  G =_/3JO4MM$/!-'	 	8 6#5yX`aa
b
bb	 O O O
&"GY\]^Y_Y_``hn  iN  O  O  O  O  O  O  O  O  OOs3   C	G: A"G: /A!G: A(G: :
I4H>8I>INr   rI   r0   r.   r  r    s(        O O O O Or0   r  c                       e Zd Zd ZdS )createConverstationProviderc                 
   	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|st          t          j        dd
          S t          j	        
                    |dd                                          }|st          t          j        dd
          S |j                            d          }|st          t          j        dd
          S t"          j	                            |          }	|	st          t          j        dd
          S t$          j	        
                    ||                                          }
|
r	|
j        }nt)          |j                  t)          |j                  z   t)          |j                  z   t)          |j                  z   }t/          |          }t1          j        |           d                    |          }t6          j        j        j                            |          }t$          j	                            |||	          }|j        |_        tA          j!                    |_"        |#                                 t)          |j                  t)          |j                  dz   t)          |j$                  z   t)          |j%                  d}tM          j'        |          }t6          j        j                            |j                  j(                            t)          |j                  |          }t)          |j                  t)          |j                  dz   t)          |j$                  z   t)          |j%                  d}tM          j'        |          }t6          j        j                            |j                  j(                            t)          |j                  |          }|j        |_)        |j        |_*        |#                                 |j        }t          t          j+        d|d          S # tX          $ r4}t          dt)          |          it          j-                  cY d }~S d }~ww xY w) Nr   rG   r   r   r   r   r!   r   User does not exist.r;   r   r   r   customer_idz service provider id is required.T)r   is_userr   zNo customer foundr]  zBooking id is requiredr   rv  )r8  r   )friendly_name)r8  r   rl  r   )r   r   r   )identity
attributesrF  )r<   r=   twilio_channel_sidr   ).r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   ri  r;  r  r)   r:   r   listrK   shufflerh   clientconversationsv1rg   sidr   r9  last_messagerl   r>   r   r   dumpsparticipantsuser_twilio_idservice_provider_twilio_idro   rp   rr   )rs   rt   r   r   r   r   r  customer_objr]  book_objexisting_conversationr  concatinate_namessuffle_stringconversation_nameconversationconversation_objuser_attributesuser_json_attributesuser_participantservice_provider_attributes service_provider_json_attributesservice_provider_participantr   s                           r.   r   z createConverstationProvider.post1  s   WV#G,,5mu%++--2*=*=

)*g
h
hhZx2yIII7Y7l!!W!::@@BB8
 ,F$?Sijj*, , , ,o

)*A
B
BB!!-00;
 xF$?Suvvwww,%%qTX%YY__aa<
 iF$?Sfgghhh  ..:
 nF$?Skllmmm"&&*&558
 iF$?Sfgghhh
 (/66Wc6ddjjll 1:.A<233c(:M6N6NNQTU]U`QaQaadghthwdxdxx*++M
N=!!!.. '	v-v..  $+22HR^hp2qq*6*:'$,LNN!|//s<;R7S7STW7WX[\h\rXsXs7s$%% O  :o66+mL$%%fc,/**6JfKK	  (+8;'7'7s8CV?W?WX[?[\_`h`r\s\s?s!!" " (,z2M'N'N$#)#7mL$%%fc(+&&2RfSS	 ! '7&:#2N2R/59
6#5yfxyy
z
zz 
 V V V
Is1vv&v/T
U
U
UUUUUUUVs?   C	T AT #AT 57T -=T +LT 
U )T;5U ;U Nr   rI   r0   r.   r  r  0  s-        XV XV XV XV XVr0   r  c                       e Zd Zd ZdS )#serviceProviderConverstationListingc                 |   	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          t          j	        
                    |          }g }|D ]O}t           j        j                            |j                  j                            dd          }	d}
d}d}|	D ]V}|j        r&|j        }
t/          |j                  dz   }|j        }/|j        r d}
t/          |j                  dz   }|j        }W|j        |j        |j        j        |j        j        dz   |j        j        z   |j        j        |j        j        |j        j        dz   |j        j        z   |j        j        |j         j        |j         j!        |j         j"        |
||d}|#                    |           Qt          t          j$        d|d          S # tJ          $ r4}t          dtM          |          it          j'                  cY d }~S d }~ww xY w)Nr   rG   r   r   r   r   r!   r   r  r;   r   r   r   r7  desc)orderlimitrK  filer   )r   r  r  r  customer_imageservice_provider_idservice_provider_nameservice_provider_imager]  r\  re  r  timemessage_daterF  r   r   )(r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r;  r  r  r  r  r   r  bodyr   date_createdmediar   r   r:   r>   r   r8  rl  r\  re  r   ro   rp   r)   rr   )rs   rt   r   r   r   r   r  conversation_listr  r   r  r  r  recordconversation_datar   s                   r.   r_   z'serviceProviderConverstationListing.get  s   7V#G,,5mu%++--2*=*=

)*g
h
hhZx2yIII7Y7l!!W!::@@BB8
 ,F$?Sijj*, , , ,o

)*A
B
BB'..(.LL=$ $0 $0|#	}\455t&t""	 
 LDL 	) 	) )[lv*++F2d(ll
, )lv*++F2d(l ?': %("'2S8<;L;VV#(/(9<*;FL|OlOvv+<C'*#+:%-?     .////
6#5yXijj
k
kk	 V V V
Is1vv&v/T
U
U
UUUUUUUVs%   C	I= F0I= =
J;)J60J;6J;Nr   rI   r0   r.   r  r    s(        8V 8V 8V 8V 8Vr0   r  c                       e Zd Zd Zd ZdS )"enableServiceProviderNotificationsc                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j        }t          d|d          S # t           $ r4}t          dt#          |          it          j                  cY d }~S d }~ww xY w)Nr   rG   r   r   r   r   r!   r   r  r;   r   r   r   rF  r   notification_settingr   )r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   notification_enablerp   r)   rr   rs   rt   r   r   r   r   r  r   s           r.   r_   z&enableServiceProviderNotifications.get  sV   V#G,,5mu%++--2*=*=

)*g
h
hhZx2yIII7Y7l!!W!::@@BB8
 ,F$?Sijj*, , , ,o

)*A
B
BB"6
i?STT
U
UU	 V V V
Is1vv&v/T
U
U
UUUUUUUVs$   C	D 7D 
E)D=7E=Ec                 $   	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|st          t          j        dd
          fS ||_        |                                 t          d|d          S # t&          $ r4}t          dt)          |          it          j                  cY d }~S d }~ww xY w)Nr   rG   r   r   r   r   r!   r   r  r;   r   r   r   r  z notification setting is requiredrF  r  r   )r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   r  rl   rp   r)   rr   r  s           r.   r   z'enableServiceProviderNotifications.post  s   V#G,,5mu%++--2*=*=

)*g
h
hhZx2yIII7Y7l!!W!::@@BB8
 ,F$?Sijj*, , , ,o

)*A
B
BB!,**+ABB
 yF$?Suvvwwxx"68==???
i?STT
U
UU	 V V V
Is1vv&v/T
U
U
UUUUUUUVs+   C	E AE $,E 
F)F
F
FNr   rI   r0   r.   r  r    s:        V V V&V V V V Vr0   r  c                       e Zd Zd ZdS )markCompleteBookingc                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|st          t          j        dd
          fS |j                            d          }|st          t          j        dd
          fS t"          j	                            |          }d|_        ||_        d|_        |                                 t,          j	                            ||           t          j	                            |j        j                  }	t4          j	                            d|j        z   dz   d|	           d}
t9          t          j                  }|	j        }d}|
}d|
i}dd|
d}t?          |                               |||||           }t          t          j!        d!d
          S # tD          $ r4}t          d"t9          |          it          j#                  cY d }~S d }~ww xY w)#Nr   rG   r   r   r   r   r!   r   r  r;   r   r   r   r]  zbooking_id is requiredcomplete_imager   TApproval_Pendingr  rw  zB has been completed succesfully.Please check and approve the work.rx  ry  zNYour booking has been completed succesfully.Please check and approve the work.zBooking Completedr   re  zBOOKING COMPLETEDr|  r~  r  r   r   )$r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   ri  re  r  r\  rl   r  rg   r   r   r  r]  r)   r  r   r   r  ro   rp   rr   )rs   rt   r   r   r   r   r]  r  rj  r  r   r  r  r  r  r  r  r  r   s                      r.   r   zmarkCompleteBooking.post  s   .V#G,,5mu%++--2*=*=

)*g
h
hhZx2yIII7Y7l!!W!::@@BB8
 ,F$?Sijj*, , , ,o

)*A
B
BB  ..:
 oF$?SkllmmnnL$$%566>
 oF$?Skllmmnn%))j)99;#';  .; 2;""H^"LLL,"")9)<"==< ''@V0V  X\  1\  bw  BN'  O  O  O]7H011:!.?&=<
G  1&
 
< J///DDUd  uB  Q]  lx  SlD  m  m6 6#5yQQ
R
RR	 V V V
Is1vv&v/T
U
U
UUUUUUUVs2   C	J AJ $8J D4J 
K)KKKNr   rI   r0   r.   r  r    s(        /V /V /V /V /Vr0   r  c                       e Zd Zd ZdS )pendingApprovalWorksc                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          t          j	        
                    |d          }g }	|D ]}
i d|
j        d|
j        d|
j        d|
j        j        dz   |
j        j        z   d|
j        j        d|
j        j        d|
j        d|
j        j        dz   |
j        j        z   d|
j        j        d|
j        d|
j        j        d|
j        d|
j        d|
j        d|
j         d|
j!        d |
j"        d!|
j#        i}|	$                    |           t          t          j%        d"|	d#          S # tL          $ r4}t          d$tO          |          it          j(                  cY d }~S d }~ww xY w)%Nr   rG   r   r   r   r   r!   r   r  r;   r   r   r   r  )r  r\  r   r]  r^  r   r_  r`  r  ra  rb  r   r   rc  rd  r\  r   rf  rg  rh  r   r   r   ))r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   ri  r   r]  r   r   r:   r>   r   r   r  r   rD  r   r   rc  rd  r\  r   rf  rg  rh  r   ro   rp   r)   rr   )rs   rt   argskwargsr   r   r   r   rj  rk  rl  r   r   s                r.   r_   zpendingApprovalWorks.get)  s   'V#G,,5mu%++--2*=*=

)*g
h
hhZx2yIII7Y7l!!W!::@@BB8
 ,F$?Sijj*, , , ,o

)*A
B
BB%,,Rd,ee;< " "w	7:7% w (3.1GG	
 ',% GL( " 7>,s2W^5MM GN) g- ,1 G( G( g, W]  W*!" W:#$ G(% H( !!!!
6#5yXdee
f
ff	 V V V
Is1vv&v/T
U
U
UUUUUUUVs%   C	H E	H 
I )I	IINr   rI   r0   r.   r  r  (  (        (V (V (V (V (Vr0   r  c                       e Zd Zd ZdS )pendingApprovalWorksDetailsc                 Z   	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|s(t          t          j        dd
t          j                  S t"          j	        
                    ||d          }	|	s(t          t          j        dd
t          j                  S g }
|	D ]}i d|j        d|j        d|j        d|j        d|j        j        dz   |j        j        z   d|j        j        d|j        d|j        j        d|j        d|j        d|j        d|j        d|j         d|j!        d|j"        d |j#        d!|j$        |j%        |j&        d"}|
'                    |           t          t          j(        d#|
d$          S # tR          $ r4}t          d%tU          |          it          j+                  cY d }~S d }~ww xY w)&Nr   rG   r   r   r   r   r!   r   r  r;   r   r   r   r]  zbooking_id is required.r  )r   r   r\  zbooking not foundr   r  ra  r   rb  r   r   rc  rd  r\  re  r   rf  rg  rh  )r[  r  r   r   r   ),r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r  r_   ri  r   r]  r   r  r   r:   r>   r   rD  r   r   rc  rd  r\  re  r   rf  rg  rh  r[  r  r   ro   rp   r)   rr   )rs   rt   r  r  r   r   r   r   r]  rj  r   approver   r   s                 r.   r_   zpendingApprovalWorksDetails.getV  sI   1V#G,,5mu%++--2*=*=

)*g
h
hhZx2yIII7Y7l!!W!::@@BB8
 ,F$?Sijj*, , , , o

)*A
B
BB--:
 (F$?Slmm&( ( ( ( %,,*H^p,qq;
 (F$?Sfgg&( ( ( (8  w
GJG&  '#	
 GN-3gn6NN W^* w. -2 W) W) W) w- '3 gm g+  g;!" W)#$ -'  H* OOH
6#5yX`aa
b
bb	 V V V
Is1vv&v/T
U
U
UUUUUUUVs3   C	I, A"I, /AI, ;C0I, ,
J*6)J%J*%J*Nr   rI   r0   r.   r   r   U  s(        2V 2V 2V 2V 2Vr0   r   c                       e Zd Zd Zd ZdS )workerBankAccountsc                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          t          j	        
                    |j                                                  }|s(t          t          j        dd
t          j                  S |j        |j        |j        |j        d}t          t          j        d|d          S # t*          $ r4}t          dt-          |          it          j                  cY d }~S d }~ww xY w)Nr   rG   r   r   r   r   r!   r   r  r;   r   r   r   r   zNo bank account details found)r   bank	sort_codeaccount_numberr   r   r   )r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   WorkerBankAccountDetailsr   r  r  r  ro   rp   r)   rr   )	rs   rt   r   r   r   r   account_objr   r   s	            r.   r_   zworkerBankAccounts.get  s   V#G,,5mu%++--2*=*=

)*g
h
hhZx2yIII7Y7l!!W!::@@BB8
 ,F$?Sijj*, , , ,o

)*A
B
BB+3::HK:PPVVXX;
 ,F$?Srss*, , , , .&!0	 8 6#5yX`aa
b
bb	 V V V
Is1vv&v/T
U
U
UUUUUUUVs+   C	F A?F 7F 
G)F=7G=Gc                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|s(t          t          j        dd
t          j                  S |j                            d          }|s(t          t          j        dd
t          j                  S |j                            d          }|s(t          t          j        dd
t          j                  S t"          j	        
                    |j                                                  }	|	r<t"          j	        
                    |j                                      |||           n>t"          j	                            ||||           d|_        |                                 t          t          j        dd
          S # t0          $ r4}
t          dt3          |
          it          j                  cY d }
~
S d }
~
ww xY w)Nr   rG   r   r   r   r   r!   r   r  r;   r   r   r   r  zbank is required.r  zsort_code is required.r  zaccount_number is required.r   )r  r  r  )r   r  r  r  Tr   r   )r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   r	  r   r1  rg   r   rl   ro   rp   r)   rr   )rs   rt   r   r   r   r   r  r  r  check_accountr   s              r.   r   zworkerBankAccounts.post  s   %V#G,,5mu%++--2*=*=

)*g
h
hhZx2yIII7Y7l!!W!::@@BB8
 ,F$?Sijj*, , , ,o

)*A
B
BB
,

6
"
"4
 (F$?Sfgg&( ( ( (|,,9
 (F$?Skll&( ( ( (L$$%566>
 (F$?Spqq&( ( ( (,4;;X[;QQWWYY= 	$++X[+AAHHd]f  wEH     $++D9N ,    $(H MMOOO
6#5yQQ
R
RR	 V V V
Is1vv&v/T
U
U
UUUUUUUVs:   C	J A"J /AJ 3AJ 7CJ 
K)J?9K?KNr   rI   r0   r.   r  r    s:        V V V<&V &V &V &V &Vr0   r  c                       e Zd Zd ZdS )serviceProviderWalletc                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          t          j	        
                    |j                                                  }|j                            d          }g }g }	|dk    rtt&          j	        
                    |j                                      d          }
|
D ]8}|j        |j        |j        |j        |j        d}|                    |           9nnt4          j	        
                    |j        d                              d          }|D ]2}|j        |j        |j        |j        d}|	                    |           3t          t          j        d|j        ||	d          S # t8          $ r4}t          dt;          |          it          j                  cY d }~S d }~ww xY w)Nr   rG   r   r   r   r   r!   r   r  r;   r   r   r   r   r  payoutr6  rJ  )r   r'   r   transcation_statusr  pay)booking__worker_idr  )r   r'   r   r  r   )r<   r=   wallet_amountpayout_Datarecived_Datar   )r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r   r   r  r_   r5   rO  r'   r   r  r  r   r#   ro   rp   r)   rr   )rs   rt   r   r   r   r   r  r  r  r  payout_transcationsr  payout_datarecived_paymentsrecrecived_datar   s                    r.   r_   zserviceProviderWallet.get  s   'V#G,,5mu%++--2*=*=

)*g
h
hhZx2yIII7Y7l!!W!::@@BB8
 ,F$?Sijj*, , , ,o

)*A
B
BB(0777MMSSUU=koo&899;<("":BIIQYQ\I]]ffglmm% % %9,}!4$ [ $$$$% '.558;hm5nnwwx}~~ ' 'F*
N	 \ &&&&
6#5yanau  EP  `l  m  m  n  n  n	 V V V
Is1vv&v/T
U
U
UUUUUUUVs%   C	I E?I 
J
)J?J
J
Nr   rI   r0   r.   r  r    r  r0   r  c                       e Zd Zd ZdS )requestPayoutc                    	 t          |          }||dk    s|                                dk    rt          j        d          t	          j        |t          j        dg          }|d         }t          j	        
                    |d                                          }|s(t          t          j        d	d
t          j                  S |j        dk    rt          j        d          |j                            d          }|s(t          t          j        dd
t          j                  S t"          j	                            |          }t%          |j                  t%          |          k     r(t          t          j        dd
t          j                  S t%          |j                  t%          |          z
  }t%          |          |_        |                                 t+                      }	t,          j	                            |	||d           t          t          j        dd
          S # t2          $ r4}
t          dt5          |
          it          j                  cY d }
~
S d }
~
ww xY w)Nr   rG   r   r   r   r   r!   r   r  r;   r   r   r   payout_amountzpayout amount is required.r   z You do not have sufficient fundsrZ  )r'   r   r   r  zRequest send successfullyr   )r   r   r   r   r   r   r	   r   rb   r$   rc   rd   r   r   r`   r^   r_   r   r(   r   rl   r6   r5   rg   ro   rp   r)   rr   )rs   rt   r   r   r   r   r  provider_wallet
new_amount	payout_idr   s              r.   r   zrequestPayout.post   sv    V#G,,5mu%++--2*=*=

)*g
h
hhZx2yIII7Y7l!!W!::@@BB8
 ,F$?Sijj*, , , ,o

)*A
B
BB<##O44=
 (F$?Sopp&( ( ( ( ,377(7KK?	/
 !!C$6$666F$?Suvv&( ( ( ( _+,,s=/A/AAJ!*ooO ""I$,33YV^hu  LU3  V  V  V
6#5Gbcc
d
dd	 V V V
Is1vv&v/T
U
U
UUUUUUUVs3   C	H5 A"H5 /A,H5 BH5 5
I3?)I.(I3.I3Nr   rI   r0   r.   r  r    s(        !V !V !V !V !Vr0   r  )frest_framework.viewsr   rest_framework.responser   rest_frameworkr   user_panel.modelsrK   r   django.confr	   passlib.hashr
   re   r   admin_panel.modelsrest_framework.authenticationr   r   rest_framework_simplejwt.tokensr   !rest_framework_simplejwt.backendsr   django.core.mailr   r   django.shortcutsr   r   django.corer   django.template.loaderr   mathpytzrM   django.contribr   admin_panel.functionsdjango.utils.timesincer   django.db.modelsr   r   r*  worker_panel.modelspyfcmr   twilio.jwt.access_token.grantsr   r   r   twilio.restr   twilio.jwt.access_tokenr   TWILIO_ACCOUNT_SIDaccount_sidTWILIO_AUTH_TOKEN
auth_tokenTWILIO_CHAT_SIDchat_service_sidTWILIO_SYNC_SIDsync_service_sidTWILIO_API_SIDapi_sidTWILIO_API_SECRET
api_secretr  r/   r6   r8   r   r   r   r   r   r  r  r  r  r!  r&  r3  rA  rH  rT  rX  rn  rq  r  r  r  r  r  r  r  r  r   r  r  r  rI   r0   r.   <module>rH     s   ( ( ( ( ( ( , , , , , , ! ! ! ! ! !                        8 8 8 8 8 8          B B B B B B 



 8 8 8 8 8 8 : : : : : : 3 3 3 3 3 3 % % % % % % - - - - - - - -       3 3 3 3 3 3 ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! # # # # # # # # # # , , , , , ,                   



 ! ! ! ! ! ! ! ! ! !         
       / / / / / / 




 ('
+ + 

!&
	Z	(	(     3O 3O 3O 3O 3OW 3O 3O 3Ol: : : : :g : : :"=O =O =O =O =O' =O =O =OBO O O O Og O O O$O O O O O O O O0JO JO JO JO JO' JO JO JOZO O O O O7 O O O8O O O O O7 O O OHV V V V V7 V V V*O *O *O *O *Og *O *O *OXO O O O Og O O O,6O 6O 6O 6O 6O 6O 6O 6Op"O "O "O "O "O' "O "O "OJ;O ;O ;O ;O ;Ow ;O ;O ;O~O O O O OW O O O6k k k k k k k k**O *O *O *O *Og *O *O *O\)O )O )O )O )O7 )O )O )OZgT gT gT gT gT7 gT gT gTV6O 6O 6O 6O 6O7 6O 6O 6OtO O O O OG O O O@ O  O  O  O  OG  O  O  OFYV YV YV YV YV' YV YV YVx9V 9V 9V 9V 9V' 9V 9V 9Vz(V (V (V (V (V (V (V (VX0V 0V 0V 0V 0V' 0V 0V 0Vf)V )V )V )V )V7 )V )V )VZ3V 3V 3V 3V 3V' 3V 3V 3VlEV EV EV EV EV EV EV EVP)V )V )V )V )VG )V )V )VX"V "V "V "V "VG "V "V "V "V "Vr0   