# Path: moira_client/client.py
# class InvalidJSONError(Exception):
#     def __init__(self, content):
#         """
# 
#         :param content: bytes response content
#         """
#         self.content = content
# 
# Path: moira_client/client.py
# class ResponseStructureError(Exception):
#     def __init__(self, msg, content):
#         """
# 
#         :param msg: str error message
#         :param content: dict response content
#         """
#         self.msg = msg
#         self.content = content
# 
# Path: moira_client/models/base.py
# class Base:
#     @property
#     def id(self):
#         return self._id
# 
#     def __repr__(self):
#         return '({} {})'.format(self.__class__.__name__, self.id)
# 
#     def __unicode__(self):
#         return u'({} {})'.format(self.__class__.__name__, self.id)
# 
#     def __eq__(self, other):
#         return self.id == other.id
# 
#     def __ne__(self, other):
#         return self.id != other.id


from ..client import InvalidJSONError
from ..client import ResponseStructureError
from .base import Base

    def update(self, contact):
        """
        Updates an existing notification contact

        :param contact: Contact
        :return: True if ok, False otherwise
        """
        data = {
            'type': contact.type,
            'value': contact.value,
        }

        try:
            self._client.put(self._full_path(contact.id), json=data)
            return True
        except InvalidJSONError:
            return False

    def test(self, contact_id):
        """
        Push a test notification to verify that the contact is properly set up.

        :param contact_id: str contact id
        :return: True if ok, False otherwise
        """

        try:
            self._client.post(self._full_path('{id}/test'.format(id=contact_id)))
            return False

# Path: moira_client/client.py
# class InvalidJSONError(Exception):
#     def __init__(self, content):
#         """
# 
#         :param content: bytes response content
#         """
#         self.content = content
# 
# Path: moira_client/client.py
# class ResponseStructureError(Exception):
#     def __init__(self, msg, content):
#         """
# 
#         :param msg: str error message
#         :param content: dict response content
#         """
#         self.msg = msg
#         self.content = content
# 
# Path: moira_client/models/base.py
# class Base:
#     @property
#     def id(self):
#         return self._id
# 
#     def __repr__(self):
#         return '({} {})'.format(self.__class__.__name__, self.id)
# 
#     def __unicode__(self):
#         return u'({} {})'.format(self.__class__.__name__, self.id)
# 
#     def __eq__(self, other):
#         return self.id == other.id
# 
#     def __ne__(self, other):
#         return self.id != other.id


# Path: moira_client/models/contact.py
from ..client import InvalidJSONError
from ..client import ResponseStructureError
from .base import Base


    def update(self, contact):
        """
        Updates an existing notification contact

        :param contact: Contact
        :return: True if ok, False otherwise
        """
        data = {
            'type': contact.type,
            'value': contact.value,
        }

        try:
            self._client.put(self._full_path(contact.id), json=data)
            return True
        except InvalidJSONError:
            return False

    def test(self, contact_id):
        """
        Push a test notification to verify that the contact is properly set up.

        :param contact_id: str contact id
        :return: True if ok, False otherwise
        """

        try:
            self._client.post(self._full_path('{id}/test'.format(id=contact_id)))
            return False

        except InvalidJSONError as e: