Completed
Pull Request — master (#331)
by James
03:06
created

CreateMessage.run()   A

Complexity

Conditions 2

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 17
rs 9.4286
1
# From https://www.reamaze.com/api/post_messages
2
3
from lib.actions import BaseAction
4
import json
5
6
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