# Path: autopush/constants.py
# DEFAULT_ROUTER_TIMEOUT = 3
# 
# Path: autopush/exceptions.py
# class RouterException(AutopushException):
#     """Exception if routing has failed, may include a custom status_code and
#     body to write to the response.
# 
#     """
#     def __init__(self, message, status_code=500, response_body="",
#                  router_data=None, headers=None, log_exception=True,
#                  errno=None, logged_status=None, **kwargs):
#         """Create a new RouterException"""
#         super(AutopushException, self).__init__(message)
#         self.status_code = status_code
#         self.headers = {} if headers is None else headers
#         self.log_exception = log_exception
#         self.response_body = response_body or message
#         self.errno = errno
#         self.logged_status = logged_status
#         self.extra = kwargs


import json
import treq
from twisted.web.http_headers import Headers
from twisted.logger import Logger
from twisted.internet.error import ConnectError
from autopush.constants import DEFAULT_ROUTER_TIMEOUT
from autopush.exceptions import RouterException
                else:
                    self.failed[reg_id] = res['error']
        return self


class JSONMessage(object):
    """GCM formatted payload

    """
    def __init__(self,
                 registration_ids,
                 collapse_key,
                 time_to_live,
                 dry_run,
                 data):
        """Convert data elements into a GCM payload.

        :param registration_ids: Single or list of registration ids to send to
        :type registration_ids: str or list
        :param collapse_key: GCM collapse key for the data.
        :type collapse_key: str
        :param time_to_live: Seconds to keep message alive
        :type time_to_live: int
        :param dry_run: GCM Dry run flag to allow remote verification
        :type dry_run: bool
        :param data: Data elements to send
        :type data: dict

        """
        if not registration_ids:

# Path: autopush/constants.py
# DEFAULT_ROUTER_TIMEOUT = 3
# 
# Path: autopush/exceptions.py
# class RouterException(AutopushException):
#     """Exception if routing has failed, may include a custom status_code and
#     body to write to the response.
# 
#     """
#     def __init__(self, message, status_code=500, response_body="",
#                  router_data=None, headers=None, log_exception=True,
#                  errno=None, logged_status=None, **kwargs):
#         """Create a new RouterException"""
#         super(AutopushException, self).__init__(message)
#         self.status_code = status_code
#         self.headers = {} if headers is None else headers
#         self.log_exception = log_exception
#         self.response_body = response_body or message
#         self.errno = errno
#         self.logged_status = logged_status
#         self.extra = kwargs


# Path: autopush/router/gcmclient.py
import json
import treq
from twisted.web.http_headers import Headers
from twisted.logger import Logger
from twisted.internet.error import ConnectError
from autopush.constants import DEFAULT_ROUTER_TIMEOUT
from autopush.exceptions import RouterException

                else:
                    self.failed[reg_id] = res['error']
        return self


class JSONMessage(object):
    """GCM formatted payload

    """
    def __init__(self,
                 registration_ids,
                 collapse_key,
                 time_to_live,
                 dry_run,
                 data):
        """Convert data elements into a GCM payload.

        :param registration_ids: Single or list of registration ids to send to
        :type registration_ids: str or list
        :param collapse_key: GCM collapse key for the data.
        :type collapse_key: str
        :param time_to_live: Seconds to keep message alive
        :type time_to_live: int
        :param dry_run: GCM Dry run flag to allow remote verification
        :type dry_run: bool
        :param data: Data elements to send
        :type data: dict

        """
        if not registration_ids:

            raise RouterException("No Registration IDs specified")