U
    k7g                     @   s,   d dl mZ d dlmZ G dd deZdS )   )BaseAPI)InvalidDataErrorc                   @   s    e Zd Zd	ddZd
ddZdS )FCMNotificationNFx   c                 C   s8   | j |||||||||
|	||d}| ||}| |S )a&  
        Send push notification to a single device

        Args:
            fcm_token (str, optional): FCM device registration ID
            notification_title (str, optional): Message title to display in the notification tray
            notification_body (str, optional): Message string to display in the notification tray
            notification_image (str, optional): Icon that appears next to the notification

            data_payload (dict, optional): Arbitrary key/value payload, which must be UTF-8 encoded

            topic_name (str, optional): Name of the topic to deliver messages to e.g. "weather".
            topic_condition (str, optional): Condition to broadcast a message to, e.g. "'foo' in topics && 'bar' in topics".

            android_config (dict, optional): Android specific options for messages - https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidconfig
            apns_config (dict, optional): Apple Push Notification Service specific options - https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#apnsconfig
            webpush_config (dict, optional): Webpush protocol options - https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushconfig
            fcm_options (dict, optional): Platform independent options for features provided by the FCM SDKs - https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#fcmoptions

            timeout (int, optional): Set time limit for the request

        Returns:
            dict: name (str) - The identifier of the message sent, in the format of projects/*/messages/{message_id}

        Raises:
            FCMServerError: FCM is temporary not available
            AuthenticationError: error authenticating the sender account
            InvalidDataError: data passed to FCM was incorrecly structured
            FCMSenderIdMismatchError: the authenticated sender is different from the sender registered to the token
            FCMNotRegisteredError: device token is missing, not registered, or invalid
        )	fcm_tokennotification_titlenotification_bodynotification_imagedata_payload
topic_nametopic_conditionandroid_configapns_configwebpush_configfcm_optionsdry_run)Zparse_payloadsend_requestparse_response)selfr   r   r   r	   r
   r   r   r   r   r   r   r   timeoutpayloadresponse r   -/tmp/pip-unpacked-wheel-vxwmpmkg/pyfcm/fcm.pynotify   s     /zFCMNotification.notify   c                 C   s   |dkrg }| j ||dS )a  
        Sends push notification to multiple devices with personalized templates

        Args:
            params_list (list): list of parameters (the same as notify_multiple_devices)
            timeout (int, optional): set time limit for the request
        N)params_listr   )Zsend_async_request)r   r   r   r   r   r   async_notify_multiple_devicesF   s    z-FCMNotification.async_notify_multiple_devices)NNNNNNNNNNNFr   )Nr   )__name__
__module____qualname__r   r   r   r   r   r   r      s                
@r   N)Zbaseapir   errorsr   r   r   r   r   r   <module>   s   