# Path: groupy/api/attachments.py
# class Attachment(base.Resource, metaclass=AttachmentMeta):
#     """Base attachment class.
# 
#     Every attachment has a type and additional data.
# 
#     :param str type: attachment type
#     :param kwargs data: additional attachment data
#     """
# 
#     def __init__(self, type, **data):
#         data['type'] = type
#         self.data = data
# 
#     def to_json(self):
#         """Return the attachment as JSON serializable dict.
# 
#         :return: serializable attachment data
#         :rtype: dict
#         """
#         return self.data
# 
#     @classmethod
#     def from_data(cls, type, **data):
#         """Create an attachment from data.
# 
#         :param str type: attachment type
#         :param kwargs data: additional attachment data
#         :return: an attachment subclass object
#         :rtype: `~groupy.api.attachments.Attachment`
#         """
#         try:
#             return cls._types[type](**data)
#         except KeyError:
#             return cls(type=type, **data)
#         except TypeError as e:
#             error = 'could not create {!r} attachment'.format(type)
#             raise TypeError('{}: {}'.format(error, e.args[0]))
# 
#     @classmethod
#     def from_bulk_data(cls, attachments):
#         """Create multiple attachments from a list of attachment data.
# 
#         :return: attachment sublcass objects
#         :rtype: :class:`list`
#         """
#         return [cls.from_data(**a) for a in attachments]
# 
# Path: groupy/utils.py
# def urljoin(base, path=None):
# def parse_share_url(share_url):
# def get_rfc3339(when):
# def get_datetime(timestamp):
#     def __init__(self, key, value):
#     def __repr__(self):
#     def __call__(self, obj):
#     def __init__(self, tests):
#     def __call__(self, objects):
#     def find(self, objects):
#     def passes(self, obj):
# def make_filter(**tests):
# class AttrTest:
# class Filter:
# 
# Path: groupy/pagers.py
# class Pager:
# class GroupList(Pager):
# class ChatList(GroupList):
# class MessageList(Pager):
# class GalleryList(MessageList):
#     def __init__(self, manager, endpoint, **params):
#     def __getitem__(self, index):
#     def __iter__(self):
#     def set_next_page_params(self):
#     def fetch(self):
#     def fetch_next(self):
#     def autopage(self):
#     def set_next_page_params(self):
#     def __init__(self, manager, endpoint, **params):
#     def detect_mode(cls, **params):
#     def set_next_page_params(self):
#     def get_last_item_index(self):
#     def get_next_page_param(self, item):
#     def fetch_next(self):
#     def get_next_page_param(self, item):


import time
from . import base
from .attachments import Attachment
from groupy import utils
from groupy import pagers
            'source_guid': source_guid or str(time.time()),
            'recipient_id': self.other_user_id,
        }

        if text is not None:
            message['text'] = text

        if attachments is not None:
            message['attachments'] = [a.to_json() for a in attachments]

        payload = {'direct_message': message}
        response = self.session.post(self.url, json=payload)
        message = response.data['direct_message']
        return DirectMessage(self, **message)


class GenericMessage(base.ManagedResource):
    """A message.

    :param manager: a message manager
    :param str conversation_id: the ID for the conversation
    :param kwargs data: the data of the message
    """

    #: number of characters seen in the repr output
    preview_length = 42

    def __init__(self, manager, conversation_id, **data):
        super().__init__(manager, **data)
        self.conversation_id = conversation_id

# Path: groupy/api/attachments.py
# class Attachment(base.Resource, metaclass=AttachmentMeta):
#     """Base attachment class.
# 
#     Every attachment has a type and additional data.
# 
#     :param str type: attachment type
#     :param kwargs data: additional attachment data
#     """
# 
#     def __init__(self, type, **data):
#         data['type'] = type
#         self.data = data
# 
#     def to_json(self):
#         """Return the attachment as JSON serializable dict.
# 
#         :return: serializable attachment data
#         :rtype: dict
#         """
#         return self.data
# 
#     @classmethod
#     def from_data(cls, type, **data):
#         """Create an attachment from data.
# 
#         :param str type: attachment type
#         :param kwargs data: additional attachment data
#         :return: an attachment subclass object
#         :rtype: `~groupy.api.attachments.Attachment`
#         """
#         try:
#             return cls._types[type](**data)
#         except KeyError:
#             return cls(type=type, **data)
#         except TypeError as e:
#             error = 'could not create {!r} attachment'.format(type)
#             raise TypeError('{}: {}'.format(error, e.args[0]))
# 
#     @classmethod
#     def from_bulk_data(cls, attachments):
#         """Create multiple attachments from a list of attachment data.
# 
#         :return: attachment sublcass objects
#         :rtype: :class:`list`
#         """
#         return [cls.from_data(**a) for a in attachments]
# 
# Path: groupy/utils.py
# def urljoin(base, path=None):
# def parse_share_url(share_url):
# def get_rfc3339(when):
# def get_datetime(timestamp):
#     def __init__(self, key, value):
#     def __repr__(self):
#     def __call__(self, obj):
#     def __init__(self, tests):
#     def __call__(self, objects):
#     def find(self, objects):
#     def passes(self, obj):
# def make_filter(**tests):
# class AttrTest:
# class Filter:
# 
# Path: groupy/pagers.py
# class Pager:
# class GroupList(Pager):
# class ChatList(GroupList):
# class MessageList(Pager):
# class GalleryList(MessageList):
#     def __init__(self, manager, endpoint, **params):
#     def __getitem__(self, index):
#     def __iter__(self):
#     def set_next_page_params(self):
#     def fetch(self):
#     def fetch_next(self):
#     def autopage(self):
#     def set_next_page_params(self):
#     def __init__(self, manager, endpoint, **params):
#     def detect_mode(cls, **params):
#     def set_next_page_params(self):
#     def get_last_item_index(self):
#     def get_next_page_param(self, item):
#     def fetch_next(self):
#     def get_next_page_param(self, item):


# Path: groupy/api/messages.py
import time
from . import base
from .attachments import Attachment
from groupy import utils
from groupy import pagers

            'source_guid': source_guid or str(time.time()),
            'recipient_id': self.other_user_id,
        }

        if text is not None:
            message['text'] = text

        if attachments is not None:
            message['attachments'] = [a.to_json() for a in attachments]

        payload = {'direct_message': message}
        response = self.session.post(self.url, json=payload)
        message = response.data['direct_message']
        return DirectMessage(self, **message)


class GenericMessage(base.ManagedResource):
    """A message.

    :param manager: a message manager
    :param str conversation_id: the ID for the conversation
    :param kwargs data: the data of the message
    """

    #: number of characters seen in the repr output
    preview_length = 42

    def __init__(self, manager, conversation_id, **data):
        super().__init__(manager, **data)
        self.conversation_id = conversation_id

        self.created_at = utils.get_datetime(self.data['created_at'])