|
1 | 1 | # -*- coding: utf-8 -*-
|
2 |
| -from ..models import GitHubCore |
| 2 | +"""This module contains the logic for GitHub's import issue API.""" |
| 3 | +from .. import models |
3 | 4 |
|
4 | 5 |
|
5 |
| -""" |
6 |
| -github3.repos.issue_import |
7 |
| -========================== |
| 6 | +class ImportedIssue(models.GitHubCore): |
| 7 | + """Represents an issue imported via the unofficial API. |
8 | 8 |
|
9 |
| -This module contains the ImportedIssue object for Github's import issue API |
| 9 | + See also: https://gist.github.com/jonmagic/5282384165e0f86ef105 |
10 | 10 |
|
11 |
| -""" |
| 11 | + This object has the following attributes: |
12 | 12 |
|
| 13 | + .. attribute:: created_at |
13 | 14 |
|
14 |
| -class ImportedIssue(GitHubCore): |
15 |
| - """ |
16 |
| - The :class:`ImportedIssue <ImportedIssue>` object. This represents |
17 |
| - information from the Import Issue API. |
| 15 | + A :class:`~datetime.datetime` object representing the date and time |
| 16 | + when this imported issue was created. |
18 | 17 |
|
19 |
| - See also: https://gist.github.com/jonmagic/5282384165e0f86ef105 |
| 18 | + .. attribute:: id |
| 19 | +
|
| 20 | + The globally unique identifier for this imported issue. |
| 21 | +
|
| 22 | + .. attribute:: import_issues_url |
| 23 | +
|
| 24 | + The URL used to import more issues via the API. |
| 25 | +
|
| 26 | + .. attribute:: repository_url |
| 27 | +
|
| 28 | + The URL used to retrieve the repository via the API. |
| 29 | +
|
| 30 | + .. attribute:: status |
| 31 | +
|
| 32 | + The status of this imported issue. |
| 33 | +
|
| 34 | + .. attribute:: updated_at |
| 35 | +
|
| 36 | + A :class:`~datetime.datetime` object representing te date and time |
| 37 | + when this imported issue was last updated. |
20 | 38 | """
|
21 | 39 |
|
22 | 40 | IMPORT_CUSTOM_HEADERS = {
|
23 | 41 | 'Accept': 'application/vnd.github.golden-comet-preview+json'
|
24 | 42 | }
|
25 | 43 |
|
26 | 44 | def _update_attributes(self, issue):
|
27 |
| - self.id = self._get_attribute(issue, 'id') |
28 |
| - |
29 |
| - self.status = self._get_attribute(issue, 'status') |
30 |
| - |
31 |
| - self.url = self._get_attribute(issue, 'url') |
32 |
| - |
33 |
| - # Since created_at and updated_at returns slightly different format |
34 |
| - # we can't use self._strptime |
35 |
| - # For example, repo correctly returns '2015-04-15T03:40:51Z' |
36 |
| - # For ImportedIssue, the format is '2016-01-14T10:57:56-08:00' |
37 |
| - self.created_at = self._get_attribute(issue, 'created_at') |
38 |
| - self.updated_at = self._get_attribute(issue, 'updated_at') |
39 |
| - self.import_issues_url = self._get_attribute( |
40 |
| - issue, 'import_issues_url' |
41 |
| - ) |
42 |
| - self.repository_url = self._get_attribute(issue, 'repository_url') |
| 45 | + self._api = issue['url'] |
| 46 | + self.created_at = self._strptime(issue['created_at']) |
| 47 | + self.id = issue['id'] |
| 48 | + self.import_issues_url = issue['import_issues_url'] |
| 49 | + self.repository_url = issue['repository_url'] |
| 50 | + self.status = issue['status'] |
| 51 | + self.updated_at = self._strptime(issue['updated_at']) |
0 commit comments