# Path: flask_github/client/messages.py
# class Blob(msgs.Message):
#   content = msgs.BytesField(1)
#   encoding = msgs.StringField(2, default='utf-8')
#   sha = msgs.StringField(3)
#   size = msgs.IntegerField(4, default=0)
# 
# Path: flask_github/client/requests.py
# class BlobResponse(msgs.Message):
#   response = msgs.MessageField('Blob', 1)


from ..messages import Blob
from ..requests import BlobResponse

from __future__ import unicode_literals

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

  def get(self, repo, sha, user=None):
    return self.client.get(
      'repos/%s/%s/git/blobs/%s' % (
        self.client.user(user), repo, sha), msg_type=BlobResponse)

  def create(self, repo, content, encoding, user=None):
    msg = Blob(
      content=content,
      encoding=encoding)
    return self._create(repo=repo, user=user, msg=msg)

  def _create(self, repo, msg, user):
    return self.client.post(
      'repos/%s/%s/git/blobs' % (

# Path: flask_github/client/messages.py
# class Blob(msgs.Message):
#   content = msgs.BytesField(1)
#   encoding = msgs.StringField(2, default='utf-8')
#   sha = msgs.StringField(3)
#   size = msgs.IntegerField(4, default=0)
# 
# Path: flask_github/client/requests.py
# class BlobResponse(msgs.Message):
#   response = msgs.MessageField('Blob', 1)


# Path: flask_github/client/gitdata/gitdatablobs.py
from ..messages import Blob
from ..requests import BlobResponse

from __future__ import unicode_literals

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

  def get(self, repo, sha, user=None):
    return self.client.get(
      'repos/%s/%s/git/blobs/%s' % (
        self.client.user(user), repo, sha), msg_type=BlobResponse)

  def create(self, repo, content, encoding, user=None):
    msg = Blob(
      content=content,
      encoding=encoding)
    return self._create(repo=repo, user=user, msg=msg)

  def _create(self, repo, msg, user):
    return self.client.post(
      'repos/%s/%s/git/blobs' % (

        self.client.user(user), repo), data=msg, msg_type=BlobResponse)
