How to use the groupy.utils.urljoin 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 / groupy / api / groups.py View on Github external
def rejoin(self, group_id):
        """Rejoin a former group.

        :param str group_id: the group_id of a group
        :return: the group
        :rtype: :class:`~groupy.api.groups.Group`
        """
        url = utils.urljoin(self.url, 'join')
        payload = {'group_id': group_id}
        response = self.session.post(url, json=payload)
        return Group(self, **response.data)
github rhgrant10 / Groupy / groupy / api / messages.py View on Github external
def unlike(self):
        """Unlike the message."""
        url = utils.urljoin(self.url, 'unlike')
        response = self.session.post(url)
        return response.ok
github rhgrant10 / Groupy / groupy / managers.py View on Github external
def like(self):
        url = utils.urljoin(self.url, 'like')
        response = self.session.post(url)
        return response.ok
github rhgrant10 / Groupy / groupy / api / memberships.py View on Github external
def add_multiple(self, *users):
        """Add multiple users to the group at once.

        Each given user must be a dictionary containing a nickname and either
        an email, phone number, or user_id.

        :param args users: the users to add
        :return: a membership request
        :rtype: :class:`MembershipRequest`
        """
        guid = uuid.uuid4()
        for i, user_ in enumerate(users):
            user_['guid'] = '{}-{}'.format(guid, i)

        payload = {'members': users}
        url = utils.urljoin(self.url, 'add')
        response = self.session.post(url, json=payload)
        return MembershipRequest(self, *users, group_id=self.group_id,
                                 **response.data)
github rhgrant10 / Groupy / groupy / managers.py View on Github external
def check(self, results_id):
        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 / messages.py View on Github external
def like(self):
        """Like the message."""
        url = utils.urljoin(self.url, 'like')
        response = self.session.post(url)
        return response.ok
github rhgrant10 / Groupy / groupy / api / groups.py View on Github external
def change_owners(self, group_id, owner_id):
        """Change the owner of a group.

        .. note:: you must be the owner to change owners

        :param str group_id: the group_id of a group
        :param str owner_id: the ID of the new owner
        :return: the result
        :rtype: :class:`~groupy.api.groups.ChangeOwnersResult`
        """
        url = utils.urljoin(self.url, 'change_owners')
        payload = {
            'requests': [{
                'group_id': group_id,
                'owner_id': owner_id,
            }],
        }
        response = self.session.post(url, json=payload)
        result, = response.data['results']  # should be exactly one
        return ChangeOwnersResult(**result)