wallet/apps/users/tasks.py
2020-11-01 23:54:09 +03:30

23 lines
875 B
Python

from celery import shared_task
from django.conf import settings
from service_clients import Client, AccountsClient
@shared_task
def send_notification(phone_number=None,
title=None,
body=None,
user_uuid=None,
email=None,
notification_type=1):
SCOPES = ['notifications.notification:submit']
client = Client(client_id=settings.CLIENT_ID,
client_secret=settings.CLIENT_SECRET,
scopes=SCOPES,
grant_type=AccountsClient.GRANT_CLIENT_CREDENTIALS)
data = {
'phone_number': phone_number,
"body": f'{title}:\n{body}'
}
print(client.request(required_scopes=SCOPES, url=f'{settings.BASE_NOTIFICATION_URL}/notifications/', data=data,
method='post').text)