Commit fe09c84e authored by test's avatar test

GitHubIssue: Add create method to create new issue

Closes #24
parent 1864f5ea
Pipeline #8787114 passed with stage
in 4 minutes and 28 seconds
......@@ -283,3 +283,31 @@ class GitHubIssue(Issue):
:return: Either 'open' or 'closed'.
return self._data['state']
def create(token: str, repository: str,
title: str, body: str):
Create a new issue with given title and body.
>>> from os import environ
>>> issue = GitHubIssue.create(environ['GITHUB_TEST_TOKEN'],
... 'gitmate-test-user/test',
... 'test issue title',
... 'sample description')
>>> issue.state
:return: GitHubIssue object of the newly created issue.
post_url = '/repos/' + repository + '/issues'
data = {
"title": title,
"body": body,
resp = post(token, post_url, data)
issue_number = resp['number']
return GitHubIssue(token, repository, issue_number)
......@@ -146,3 +146,10 @@ class Issue:
Retrieves a timestamp on when the comment was updated the last time.
raise NotImplementedError
def create(token, repository, title, body):
Create a new issue in repository.
raise NotImplementedError
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment