Exemplo n.º 1
0
    def create_conversation(self, recipients, body, **kwargs):
        """
        Create a new Conversation.

        :calls: `POST /api/v1/conversations \
        <https://canvas.instructure.com/doc/api/conversations.html#method.conversations.create>`_

        :param recipients: An array of recipient ids.
            These may be user ids or course/group ids prefixed
            with 'course\\_' or 'group\\_' respectively,
            e.g. recipients=['1', '2', 'course_3']
        :type recipients: `list` of `str`
        :param body: The body of the message being added.
        :type body: `str`
        :rtype: list of :class:`canvasapi.conversation.Conversation`
        """
        from canvasapi.conversation import Conversation

        kwargs['recipients'] = recipients
        kwargs['body'] = body

        response = self.__requester.request('POST',
                                            'conversations',
                                            _kwargs=combine_kwargs(**kwargs))
        return [
            Conversation(self.__requester, convo) for convo in response.json()
        ]
Exemplo n.º 2
0
    def get_conversation(self, conversation_id, **kwargs):
        """
        Return single Conversation

        :calls: `GET /api/v1/conversations/:id \
        <https://canvas.instructure.com/doc/api/conversations.html#method.conversations.show>`_

        :param conversation_id: The ID of the conversation.
        :type conversation_id: `int`
        :rtype: :class:`canvasapi.conversation.Conversation`
        """
        from canvasapi.conversation import Conversation
        response = self.__requester.request(
            'GET', 'conversations/%s' % (conversation_id),
            **combine_kwargs(**kwargs))
        return Conversation(self.__requester, response.json())
Exemplo n.º 3
0
    def get_conversation(self, conversation, **kwargs):
        """
        Return single Conversation

        :calls: `GET /api/v1/conversations/:id \
        <https://canvas.instructure.com/doc/api/conversations.html#method.conversations.show>`_

        :param conversation: The object or ID of the conversation.
        :type conversation: :class:`canvasapi.conversation.Conversation` or int

        :rtype: :class:`canvasapi.conversation.Conversation`
        """
        from canvasapi.conversation import Conversation

        conversation_id = obj_or_id(conversation, "conversation",
                                    (Conversation, ))

        response = self.__requester.request(
            'GET',
            'conversations/{}'.format(conversation_id),
            _kwargs=combine_kwargs(**kwargs))
        return Conversation(self.__requester, response.json())