# Path: isserviceup/notifiers/notifier.py
# class Notifier(object):
# 
#     def notify(self, service, old_status, new_status):
#         raise NotImplemented()


import requests
from isserviceup.notifiers.notifier import Notifier
        from isserviceup.config import config


class Slack(Notifier):

    def __init__(self, web_hook_url):
        self.web_hook_url = web_hook_url

    def _build_payload(self, service, old_status, new_status):
        host_url = config.FRONTEND_URL
        if host_url[-1] == '/':
            host_url = host_url[:-1]
        payload = {
            "username": "IsServiceUp.com",
            "icon_url": '{}{}'.format(host_url, service.icon_url),
            "text": "{}'s new status is <{}|{}> (was {})".format(
                service.name,
                service.status_url,
                new_status,
                old_status,
            )

# Path: isserviceup/notifiers/notifier.py
# class Notifier(object):
# 
#     def notify(self, service, old_status, new_status):
#         raise NotImplemented()


# Path: isserviceup/notifiers/slack.py
import requests
from isserviceup.notifiers.notifier import Notifier
        from isserviceup.config import config



class Slack(Notifier):

    def __init__(self, web_hook_url):
        self.web_hook_url = web_hook_url

    def _build_payload(self, service, old_status, new_status):
        host_url = config.FRONTEND_URL
        if host_url[-1] == '/':
            host_url = host_url[:-1]
        payload = {
            "username": "IsServiceUp.com",
            "icon_url": '{}{}'.format(host_url, service.icon_url),
            "text": "{}'s new status is <{}|{}> (was {})".format(
                service.name,
                service.status_url,
                new_status,
                old_status,
            )

        }