diff options
| author | 2012-04-03 19:06:02 +0200 | |
|---|---|---|
| committer | 2012-04-03 19:06:02 +0200 | |
| commit | 30033cb33d828d96492c429407977a9f7912bf28 (patch) | |
| tree | 4b2804b3cc2391f19325dbe302b95a0c98a87b65 /pygithub3/services/gists | |
| parent | services.gists.Gist done (diff) | |
| download | python-github3-30033cb33d828d96492c429407977a9f7912bf28.tar.xz python-github3-30033cb33d828d96492c429407977a9f7912bf28.zip | |
services.gists.Comment done
Diffstat (limited to 'pygithub3/services/gists')
| -rw-r--r-- | pygithub3/services/gists/__init__.py | 2 | ||||
| -rw-r--r-- | pygithub3/services/gists/comments.py | 64 |
2 files changed, 66 insertions, 0 deletions
diff --git a/pygithub3/services/gists/__init__.py b/pygithub3/services/gists/__init__.py index b983fea..5fbfe7a 100644 --- a/pygithub3/services/gists/__init__.py +++ b/pygithub3/services/gists/__init__.py @@ -2,12 +2,14 @@ # -*- encoding: utf-8 -*- from pygithub3.services.base import Service +from comments import Comments class Gist(Service): """ Consume `Gists API <http://developer.github.com/v3/gists>`_ """ def __init__(self, **config): + self.comments = Comments(**config) super(Gist, self).__init__(**config) def list(self, user=None): diff --git a/pygithub3/services/gists/comments.py b/pygithub3/services/gists/comments.py new file mode 100644 index 0000000..397d583 --- /dev/null +++ b/pygithub3/services/gists/comments.py @@ -0,0 +1,64 @@ +#!/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 + """ + 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 + """ + request = self.request_builder('gists.comments.delete', id=id) + self._delete(request) |
