# 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 oauth2client.service_account import ServiceAccountCredentials
from twisted.logger import Logger
from twisted.internet.error import (ConnectError, TimeoutError)
from autopush.constants import DEFAULT_ROUTER_TIMEOUT
from autopush.exceptions import RouterException
            raise RouterException(
                "Unknown error response: {}".format(content))
        return self


class FCMv1(object):
    def __init__(self,
                 project_id,
                 service_cred_path=None,
                 logger=None,
                 metrics=None,
                 **options):
        self.project_id = project_id
        self.endpoint = ("https://fcm.googleapis.com/v1/"
                         "projects/{}/messages:send".format(self.project_id))

        self.token = None
        self.metrics = metrics
        self.logger = logger or Logger()
        self._options = options
        if service_cred_path:
            self.svc_cred = ServiceAccountCredentials.from_json_keyfile_name(
                service_cred_path,
                ["https://www.googleapis.com/auth/firebase.messaging"])
        self._sender = treq.post

    def _get_access_token(self):
        return self.svc_cred.get_access_token()

    def _build_message(self, token, notif):

# 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/fcmv1client.py
import json
import treq
from oauth2client.service_account import ServiceAccountCredentials
from twisted.logger import Logger
from twisted.internet.error import (ConnectError, TimeoutError)
from autopush.constants import DEFAULT_ROUTER_TIMEOUT
from autopush.exceptions import RouterException

            raise RouterException(
                "Unknown error response: {}".format(content))
        return self


class FCMv1(object):
    def __init__(self,
                 project_id,
                 service_cred_path=None,
                 logger=None,
                 metrics=None,
                 **options):
        self.project_id = project_id
        self.endpoint = ("https://fcm.googleapis.com/v1/"
                         "projects/{}/messages:send".format(self.project_id))

        self.token = None
        self.metrics = metrics
        self.logger = logger or Logger()
        self._options = options
        if service_cred_path:
            self.svc_cred = ServiceAccountCredentials.from_json_keyfile_name(
                service_cred_path,
                ["https://www.googleapis.com/auth/firebase.messaging"])
        self._sender = treq.post

    def _get_access_token(self):
        return self.svc_cred.get_access_token()

    def _build_message(self, token, notif):

        msg = {