How to use the groupy.api.endpoint 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_endpoint.py View on Github external
def test_nonstring_path_converted_to_string(self):
        url = endpoint.Endpoint.build_url(list())
        path = urlsplit(url).path
        self.assertEqual(path, '/[]')
github rhgrant10 / Groupy / tests / test_endpoint.py View on Github external
def test_users_me(self):
        self.assert_url_correct(
            responses.GET,
            'https://api.groupme.com/v3/users/me',
            endpoint.Users.me
        )
github rhgrant10 / Groupy / tests / test_endpoint.py View on Github external
def test_multiple_message_ids_raises_ValueError(self):
        with self.assertRaises(ValueError):
            endpoint.Messages.index(1, before_id='10', after_id='5')
github rhgrant10 / Groupy / tests / test_endpoint.py View on Github external
def test_direct_messages_index(self):
        self.assert_url_correct(
            responses.GET,
            'https://api.groupme.com/v3/direct_messages',
            endpoint.DirectMessages.index,
            other_user_id='1',
            before_id='2',
            since_id='3',
            after_id='4'
        )
github rhgrant10 / Groupy / tests / test_endpoint.py View on Github external
def test_likes_destroy(self):
        self.assert_url_correct(
            responses.POST,
            'https://api.groupme.com/v3/messages/1/2/unlike',
            endpoint.Likes.destroy, '1', '2'
        )
github rhgrant10 / Groupy / groupy / object / responses.py View on Github external
def post(self, text, *attachments, picture_url=None):
        """Post a message to the group of the bot.

        :param str text: the message text
        :param str picture_url: the GroupMe image URL for an image
        :param list attachments: the attachments to include
        :returns: ``True`` if successful
        :rtype: bool
        :raises groupy.api.errors.ApiError: if unsuccessful
        """
        try:
            endpoint.Bots.post(self.bot_id, text, *attachments, picture_url=picture_url)
        except errors.ApiError as e:
            if e.args[0].status_code >= status.BAD_REQUEST:
                raise
        return True
github rhgrant10 / Groupy / groupy / object / responses.py View on Github external
def refresh(self):
        """Refresh the group information from the API.
        """
        self.__init__(**endpoint.Groups.show(self.id))
github rhgrant10 / Groupy / groupy / object / responses.py View on Github external
def __init__(self, **kwargs):
        super().__init__(endpoint.DirectMessages, 'direct_messages',
                         'user_id', **kwargs)
        self.id = kwargs.get('id')
        self.user_id = kwargs.get('user_id')
        self.nickname = kwargs.get('nickname')
        self.muted = kwargs.get('muted')
        self.image_url = kwargs.get('image_url')
        self.autokicked = kwargs.get('autokicked')
        self.app_installed = kwargs.get('app_installed')
        self.guid = kwargs.get('guid', None)
        self.message_count = None
github rhgrant10 / Groupy / groupy / object / attachments.py View on Github external
def download(self):
        """Download the image data of the image attachment.
        
        :returns: the actual image the image attachment references
        :rtype: :class:`PIL.Image.Image`
        """
        return endpoint.Images.download(self.url)
github rhgrant10 / Groupy / groupy / object / responses.py View on Github external
def __init__(self, **kwargs):
        messages = kwargs.pop('messages', {})
        members = kwargs.pop('members')
        super().__init__(endpoint.Messages, 'messages', 'id', **kwargs)

        self.id = kwargs.get('id')
        self.group_id = kwargs.get('group_id')
        self.name = kwargs.get('name')
        self.type = kwargs.get('type')
        self.description = kwargs.get('description')
        self.image_url = kwargs.get('image_url')
        self.creator_user_id = kwargs.get('creator_user_id')
        self.created_at = datetime.fromtimestamp(kwargs.get('created_at'))
        self.updated_at = datetime.fromtimestamp(kwargs.get('updated_at'))
        ca = messages.get('last_message_created_at')
        if ca is not None and ca >= 0:
            self.last_message_created_at = datetime.fromtimestamp(ca)
            self.last_message_id = messages.get('last_message_id')
        else:
            self.last_message_created_at = None