Completed
Pull Request — master (#331)
by James
03:06
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
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