a
    Wõ!fÉ-  ã                   @   s:   d dl Z d dlZd dlmZ d dlmZ G dd„ dƒZdS )é    N)ÚEnvironment)ÚClientc                   @   s¬   e Zd Zeddd„ƒZedd„ ƒZedd„ ƒZeddd„ƒZedd„ ƒZeddd„ƒZ	ed dd„ƒZ
edd„ ƒZed!dd„ƒZed"dd„ƒZed#dd„ƒZed$dd„ƒZdS )%Ú
SMSServiceNFc                 C   sä   |r|   ¡ dkrtdƒ‚|   ¡ dkr(dnd}|   ¡ dkr<dnd}|rHdnd}|dur´|dur´|d	kr´|d	kr´t|ƒd
› d¡ d¡}t|ƒd
› d¡ d¡}	d|› |	› |› |› }
n,t|ƒd
› d¡ d¡}|› |› |› |› }
|
S )a½  
        Generates a description of the reward based on the credit amount and type, or a range if boundaries are specified.
            Args:
                compensation (str): The amount of credit to be rewarded.
                credit_type (str): The type of credit to be rewarded.
                min_compensation(int): The minimum boundary for the reward.
                max_compensation(int): The maximum boundary for the reward.
        Úpercentz6Credit type cannot be 'percent' when hard_cash is TrueÚcashú$Ú ú%z offNr   z.2fÚ0Ú.zup to )ÚlowerÚ
ValueErrorÚfloatÚrstrip)Úcredit_typeÚcompensationÚmin_compensationÚmax_compensationÚ	hard_cashÚprefixÚsuffixZtrailing_wordZ
min_amountZ
max_amountÚcredit_description© r   úJ/var/www/html/python-backend/backend/services/notifications/sms_service.pyÚgenerate_reward_description
   s     z&SMSService.generate_reward_descriptionc                 C   sV   d}| dkrd}n@| dkr d}n2| dkr.d}n$| dkr<d	}n| d
krJd}nt dƒ‚|S )Nr   ÚinstagramStoryzInstagram StoryÚugczphoto or videoÚinstagramPostzInstagram PostÚinstagramReelzInstagram ReelÚtiktokVideozTiktok VideozInvalid content type)r   )Úcontent_typeÚcontent_type_finalr   r   r   Útype_of_content&   s    zSMSService.type_of_contentc                 C   sN   t  d¡dk}|r|d fS tj}tj}d}t||ƒ}|jj| ||d}||fS )NZSUPPRESS_SMSÚtruez+18334867100)ÚtoÚfrom_Úbody)ÚosÚgetenvr   ÚTWILIO_ACCOUNT_SIDÚTWILIO_AUTH_TOKENr   ÚmessagesÚcreate)ÚtargetÚmessageZsuppress_smsZaccount_sidZ
auth_tokenZtwilio_numberZtwilio_clientÚresponser   r   r   Úsend_sms?   s    
ÿzSMSService.send_smsÚStoryItr   c              
   C   sz   |dkrd|› dn|}d}|| }t |ƒ t d|  ƒ zt | |¡W S  tyt } zt |ƒ W Y d }~d S d }~0 0 d S )Nr   z
Welcome to the u¯    rewards program! You can earn incredible rewards by sharing your Instagram stories and content. ðŸ’°ðŸ’« Start sharing and unlock cash, credit, discounts, and more! ðŸ“¸âœ¨ 
z6
        
Reply HELP for help or STOP to unsubscribe.
zSending welcome text to ©Úprintr   r0   Ú	Exception)r-   Úbusiness_nameÚbusiness_welcome_textr.   Z
reply_stopZcomplete_messageÚer   r   r   Úsend_welcome_textO   s    þÿþzSMSService.send_welcome_textc              
   C   s°   t  |¡}d}|dkrd}|dkr(d}nd|› d|› d}d	|rLd
| d
 nd› d|› d|› d}td|  ƒ zt  | |¡W S  tyª } zt|ƒ W Y d }~d S d }~0 0 d S )Nr   r   uS   ðŸŽ‰ Your submission is under review. We'll let you know when your reward is ready!r   u`   ðŸŽ‰ Now, it's time to post your Tiktok video. Remember to follow all the requirements! ðŸ’«ðŸ“¸u!   ðŸŽ‰ Now, it's time to post your z<. Remember to follow all the requirements and to leave your u#    up for at least 24 hours! ðŸ’«ðŸ“¸z
Congratulationsz, Ú zon accepting the offer from z! Ú
z!Sending offer acceptance text to ©r   r"   r3   r0   r4   )r-   Únamer5   r    r!   Zextended_messager.   r7   r   r   r   Úsend_offer_acceptance_textf   s(    
ÿÿÿz%SMSService.send_offer_acceptance_textc              
   C   s~   |rd|› dnd}d|r|nt j› d|› d}td|  ƒ zt | |¡W S  tyx } zt|ƒ W Y d }~d S d }~0 0 d S )Nz
Your discount code is: r:   r   u²   
Your content was verified. Your well-deserved reward is now available in your wallet. Simply click the link below to access it and start enjoying the benefits! ðŸ’°âœ¨

https://ú/wallet
u‘   
Thank you for your participation and stay tuned for more exciting opportunities and rewards in the future. Happy redeeming! ðŸ˜ŠðŸ›ï¸
        zSending post approved text to )r   ÚWEB_APP_URLr3   r   r0   r4   )r-   Úwhitelabel_urlÚdiscount_codeZdiscount_code_textr.   r7   r   r   r   Úsend_post_approved_text„   s    ýüz"SMSService.send_post_approved_textc              
   C   sZ   |sdnd}t d|  ƒ zt | |¡W S  tyT } zt |ƒ W Y d }~d S d }~0 0 d S )Na¨  
Oops! We encountered a little hiccup in verifying your post. Not to worry, though! To receive your well-deserved reward, please fill out the form below and we will contact you shortly. 

https://forms.gle/ZbZQX7RQ4qG8ZyvG7

If your account is set to private, kindly ensure that one of our verification accounts is following you. We appreciate your cooperation and look forward to resolving this issue promptly. Thank you! 
z¾
We were unable to successfully verify your submission. If you believe this is an error, please fill out the form below and we will contact you shortly.

https://forms.gle/ZbZQX7RQ4qG8ZyvG7
zSending post rejected text to r2   )r-   Úis_ugc_offerr.   r7   r   r   r   Úsend_post_rejected_text–   s    
ù÷z"SMSService.send_post_rejected_textc              
   C   sZ   d|› d}t d|  ƒ zt | |¡W S  tyT } zt |ƒ W Y d }~d S d }~0 0 d S )Nu!   
ðŸš¨ Our verification account, @um   , has requested to follow you on Instagram.

Please accept the request so we can verify your post/reel! ðŸš¨
z&Sending accept follow request text to r2   )r-   Úbot_usernamer.   r7   r   r   r   Ú)send_accept_instagram_follow_request_text®   s    ÿz4SMSService.send_accept_instagram_follow_request_textc           	   
   C   s¨   t  ||¡}d|› d|› d|r"|ntj› dd|› d|› d|rB|ntj› dg}t |¡}td|  ƒ zt  | |¡W S  ty¢ } zt|ƒ W Y d }~d S d }~0 0 d S )	Nz5
Hi there! This is a friendly reminder that you have z at z".

To access your reward: https://r>   z"
Hey! Just a reminder to use your z on your next purchase at z.

https://z Sending credit reminder text to )	r   r   r   r?   ÚrandomÚchoicer3   r0   r4   )	r-   r5   r   r   r@   r   r+   r.   r7   r   r   r   Úsend_credit_reminder_text¼   s.    ÿÿýÿÿýú
z$SMSService.send_credit_reminder_textc
                 C   sÖ   t d|  ƒ t |||||	¡}
t |¡}|d  ¡ dv r<dnd}|dkrLdnd|› }d	|r`|ntj› d
}d|› d|› d|› |› d|
› d|› d}zt | |¡W S  tyÐ } zt |ƒ W Y d }~d S d }~0 0 d S )NzSending private offer alert to r   ÚaeiouÚanÚar   r   ú
 and tag @zhttps://z/walletz+
You have received an exclusive offer from u   ! ðŸ‘€ðŸŽ‰

Upload r9   z	 to earn u   ! ðŸ“¸âœ¨

Check it out: z	
        )	r3   r   r   r"   r   r   r?   r0   r4   )r-   r5   Úclient_ig_handler    r   r   r   r   r@   r   r   Úcontent_type_formattedÚarticleÚtag_instructionÚurlr.   r7   r   r   r   Úsend_private_offer_alert_textÕ   s0    
ÿýýýýûz(SMSService.send_private_offer_alert_textc              
   C   sÐ   t d|  ƒ t |ƒ t |||||¡}t |¡}	|	d  ¡ dv rDdnd}
|dkrTdnd|› }d	|
› d
|	› |› d|› d}z"t d|  ƒ t |ƒ t | |¡W S  tyÊ } zt |ƒ W Y d }~d S d }~0 0 d S )Nzsending post reminder to r   rJ   rK   rL   r   r   rM   uD   
ðŸ™ˆ Oops! We couldn't find your post.

Please make sure to upload r9   z to unlock your u   ! ðŸ“¸âœ¨
        zSending post reminder text to )r3   r   r   r"   r   r0   r4   )r-   rN   r    r   r   r   r   r   r   rO   rP   rQ   r.   r7   r   r   r   Úsend_post_reminder_textñ   s,    
ýýýýz"SMSService.send_post_reminder_textc           	   
   C   s´   t  |¡}d}|dkr$d|› d}n"|dkr:d|› d}n|dkrFd	}d
|› d|› d|› d}z"td|  d | ƒ t  | |¡W S  ty® } zt|ƒ W Y d }~d S d }~0 0 d S )Nr   z-1zThe @z tag was not foundz-2zA z was not foundz-69zProfanity was detectedu    
ðŸ”„ Uh oh! It looks like your z needs to be re-uploaded.

z	 in your u<   , give it another go to unlock your reward! ðŸ“¸âœ¨
        z"Sending post resubmission text to z: r;   )	r-   Úmissing_requirement_error_coder    Úclient_instagram_handleÚspecific_productr!   Zmissing_requirementr.   r7   r   r   r   Úsend_post_resubmission  s*    
ÿýýz!SMSService.send_post_resubmission)NNNF)r1   r   )NN)F)N)NNNNF)NNNF)r   r   )Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr   r"   r0   r8   r=   rB   rD   rF   rI   rS   rT   rX   r   r   r   r   r      s0   



r   )r'   rG   Úenvironmentr   Ztwilio.restr   r   r   r   r   r   Ú<module>   s   