o
    dWf 	  ã                   @   sj   d dl Z d dl mZmZ e d¡Ze  e¡ dd„ Zdd„ Zdd	„ Zd
d„ Z	dd„ Z
dd„ Zddd„ZdS )é    N)Ú	messagingÚcredentialsz0loop-com-firebase-adminsdk-1giu3-8a1c208390.jsonc                 C   ó$   d}d}| j  ¡ j}t|||ƒ d S )NzDriver Has Arrivedz/Your driver has arrived at the pickup location.©ÚdevicesÚfirstÚdevice_tokenÚsend_firebase_notification©ÚuserÚrideÚtitleÚbodyr   © r   ú+/var/www/html/loop/booking/notifications.pyÚnotify_user_driver_arrived   ó   r   c                 C   r   )NzRide Startedz*Your ride has started. Enjoy your journey!r   r
   r   r   r   Únotify_user_ride_started   r   r   c                 C   r   )NzRide Finishedz8Your ride has finished. Thank you for using our service!r   r
   r   r   r   Únotify_user_ride_finished   r   r   c                 C   r   )NzDriver is Approachingz8Your driver is almost there. Please be ready for pickup.r   r
   r   r   r   Únotify_user_driver_reaching   r   r   c                 C   s4   d}d}| j  ¡ j}dt|jƒi}t||||ƒ d S )NzRide AcceptedzYour ride has been accepted.Úride_id)r   r   r   ÚstrÚidr	   )r   r   r   r   r   Údatar   r   r   Únotify_user_ride_accepted!   s
   r   c                 C   sf   t dƒ d}d}t|jƒt|jjƒt|jjƒdœ}t dƒ | j}|j ¡ j	}t dƒ t
||||ƒ d S )Nz)Step 1: Constructing notification detailszNew Ride RequestzYou have a new ride request.)r   Úpickup_coordsÚdropoff_coordsz(Step 2: Retrieving driver's device tokenz/Step 3: Sending Firebase notification to driver)Úprintr   r   Úpickup_locationÚcoordsÚdropoff_locationÚdriverr   r   r   r	   )Údriver_locationr   r   r   r   r!   r   r   r   r   Únotify_driver_new_ride(   s   

ýr#   c                 C   s(   t jt j||d�|| d�}t  |¡}|S )N)r   r   )Únotificationr   Útoken)r   ÚMessageÚNotificationÚsend)r   r   r   r   ÚmessageÚresponser   r   r   r	   :   s   þú

r	   )N)Úfirebase_adminr   r   ÚCertificateÚcredÚinitialize_appr   r   r   r   r   r#   r	   r   r   r   r   Ú<module>   s    

