import requests from django.conf import settings class NotificationClient(): def notify(self, phone_number, body): data = { 'phone_number': phone_number, 'body': body } # data = json.dumps(data) header = { # "Content-Type": "application/json", "charset": "utf-8" } header.setdefault("Authorization", f"Bearer {settings.ACCESS_TOKEN}", ) response = requests.request('post', f'{settings.NOTIFICATIONS_SERVICE_URL}/notifications/', headers=header, json=data) try: return response.json() except: return response.text notification_client = NotificationClient()