def create_a_gist(self, file, description=None, public=None):
     file = file.to_json() if file else None
     data_content = {'files': file}
     if description:
         data_content['description'] = description
     if public is not None:
         data_content['public'] = public
     result = self._http_client.send_request(self.BASE_URL,
                                             Method.POST,
                                             data=json.dumps(data_content),
                                             headers=self._headers)
     return GistCustomResponse(result, Models.GIST)
 def get_latest_revision_of_gist_by_gist_id(self, gist_id, custom_sha=None):
     sha = ""
     if not custom_sha:
         sha = self.get_latest_commit_sha_by_gist_id(gist_id)
         if not sha:
             raise GistGeneralFunctionalityError(
                 'There is not a commits of this specific gist')
     else:
         sha = custom_sha
     revision_url = f'{self.BASE_URL}/{gist_id}/{sha}'
     result = self._http_client.send_request(revision_url,
                                             Method.GET,
                                             headers=self._headers)
     return GistCustomResponse(result, Models.GIST)
    def edit_a_gist_by_gist_id(self, gist_id, description=None, files=None):
        body = {}
        if files:
            body['files'] = files.to_json()

        if description is not None:
            body['description'] = description

        edit_url = f'{self.BASE_URL}/{gist_id}'
        result = self._http_client.send_request(edit_url,
                                                Method.PATCH,
                                                headers=self._headers,
                                                data=json.dumps(body))

        return GistCustomResponse(result, Models.GIST)
    def get_gists_list(self,
                       public=False,
                       since=None,
                       per_page=None,
                       page=None):
        headers = self._headers
        params = {}
        if public:
            headers = {}
        if page:
            params['page'] = page

        if per_page:
            params['per_page'] = per_page

        if since:
            params['since'] = since

        result = self._http_client.send_request(self.BASE_URL,
                                                Method.GET,
                                                headers=headers,
                                                params=params)
        return GistCustomResponse(result, Models.GIST)
 def get_all_starred_gists(self):
     star_url = f'{self.BASE_URL}/starred'
     result = self._http_client.send_request(star_url,
                                             Method.GET,
                                             headers=self._headers)
     return GistCustomResponse(result, Models.GIST)
 def star_a_gist_by_gist_id(self, gist_id):
     star_url = f'{self.BASE_URL}/{gist_id}/star'
     result = self._http_client.send_request(star_url,
                                             Method.PUT,
                                             headers=self._headers)
     return GistCustomResponse(result, None)
 def delete_a_gist_by_gist_id(self, gist_id):
     delete_url = f'{self.BASE_URL}/{gist_id}'
     result = self._http_client.send_request(delete_url,
                                             Method.DELETE,
                                             headers=self._headers)
     return GistCustomResponse(result, None)