
    }jZ                         d dl Z d dlZd dlmZ d dlZd dlmZ dee         dee         dee         fdZh dZ	h d	Z
d
hZd Zd ZdedefdZdedededefdZ	 ddededz  defdZdS )    N)deepcopy)settingssources_documentuse_source_idsreturnc                 @   g }| D ]}|                                 }|                    d          }|                    d          }|                    d          |                    d          |                    d          d}||v r|                    |           |S )Nmetadata	source_idtitlestart_timestamppage_content)r   r   r   )
model_dumpgetappend)r   r   sourcessource_documentr	   r
   s         0/var/www/html/ls-pms-bot-apis/app/utils/extra.pyprocess_sourcesr      s    W, 
( 
(+6688/$((44(ll;//) W--"*,,/@"A"A.22>BB (
 .((~~h'''^    >   tax_idtype_id	policy_id	reserv_id
auto_added
customerId
product_id
res_tax_idcustomer_idtravellerIdroom_stay_idsub_hotel_idcollect_whichsiteminder_idcreated_by_usercurrent_billingselectedRatePlanIdsource_of_creationcustomer_traveller_idproducts_added_while_createroom_number_locked_indicator>   cvccvvpinssncardtokenexpirysecretpassword	cc_number
auth_token
expirationcard_numbercredit_cardaccess_tokenpayment_tokenrefresh_tokenreservation_datac                     t          | t                    sdS t          j        dd|           }dt	          |          cxk    rdk    rn ndS dS )NFz\D       T)
isinstancestrresublen)valuedigitss     r   _looks_sensitiverH   J   s`    eS!! u VE2u%%F	S[[Bt5r   c                 *   t          | t                    r{i }|                                 D ]b\  }}|t          v r|t          v r|                                t          v r5t          |          rEt          |          }|d dg i fv r]|||<   c|S t          | t                    rmg }t                      }| D ]X}t          |          }|d di g fv rt          |          }||v r.|                    |           |                    |           Y|S | S )Nr>   )rA   dictitemsREMOVE_DUPLICATE_SECTIONSREMOVE_KEYSlowerSENSITIVE_KEYSrH   _cleanlistsetrepraddr   )	objcleanedkvrF   resultseenitemmarkers	            r   rP   rP   V   sW   #t 4IIKK 	 	DAq ---KwwyyN**"" 1IIE 	   GAJJ	C		 uu 	  	 D$<<Db"b))) $ZZF~~HHVMM$Jr   payloadc                 *   t          |           } t          |           }d|v rd|v r|                    dd            |                    d          }t	          |t
                    r,|                    dd            |                    dd            |S )Nreservationr<   overalltotalsresortFeePos)r   rP   popr   rA   rJ   )r]   rV   r_   s      r   clean_reservation_payloadrc      s    wGWooG 	  '))&--- ++m,,K+t$$ .... 	---Nr   confirmation_numberemailhotel_idr!   c                   K   	 t          j        d          4 d {V }|                    t          j        dz   | dd||d           d {V }|                                }|                    dd	          d
k    r4t          |                    d                    cd d d           d {V  S ddicd d d           d {V  S # 1 d {V swxY w Y   d S # t          $ r }t          d|            ddicY d }~S d }~ww xY w)N      N@timeoutz#frontend/Reservations/loadOrderInfoF)confirmationget_payment_data)rf   r!   )jsonheadersstatusr>   successdataerrorzLReservation not found. Confirmation number (Itenrary) or email is incorrect.zError getting reservation: z2Error getting reservation. Please try again later.)
httpxAsyncClientpostr   
LS_API_URLrm   r   rc   	Exceptionprint)rd   re   rf   r!   clientresponserq   es           r   get_reservationr|      sY     O$T222 	q 	q 	q 	q 	q 	q 	qf#[[#&KK$7(- 
 !)$0  ) 	 	 	 	 	 	 	 	H ==??Dxx"%%220&1A1ABB	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q  !op	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q 	q   O O O/A//000MNNNNNNNOsM   C BC	 C 3C	6C 	
CC CC 
D&D;DDc                 |  K   | sddiS t          |           ddt          j        d}|rt          |          |d<   ddd	d
}	 t          j        d          4 d {V }|                    t          j        dz   ||           d {V }|                                }d d d           d {V  n# 1 d {V swxY w Y   n-# t          $ r }t          d|            ddicY d }~S d }~ww xY wt          |t                    sddiS |                    di                               dg           pg }|sdg dS d|iS )Nrr   z?Hotel ID is required to look up available products and add-ons.12zapplication/json)Hotelidcurrent_versionzContent-Typez
ls-bot-keyr!   retailF   )typeofServicehappy_hoursdataPerPagerh   ri   z$Checkout/skipAcl_getFilteredProducts)rn   rm   z!Error getting available add-ons: zPUnable to load available products and add-ons right now. Please try again later.z8Unable to load available products and add-ons right now.productszENo products or add-on options are currently available for this hotel.)messager   )rB   r   LS_BOT_TOKENrs   rt   ru   rv   rm   rw   rx   rA   rJ   r   )	rf   r!   rn   r]   ry   rz   rq   r{   r   s	            r   get_available_addonsr      sh     
  \Z[[ x==*+	 G  4"%l"3"3 " G
$T222 	# 	# 	# 	# 	# 	# 	#f#[[#&LL )        H
 ==??D	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#  
 
 
5!55666g
 	
 	
 	
 	
 	
 	

 dD!! USTTxx
B''++J;;ArH 
^
 
 	
 	H sC   C A B/C /
B99C <B9=C 
C+C& C+&C+)N)rC   rs   copyr   app.core.configr   rQ   rB   r   rM   rO   rL   rH   rP   rJ   rc   r|   r    r   r   <module>r      si   				         $ $ $ $ $ $d3i c tTWy       2  ,  
	 	 	7 7 7tt     .Os O3 O# O]` O O O O0  $2 22*2 
2 2 2 2 2 2r   