def post_to_sendinblue(self, payload, message): """Post payload to correct SendinBlue send API endpoint, and return the response. payload is a dict to use as SendinBlue send data return should be a requests.Response Can raise NotSerializableForSendinBlueError if payload is not serializable Can raise DJBlueAPIError for HTTP errors in the post """ msg = Mailin(self.api_url,self.api_key) if not getattr(message, 'template_id', False): payload.update({'text':message.body}) response,content = msg.send_email(payload) else: payload['to'] = payload['to'].keys()[0] response,content = msg.send_transactional_template(payload) # response = self.session.post(self.api_url, data=json_payload) if response.status != 200: raise DJBlueAPIError(email_message=message, payload=payload, response=response) return content