# Path: flask_github/client/messages.py
# class Commit(msgs.Message):
#   url = msgs.StringField(1)
#   sha = msgs.StringField(2)
#   committer = msgs.MessageField('User', 3)
#   author = msgs.MessageField('User', 4)
#   comment_count = msgs.IntegerField(5, default=0)
#   message = msgs.StringField(6)
#   # string reference allows for recursion..
#   tree = msgs.MessageField('Commit', 7)
#   parents = msgs.MessageField('Commit', 8, repeated=True)
#   # fields that live on the tree api responses..
#   path = msgs.StringField(9)
#   mode = msgs.StringField(10)
#   type = msgs.StringField(11)
#   size = msgs.IntegerField(12, default=0)
#   # fields for the hooks payload..
#   id = msgs.StringField(13)
#   timestamp = msgs.StringField(14)
#   added = msgs.StringField(15, repeated=True)
#   removed = msgs.StringField(16, repeated=True)
#   modified = msgs.StringField(17, repeated=True)
#   commit = msgs.MessageField('Commit', 18)
# 
# Path: flask_github/client/requests.py
# class CommitResponse(msgs.Message):
#   response = msgs.MessageField('Commit', 1)
# 
# Path: flask_github/client/requests.py
# class CommitListResponse(msgs.Message):
#   response = msgs.MessageField('Commit', 1, repeated=True)
# 
# Path: flask_github/client/requests.py
# class CommentResponse(msgs.Message):
#   response = msgs.MessageField('Comment', 1)
# 
# Path: flask_github/client/requests.py
# class CommentListResponse(msgs.Message):
#   response = msgs.MessageField('Comment', 1, repeated=True)


from ..messages import Commit
from ..requests import CommitResponse
from ..requests import CommitListResponse
from ..requests import CommentResponse
from ..requests import CommentListResponse

  # comments..

  def list_comments(self, repo, sha=None, user=None):
    url = 'repos/%s/%s/comments' % (
      self.client.user(user), repo)
    if sha:
      url = 'repos/%s/%s/commits/%s/comments' % (
        self.client.user(user), repo, sha)
    return self.client.get(url, msg_type=CommentListResponse)

  def create_comment(self, repo, sha, body, line, path, position, user=None):
    msg = Commit(
      body=body,
      commit_id=sha,
      line=line,
      path=path,
      position=position)
    return self._create_comment(repo=repo, sha=sha, msg=msg, user=user)

  def _create_comment(self, repo, sha, msg, user=None):
    return self.client.post(
      'repos/%s/%s/commits/%s/comments' % (
        self.client.user(user), repo, sha), data=msg)

  def get_comment(self, repo, id, user=None):
    return self.client.get(
      'repos/%s/%s/comment/%s' % (
        self.client.user(user), repo, id), msg_type=CommentResponse)

  def update_comment(self, repo, id, body, user=None):

# Path: flask_github/client/messages.py
# class Commit(msgs.Message):
#   url = msgs.StringField(1)
#   sha = msgs.StringField(2)
#   committer = msgs.MessageField('User', 3)
#   author = msgs.MessageField('User', 4)
#   comment_count = msgs.IntegerField(5, default=0)
#   message = msgs.StringField(6)
#   # string reference allows for recursion..
#   tree = msgs.MessageField('Commit', 7)
#   parents = msgs.MessageField('Commit', 8, repeated=True)
#   # fields that live on the tree api responses..
#   path = msgs.StringField(9)
#   mode = msgs.StringField(10)
#   type = msgs.StringField(11)
#   size = msgs.IntegerField(12, default=0)
#   # fields for the hooks payload..
#   id = msgs.StringField(13)
#   timestamp = msgs.StringField(14)
#   added = msgs.StringField(15, repeated=True)
#   removed = msgs.StringField(16, repeated=True)
#   modified = msgs.StringField(17, repeated=True)
#   commit = msgs.MessageField('Commit', 18)
# 
# Path: flask_github/client/requests.py
# class CommitResponse(msgs.Message):
#   response = msgs.MessageField('Commit', 1)
# 
# Path: flask_github/client/requests.py
# class CommitListResponse(msgs.Message):
#   response = msgs.MessageField('Commit', 1, repeated=True)
# 
# Path: flask_github/client/requests.py
# class CommentResponse(msgs.Message):
#   response = msgs.MessageField('Comment', 1)
# 
# Path: flask_github/client/requests.py
# class CommentListResponse(msgs.Message):
#   response = msgs.MessageField('Comment', 1, repeated=True)


# Path: flask_github/client/repos/reposcommits.py
from ..messages import Commit
from ..requests import CommitResponse
from ..requests import CommitListResponse
from ..requests import CommentResponse
from ..requests import CommentListResponse

  # comments..

  def list_comments(self, repo, sha=None, user=None):
    url = 'repos/%s/%s/comments' % (
      self.client.user(user), repo)
    if sha:
      url = 'repos/%s/%s/commits/%s/comments' % (
        self.client.user(user), repo, sha)
    return self.client.get(url, msg_type=CommentListResponse)

  def create_comment(self, repo, sha, body, line, path, position, user=None):
    msg = Commit(
      body=body,
      commit_id=sha,
      line=line,
      path=path,
      position=position)
    return self._create_comment(repo=repo, sha=sha, msg=msg, user=user)

  def _create_comment(self, repo, sha, msg, user=None):
    return self.client.post(
      'repos/%s/%s/commits/%s/comments' % (
        self.client.user(user), repo, sha), data=msg)

  def get_comment(self, repo, id, user=None):
    return self.client.get(
      'repos/%s/%s/comment/%s' % (
        self.client.user(user), repo, id), msg_type=CommentResponse)

  def update_comment(self, repo, id, body, user=None):

    msg = Commit(
