aboutsummaryrefslogtreecommitdiffstats
path: root/pygithub3/services/gists/comments.py
blob: 7f4955fe857c61f56fe101181d0ed6c2a4fe32d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from pygithub3.services.base import Service, MimeTypeMixin


class Comments(Service, MimeTypeMixin):
    """ Consume `Comments API
    <http://developer.github.com/v3/gists/comments>`_

    .. note::
        This service support :ref:`mimetypes-section` configuration
    """

    def list(self, gist_id):
        """ Get gist's comments

        :param int gist_id: Gist id
        :returns: A :doc:`result`
        """
        request = self.request_builder('gists.comments.list', gist_id=gist_id)
        return self._get_result(request, **self._get_mimetype_as_header())

    def get(self, id):
        """ Get a single comment

        :param int id: Comment id
        """
        request = self.request_builder('gists.comments.get', id=id)
        return self._get(request, **self._get_mimetype_as_header())

    def create(self, gist_id, message):
        """ Create a comment

        :param int gist_id: Gist id
        :param str message: Comment's message

        .. warning::
            You must be authenticated

        ::

            comment_service.create(1, 'comment')
        """
        request = self.request_builder('gists.comments.create',
            gist_id=gist_id, body={'body': message})
        return self._post(request, **self._get_mimetype_as_header())

    def update(self, id, message):
        """ Update a comment

        :param int id: Comment id
        :param str message: Comment's message

        .. warning::
            You must be authenticated
        """
        request = self.request_builder('gists.comments.update', id=id,
            body={'body': message})
        return self._patch(request, **self._get_mimetype_as_header())

    def delete(self, id):
        """ Delete a comment

        :param int id: Comment id

        .. warning::
            You must be authenticated
        """
        request = self.request_builder('gists.comments.delete', id=id)
        self._delete(request)