Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_messages(self, path=None, **params):
url = utils.urljoin(self.url, path)
response = self.session.get(url, params=params)
messages = response.data['messages']
return [Message(self, **message) for message in messages]
def _raw_list(self, **params):
response = self.session.get(self.url, params=params)
if response.status_code == 304:
return []
messages = response.data['messages']
return [Message(self, **message) for message in messages]
def create(self, text=None, attachments=None, source_guid=None):
message = {
'source_guid': source_guid or str(time.time()),
}
if text is not None:
message['text'] = text
if attachments is not None:
message['attachments'] = [a.to_json() for a in attachments]
payload = {'message': message}
response = self.session.post(self.url, json=payload)
message = response.data['message']
return Message(self, **message)