ó
º9—^c           @   sœ  d  d l  m Z d d l m Z d d d d d d d d d e d d e e d d d d d d d d d d d d i  d „ Z d d d d d d e d d d d e d e d d d d d d d i  d d d d „ Z d d e d d e e d d d d d d d „ Z	 d d d d d d e d d d d e d e d d d d d d d i  d d d d „ Z
 d d d e d d e e d d d d d d	 „ Z d
 e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   FCMNotificationi   (   t   FCM_DJANGO_SETTINGSi   c      3   C   sÙ   |  d  k r t j d ƒ }  n  t d |  d | ƒ } | j d | d | d | d | d | d	 | d
 | d |	 d |
 d | d | d | d | d | d | d | d | d | d | d | d | d | d | d | d | ƒ } | S(   Nt   FCM_SERVER_KEYt   api_keyt   json_encodert
   topic_namet   message_bodyt   message_titlet   message_icont   soundt	   conditiont   collapse_keyt   delay_while_idlet   time_to_livet   restricted_package_namet   low_priorityt   dry_runt   data_messaget   click_actiont   badget   colort   tagt   body_loc_keyt   body_loc_argst   title_loc_keyt   title_loc_argst   content_availablet   timeoutt   extra_kwargst   extra_notification_kwargs(   t   Nonet   SETTINGSt   getR    t   notify_topic_subscribers(   R   R   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   push_servicet   result(    (    s0   /tmp/pip-unpacked-wheel-zRhu6W/fcm_django/fcm.pyt   fcm_send_topic_message   s<    		c      2   K   sÖ   | d k r t j d ƒ } n  t d | d | ƒ } | j d |  d | d | d | d | d	 | d
 | d | d | d | d |	 d |
 d | d | d | d | d | d | d | d | d | d | d | d | |  } | S(   s~  
    Copied from https://github.com/olucurious/PyFCM/blob/master/pyfcm/fcm.py:

    Send push notification to a single device
    Args:
        registration_id (str): FCM device registration IDs.
        body (str): Message string to display in the notification tray
        data (dict): Data message payload to send alone or with the notification
            message
        sound (str): The sound file name to play. Specify "Default" for device
            default sound.
    Keyword Args:
        collapse_key (str, optional): Identifier for a group of messages
            that can be collapsed so that only the last message gets sent
            when delivery can be resumed. Defaults to ``None``.
        delay_while_idle (bool, optional): If ``True`` indicates that the
            message should not be sent until the device becomes active.
        time_to_live (int, optional): How long (in seconds) the message
            should be kept in FCM storage if the device is offline. The
            maximum time to live supported is 4 weeks. Defaults to ``None``
            which uses the FCM default of 4 weeks.
        low_priority (boolean, optional): Whether to send notification with
            the low priority flag. Defaults to ``False``.
        restricted_package_name (str, optional): Package name of the
            application where the registration IDs must match in order to
            receive the message. Defaults to ``None``.
        dry_run (bool, optional): If ``True`` no message will be sent but
            request will be tested.

    Returns:
        :tuple:`multicast_id(long), success(int), failure(int),
            canonical_ids(int), results(list)`:
        Response from FCM server.
    Raises:
        AuthenticationError: If :attr:`api_key` is not set or provided or there
            is an error authenticating the sender.
        FCMServerError: Internal server error or timeout error on Firebase cloud
            messaging server
        InvalidDataError: Invalid data provided
        InternalPackageError: JSON parsing error, mostly from changes in the
            response of FCM, create a new github issue to resolve it.
    R   R   R   t   registration_idR   R   R   R   R	   R   R   R   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   R   N(   R   R   R    R    t   notify_single_device(   R%   t   titlet   bodyt   icont   dataR	   R   R   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   kwargsR"   R#   (    (    s0   /tmp/pip-unpacked-wheel-zRhu6W/fcm_django/fcm.pyt   fcm_send_messageC   s<    G		c         C   s‚   t  d |
 d k r! t j d ƒ n |
 d | ƒ } | j d |  d | d | d | d | d	 | d
 | d | d | d |	 d | d | ƒ S(   sò  
    Send push message to a single device
    All arguments correspond to that defined in pyfcm/fcm.py.

    Args:
        registration_id (str): FCM device registration IDs.
        data_message (dict): Data message payload to send alone or with the
            notification message

    Keyword Args:
        collapse_key (str, optional): Identifier for a group of messages
            that can be collapsed so that only the last message gets sent
            when delivery can be resumed. Defaults to ``None``.
        delay_while_idle (bool, optional): If ``True`` indicates that the
            message should not be sent until the device becomes active.
        time_to_live (int, optional): How long (in seconds) the message
            should be kept in FCM storage if the device is offline. The
            maximum time to live supported is 4 weeks. Defaults to ``None``
            which uses the FCM default of 4 weeks.
        low_priority (boolean, optional): Whether to send notification with
            the low priority flag. Defaults to ``False``.
        restricted_package_name (str, optional): Package name of the
            application where the registration IDs must match in order to
            receive the message. Defaults to ``None``.
        dry_run (bool, optional): If ``True`` no message will be sent but
            request will be tested.
        timeout (int, optional): set time limit for the request
    Returns:
        :dict:`multicast_id(long), success(int), failure(int),
            canonical_ids(int), results(list)`:
        Response from FCM server.

    Raises:
        AuthenticationError: If :attr:`api_key` is not set or provided or there
            is an error authenticating the sender.
        FCMServerError: Internal server error or timeout error on Firebase cloud
            messaging server
        InvalidDataError: Invalid data provided
        InternalPackageError: Mostly from changes in the response of FCM,
            contact the project owner to resolve the issue
    R   R   R   R%   R
   R   R   R   R   R   R   R   R   R   R   N(   R    R   R   R    t   single_device_data_message(   R%   R
   R   R   R   R   R   R   R   R   R   R   R   R   R"   (    (    s0   /tmp/pip-unpacked-wheel-zRhu6W/fcm_django/fcm.pyt#   fcm_send_single_device_data_message¯   s     9!		c      2   K   sÖ   | d k r t j d ƒ } n  t d | d | ƒ } | j d |  d | d | d | d | d	 | d
 | d | d | d | d |	 d |
 d | d | d | d | d | d | d | d | d | d | d | d | |  } | S(   s€  
    Copied from https://github.com/olucurious/PyFCM/blob/master/pyfcm/fcm.py:

    Send push notification to a single device
    Args:
        registration_ids (list): FCM device registration IDs.
        body (str): Message string to display in the notification tray
        data (dict): Data message payload to send alone or with the notification
            message
        sound (str): The sound file name to play. Specify "Default" for device
            default sound.
    Keyword Args:
        collapse_key (str, optional): Identifier for a group of messages
            that can be collapsed so that only the last message gets sent
            when delivery can be resumed. Defaults to ``None``.
        delay_while_idle (bool, optional): If ``True`` indicates that the
            message should not be sent until the device becomes active.
        time_to_live (int, optional): How long (in seconds) the message
            should be kept in FCM storage if the device is offline. The
            maximum time to live supported is 4 weeks. Defaults to ``None``
            which uses the FCM default of 4 weeks.
        low_priority (boolean, optional): Whether to send notification with
            the low priority flag. Defaults to ``False``.
        restricted_package_name (str, optional): Package name of the
            application where the registration IDs must match in order to
            receive the message. Defaults to ``None``.
        dry_run (bool, optional): If ``True`` no message will be sent but
            request will be tested.

    Returns:
        :tuple:`multicast_id(long), success(int), failure(int),
            canonical_ids(int), results(list)`:
        Response from FCM server.
    Raises:
        AuthenticationError: If :attr:`api_key` is not set or provided or there
            is an error authenticating the sender.
        FCMServerError: Internal server error or timeout error on Firebase cloud
            messaging server
        InvalidDataError: Invalid data provided
        InternalPackageError: JSON parsing error, mostly from changes in the
            response of FCM, create a new github issue to resolve it.
    R   R   R   t   registration_idsR   R   R   R   R	   R   R   R   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   R   N(   R   R   R    R    t   notify_multiple_devices(   R/   R'   R(   R)   R*   R	   R   R   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R+   R"   R#   (    (    s0   /tmp/pip-unpacked-wheel-zRhu6W/fcm_django/fcm.pyt   fcm_send_bulk_messageü   s<    G		c         C   s‚   t  d |  d k r! t j d ƒ n |  d | ƒ } | j d | d | d | d | d | d	 | d
 | d | d |	 d |
 d | d | ƒ S(   s´  
    Arguments correspond to those from pyfcm/fcm.py.

    Sends push message to multiple devices,
    can send to over 1000 devices

    Args:
        api_key
        registration_ids (list): FCM device registration IDs.
        data_message (dict): Data message payload to send alone or with the notification message

    Keyword Args:
        collapse_key (str, optional): Identifier for a group of messages
            that can be collapsed so that only the last message gets sent
            when delivery can be resumed. Defaults to ``None``.
        delay_while_idle (bool, optional): If ``True`` indicates that the
            message should not be sent until the device becomes active.
        time_to_live (int, optional): How long (in seconds) the message
            should be kept in FCM storage if the device is offline. The
            maximum time to live supported is 4 weeks. Defaults to ``None``
            which uses the FCM default of 4 weeks.
        low_priority (boolean, optional): Whether to send notification with
            the low priority flag. Defaults to ``False``.
        restricted_package_name (str, optional): Package name of the
            application where the registration IDs must match in order to
            receive the message. Defaults to ``None``.
        dry_run (bool, optional): If ``True`` no message will be sent but
            request will be tested.
    Returns:
        :tuple:`multicast_id(long), success(int), failure(int), canonical_ids(int), results(list)`:
        Response from FCM server.

    Raises:
        AuthenticationError: If :attr:`api_key` is not set or provided or there is an error authenticating the sender.
        FCMServerError: Internal server error or timeout error on Firebase cloud messaging server
        InvalidDataError: Invalid data provided
        InternalPackageError: JSON parsing error, mostly from changes in the response of FCM, create a new github issue to resolve it.
    R   R   R   R/   R
   R   R   R   R   R   R   R   R   R   R   N(   R    R   R   R    t   multiple_devices_data_message(   R   R/   R
   R   R   R   R   R   R   R   R   R   R   R   R"   (    (    s0   /tmp/pip-unpacked-wheel-zRhu6W/fcm_django/fcm.pyt   fcm_send_bulk_data_messagesi  s     5!		t   FCMErrorc           B   s   e  Z d  Z RS(   s   
    PyFCM Error
    (   t   __name__t
   __module__t   __doc__(    (    (    s0   /tmp/pip-unpacked-wheel-zRhu6W/fcm_django/fcm.pyR4   ²  s   N(   t   pyfcmR    t   settingsR   R   R   t   FalseR$   R,   R.   R1   R3   t	   ExceptionR4   (    (    (    s0   /tmp/pip-unpacked-wheel-zRhu6W/fcm_django/fcm.pyt   <module>   sÒ   &TAU;