19 lines
632 B
Python
19 lines
632 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
|
|
)
|
|
return message.status
|