26 lines
1.1 KiB
Python
26 lines
1.1 KiB
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):
|
|
|
|
service_client = Client(
|
|
client_id=settings.CLIENT_ID,
|
|
client_secret=settings.CLIENT_SECRET,
|
|
grant_type=AccountsClient.GRANT_CLIENT_CREDENTIALS
|
|
)
|
|
service_client.login(scopes=['notification.notification:submit'])
|
|
service_client.notification.submit_notification(phone_number=phone_number,
|
|
title=title,
|
|
body=body,
|
|
user_uuid=user_uuid,
|
|
notification_type=notification_type,
|
|
email=email
|
|
)
|