# 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 fetch_all(self):
        """
        Returns all existing contacts

        :return: list of Contact

        :raises: ResponseStructureError
        """
        result = self._client.get(self._full_path())
        if 'list' not in result:
            raise ResponseStructureError("list doesn't exist in response", result)

        contacts = []

        for contact in result['list']:
            contacts.append(Contact(**contact))

        return contacts

    def fetch_by_current_user(self):
        """
        Returns all contacts by current user

        :return: list of Contact

        :raises: ResponseStructurteError
        """
        result = self._client.get('user/settings')
        if 'contacts' not in result:

# 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 fetch_all(self):
        """
        Returns all existing contacts

        :return: list of Contact

        :raises: ResponseStructureError
        """
        result = self._client.get(self._full_path())
        if 'list' not in result:
            raise ResponseStructureError("list doesn't exist in response", result)

        contacts = []

        for contact in result['list']:
            contacts.append(Contact(**contact))

        return contacts

    def fetch_by_current_user(self):
        """
        Returns all contacts by current user

        :return: list of Contact

        :raises: ResponseStructurteError
        """
        result = self._client.get('user/settings')
        if 'contacts' not in result:

            raise ResponseStructureError("'contacts' field doesn't exist in response", result)