Total Complexity | 2 |
Total Lines | 23 |
Duplicated Lines | 0 % |
1 | # From https://www.reamaze.com/api/post_messages |
||
7 | class CreateMessage(BaseAction): |
||
8 | VISIBILITY = { |
||
9 | 'internal': 1, |
||
10 | 'regular': 0, |
||
11 | } |
||
12 | |||
13 | def run(self, slug, message, visibility='internal', |
||
14 | suppress_notification=False): |
||
15 | |||
16 | payload = { |
||
17 | 'message': { |
||
18 | 'body': message, |
||
19 | 'visibility': CreateMessage.VISIBILITY[visibility] |
||
20 | } |
||
21 | } |
||
22 | |||
23 | if suppress_notification: |
||
24 | params['suppress_notificiaton'] = True |
||
25 | |||
26 | endpoint = '/conversations/{}/messages'.format(slug) |
||
27 | response = self._api_post(endpoint, json=payload) |
||
28 | |||
29 | return response |
||
30 |