From a423c22a02c85ea16ae42c1b5a0a0a365eccd61c Mon Sep 17 00:00:00 2001 From: Antti Kaihola Date: Mon, 7 Nov 2011 14:38:32 +0200 Subject: _post_resource --- github3/api.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'github3') diff --git a/github3/api.py b/github3/api.py index 81ae3e7..78f87b3 100644 --- a/github3/api.py +++ b/github3/api.py @@ -105,6 +105,11 @@ class GithubCore(object): return msg + def _post_resource(self, resource, obj, data, **kwargs): + r = self._http_resource('POST', resource, data=data, params=kwargs) + item = self._resource_deserialize(r.content) + + return obj.new_from_dict(item, gh=self) @staticmethod def _total_pages_from_header(link_header): -- cgit v1.2.3-59-g8ed1b From 6d7b6547d48c66c607a2e674034cef662a08e2f7 Mon Sep 17 00:00:00 2001 From: Antti Kaihola Date: Mon, 7 Nov 2011 14:38:55 +0200 Subject: Added the create_gist() method --- github3/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'github3') diff --git a/github3/models.py b/github3/models.py index 3c86687..8c4f9ba 100644 --- a/github3/models.py +++ b/github3/models.py @@ -113,6 +113,14 @@ class User(BaseResource): def gists(self): return self._gh._get_resources(('users', self.login, 'gists'), Gist) + def create_gist(self, description, public=True, files={}): + data = {'description': description, + 'public': public, + 'files': files} + deploy = json.dumps(data) + return self._gh._post_resource(('users', self.login, 'gists'), Gist, deploy) + + class CurrentUser(User): """Github Current User object model.""" -- cgit v1.2.3-59-g8ed1b