add: create project column card route (#1003)

Add the missing route to create cards for projects columns
Test written and passing locally.
This commit is contained in:
Benoit Latinier
2019-01-18 11:51:04 +08:00
committed by Wan Liuyang
parent 10bacb486a
commit 5f5c276465
4 changed files with 126 additions and 1 deletions
+33 -1
View File
@@ -30,6 +30,7 @@ import github.ProjectCard
import Consts
class ProjectColumn(github.GithubObject.CompletableGithubObject):
"""
This class represents Project Columns. The reference can be found here http://developer.github.com/v3/projects/columns
@@ -94,7 +95,7 @@ class ProjectColumn(github.GithubObject.CompletableGithubObject):
"""
return self._url.value
def get_cards(self,archived_state=github.GithubObject.NotSet):
def get_cards(self, archived_state=github.GithubObject.NotSet):
"""
:calls: `GET /projects/columns/:column_id/cards <https://developer.github.com/v3/projects/cards/#list-project-cards>`_
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ProjectCard.ProjectCard`
@@ -114,6 +115,37 @@ class ProjectColumn(github.GithubObject.CompletableGithubObject):
{"Accept": Consts.mediaTypeProjectsPreview}
)
def create_card(self, note=github.GithubObject.NotSet,
content_id=github.GithubObject.NotSet,
content_type=github.GithubObject.NotSet):
"""
calls: `POST https://developer.github.com/v3/projects/cards/#create-a-project-card>`_
:param note: string
:param content_id: integer
:param content_type: string
"""
post_parameters = {}
if isinstance(note, (str, unicode)):
assert content_id is github.GithubObject.NotSet, content_id
assert content_type is github.GithubObject.NotSet, content_type
post_parameters = {"note": note}
else:
assert note is github.GithubObject.NotSet, note
assert isinstance(content_id, int), content_id
assert isinstance(content_type, (str, unicode)), content_type
post_parameters = {"content_id": content_id,
"content_type": content_type}
import_header = {"Accept": Consts.mediaTypeProjectsPreview}
headers, data = self._requester.requestJsonAndCheck(
"POST",
self.url + "/cards",
headers=import_header,
input=post_parameters
)
return github.ProjectCard.ProjectCard(self._requester, headers,
data, completed=True)
def _initAttributes(self):
self._cards_url = github.GithubObject.NotSet
self._created_at = github.GithubObject.NotSet