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    

