# Path: flask_github/client/messages.py
# class Gist(msgs.Message):
#   '''
#   {
#   "files": {
#     "ring.erl": {
#       "size": 932,
#       "filename": "ring.erl",
#       "raw_url": "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl"
#     }
#   }
#   "history": [
#     {
#       "url": "https://api.github.com/gists/14a2302d4083e5331759",
#       "version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
#       "user": {
#         "login": "octocat",
#         "id": 1,
#         "avatar_url": "https://github.com/images/error/octocat_happy.gif",
#         "gravatar_id": "somehexcode",
#         "url": "https://api.github.com/users/octocat"
#       },
#       "change_status": {
#         "deletions": 0,
#         "additions": 180,
#         "total": 180
#       },
#       "committed_at": "2010-04-14T02:15:15Z"
#     }
#   ]
#   '''
#   id = msgs.IntegerField(1, default=0)
#   url = msgs.StringField(2)
#   description = msgs.StringField(3)
#   public = msgs.BooleanField(4, default=True)
#   user = msgs.MessageField('User', 5)
#   comments = msgs.IntegerField(6, default=0)
#   comments_url = msgs.StringField(7)
#   html_url = msgs.StringField(8)
#   git_pull_url = msgs.StringField(9)
#   git_push_url = msgs.StringField(10)
#   created_at = msgs.StringField(11)
#   forks = msgs.MessageField('Gist', 12, repeated=True)
# 
# Path: flask_github/client/requests.py
# class GistResponse(msgs.Message):
#   response = msgs.MessageField('Gist', 1)
# 
# Path: flask_github/client/requests.py
# class GistListResponse(msgs.Message):
#   response = msgs.MessageField('Gist', 1, repeated=True)


from ..messages import Gist
from ..requests import GistResponse
from ..requests import GistListResponse

from __future__ import unicode_literals

class Gists:
  def __init__(self, client):
    self.client = client

  def list(self, user=None):
    url = 'users/%s/gists' % user if user else 'gists'
    return self.client.get(url, msg_type=GistListResponse)

  def list_public(self):
    return self.client.get('gists/public', msg_type=GistListResponse)

  def list_starred(self):

# Path: flask_github/client/messages.py
# class Gist(msgs.Message):
#   '''
#   {
#   "files": {
#     "ring.erl": {
#       "size": 932,
#       "filename": "ring.erl",
#       "raw_url": "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl"
#     }
#   }
#   "history": [
#     {
#       "url": "https://api.github.com/gists/14a2302d4083e5331759",
#       "version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
#       "user": {
#         "login": "octocat",
#         "id": 1,
#         "avatar_url": "https://github.com/images/error/octocat_happy.gif",
#         "gravatar_id": "somehexcode",
#         "url": "https://api.github.com/users/octocat"
#       },
#       "change_status": {
#         "deletions": 0,
#         "additions": 180,
#         "total": 180
#       },
#       "committed_at": "2010-04-14T02:15:15Z"
#     }
#   ]
#   '''
#   id = msgs.IntegerField(1, default=0)
#   url = msgs.StringField(2)
#   description = msgs.StringField(3)
#   public = msgs.BooleanField(4, default=True)
#   user = msgs.MessageField('User', 5)
#   comments = msgs.IntegerField(6, default=0)
#   comments_url = msgs.StringField(7)
#   html_url = msgs.StringField(8)
#   git_pull_url = msgs.StringField(9)
#   git_push_url = msgs.StringField(10)
#   created_at = msgs.StringField(11)
#   forks = msgs.MessageField('Gist', 12, repeated=True)
# 
# Path: flask_github/client/requests.py
# class GistResponse(msgs.Message):
#   response = msgs.MessageField('Gist', 1)
# 
# Path: flask_github/client/requests.py
# class GistListResponse(msgs.Message):
#   response = msgs.MessageField('Gist', 1, repeated=True)


# Path: flask_github/client/gists/gists.py
from ..messages import Gist
from ..requests import GistResponse
from ..requests import GistListResponse

from __future__ import unicode_literals

class Gists:
  def __init__(self, client):
    self.client = client

  def list(self, user=None):
    url = 'users/%s/gists' % user if user else 'gists'
    return self.client.get(url, msg_type=GistListResponse)

  def list_public(self):
    return self.client.get('gists/public', msg_type=GistListResponse)

  def list_starred(self):

    return self.client.get('gists/starred', msg_type=GistListResponse)
