Completed
Pull Request — master (#331)
by James
03:12 queued 22s
created

CreateMessage   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %
Metric Value
dl 0
loc 23
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 17 2
1
# From https://www.reamaze.com/api/post_messages
2
3
from lib.actions import BaseAction
4
5
6
class CreateMessage(BaseAction):
7
    VISIBILITY = {
8
        'internal': 1,
9
        'regular': 0,
10
    }
11
12
    def run(self, slug, message, visibility='internal',
13
            suppress_notification=False):
14
15
        payload = {
16
            'message': {
17
                'body': message,
18
                'visibility': CreateMessage.VISIBILITY[visibility]
19
            }
20
        }
21
22
        if suppress_notification:
23
            payload['suppress_notificiaton'] = True
24
25
        endpoint = '/conversations/{}/messages'.format(slug)
26
        response = self._api_post(endpoint, json=payload)
27
28
        return response
29