Completed
Push — master ( 3c61a8...5ea3bf )
by
unknown
02:27
created

ArticleCreate   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %
Metric Value
wmc 3
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 9 2
A _create_article() 0 9 1
1
from lib.actions import BaseAction
2
3
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