freeleaps-service-hub/app/notification/backend/infra/sms_handler.py

20 lines
674 B
Python

from app.notification.common.config.app_settings import app_settings
from twilio.http.async_http_client import AsyncTwilioHttpClient
from twilio.rest import Client
class SmsHandler:
def __init__(self) -> None:
self.twillo_client = Client(
app_settings.TWILIO_ACCOUNT_SID,
app_settings.TWILIO_AUTH_TOKEN,
http_client=AsyncTwilioHttpClient(),
)
async def send_sms(self, sender: str, receiver: str, message: str):
message = await self.twillo_client.messages.create_async(
to=receiver, from_=sender, body=message
)
print("this is message", message)
return message.status