# 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:


from . import base
from groupy import utils
class LinkedImage(Image):
    pass


class Images(base.Manager):
    """A manager for handling image uploads/downloads."""

    #: the base url for the pictures API
    base_url = 'https://image.groupme.com/'

    def from_file(self, fp):
        """Create a new image attachment from an image file.

        :param file fp: a file object containing binary image data
        :return: an image attachment
        :rtype: :class:`~groupy.api.attachments.Image`
        """
        image_urls = self.upload(fp)
        return Image(image_urls['url'], source_url=image_urls['picture_url'])

    def upload(self, fp):
        """Upload image data to the image service.

        Call this, rather than :func:`from_file`, you don't want to
        create an attachment of the image.

        :param file fp: a file object containing binary image data
        :return: the URLs for the image uploaded
        :rtype: dict
        """

# 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/api/attachments.py
from . import base
from groupy import utils

class LinkedImage(Image):
    pass


class Images(base.Manager):
    """A manager for handling image uploads/downloads."""

    #: the base url for the pictures API
    base_url = 'https://image.groupme.com/'

    def from_file(self, fp):
        """Create a new image attachment from an image file.

        :param file fp: a file object containing binary image data
        :return: an image attachment
        :rtype: :class:`~groupy.api.attachments.Image`
        """
        image_urls = self.upload(fp)
        return Image(image_urls['url'], source_url=image_urls['picture_url'])

    def upload(self, fp):
        """Upload image data to the image service.

        Call this, rather than :func:`from_file`, you don't want to
        create an attachment of the image.

        :param file fp: a file object containing binary image data
        :return: the URLs for the image uploaded
        :rtype: dict
        """

        url = utils.urljoin(self.url, 'pictures')