def send_notification(self, recipient: Recipient, document_name: str, document_file: bytes):
data = {
"name": "notification",
"to": {
"subscriberId": str(recipient.id),
"email": recipient.email,
"firstName": recipient.first_name,
"lastName": recipient.last_name
},
"payload": {
"document":{
"name": document_name,
},
"attachments": [
{
"file": document_file.decode('unicode_escape'),
"name": document_name,
"mime": 'application/octet-stream',
},
],
}
headers = {'Content-Type': 'application/json', 'Authorization': f'ApiKey {settings.NOVU_API_KEY}'}
response = requests.post(url=f"{settings.NOVU_API_URL}/v1/events/trigger", headers=headers, json=data)
def send_notification(self, recipient: Recipient, document_name: str, document_file: bytes):
data = {
"name": "notification",
"to": {
"subscriberId": str(recipient.id),
"email": recipient.email,
"firstName": recipient.first_name,
"lastName": recipient.last_name
},
"payload": {
"document":{
"name": document_name,
},
"attachments": [
{
"file": document_file.decode('unicode_escape'),
"name": document_name,
"mime": 'application/octet-stream',
},
],
}
headers = {'Content-Type': 'application/json', 'Authorization': f'ApiKey {settings.NOVU_API_KEY}'}
response = requests.post(url=f"{settings.NOVU_API_URL}/v1/events/trigger", headers=headers, json=data)