Total Complexity | 3 |
Total Lines | 20 |
Duplicated Lines | 0 % |
1 | from lib.actions import BaseAction |
||
4 | class ArticleCreate(BaseAction): |
||
5 | def run(self, title, body, topic=None, status=0): |
||
6 | if topic: |
||
7 | topic = self._convert_slug(topic) |
||
8 | path = '/topics/%s/articles' % topic |
||
9 | else: |
||
10 | path = '/articles' |
||
11 | payload = self._create_article(title=title, body=body, status=status) |
||
12 | response = self._api_post(path, json=payload) |
||
13 | return response |
||
14 | |||
15 | def _create_article(self, title, body, status=0): |
||
16 | payload = { |
||
17 | 'article': { |
||
18 | 'title': title, |
||
19 | 'body': body, |
||
20 | 'status': int(status) |
||
21 | } |
||
22 | } |
||
23 | return payload |
||
24 |