How to use the groupy.utils function in groupy

To help you get started, we’ve selected a few groupy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rhgrant10 / Groupy / tests / test_utils.py View on Github external
def test_result_is_base_when_no_path(self):
        self.assertEqual(utils.urljoin(self.url), self.url)
github rhgrant10 / Groupy / groupy / managers.py View on Github external
def _get_messages(self, path=None, **params):
        url = utils.urljoin(self.url, path)
        response = self.session.get(url, params=params)
        messages = response.data['messages']
        return [Message(self, **message) for message in messages]
github rhgrant10 / Groupy / groupy / api / memberships.py View on Github external
def check(self, results_id):
        """Check for results of a membership request.

        :param str results_id: the ID of a membership request
        :return: successfully created memberships
        :rtype: :class:`list`
        :raises groupy.exceptions.ResultsNotReady: if the results are not ready
        :raises groupy.exceptions.ResultsExpired: if the results have expired
        """
        path = 'results/{}'.format(results_id)
        url = utils.urljoin(self.url, path)
        response = self.session.get(url)
        if response.status_code == 503:
            raise exceptions.ResultsNotReady(response)
        if response.status_code == 404:
            raise exceptions.ResultsExpired(response)
        return response.data['members']
github rhgrant10 / Groupy / groupy / api / bots.py View on Github external
def post(self, bot_id, text, attachments=None):
        """Post a new message as a bot to its room.

        :param str bot_id: the ID of the bot
        :param str text: the text of the message
        :param attachments: a list of attachments
        :type attachments: :class:`list`
        :return: ``True`` if successful
        :rtype: bool
        """
        url = utils.urljoin(self.url, 'post')
        payload = dict(bot_id=bot_id, text=text)

        if attachments:
            payload['attachments'] = [a.to_json() for a in attachments]

        response = self.session.post(url, json=payload)
        return response.ok
github rhgrant10 / Groupy / groupy / api / base.py View on Github external
def __init__(self, session, path=None):
        self.session = session
        self.url = utils.urljoin(self.base_url, path)
github rhgrant10 / Groupy / groupy / api / groups.py View on Github external
def list_former(self):
        """List all former groups.

        :return: a list of groups
        :rtype: :class:`list`
        """
        url = utils.urljoin(self.url, 'former')
        response = self.session.get(url)
        return [Group(self, **group) for group in response.data]
github rhgrant10 / Groupy / groupy / pagers.py View on Github external
def get_next_page_param(self, item):
        return utils.get_rfc3339(item.created_at)
github rhgrant10 / Groupy / groupy / api / images.py View on Github external
def upload(self, fp):
        url = utils.urljoin(self.url, 'pictures')
        response = self.session.post(url, files={'file': fp})
        image_urls = response.data['payload']
        return image_urls