| Total Complexity | 2 |
| Total Lines | 23 |
| Duplicated Lines | 0 % |
| 1 | # From https://www.reamaze.com/api/post_messages |
||
| 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 |