2020-04-13 10:08:59 +00:00
|
|
|
from typing import Union
|
|
|
|
|
|
|
|
class SMSNotSent(Exception):
|
|
|
|
'''SMS providers must raise SMSNotSent if an SMS was reported as not sent by the gateway.'''
|
|
|
|
|
|
|
|
class BaseSMSProvider:
|
|
|
|
'''SMS providers must be subclasses of BaseSMSProvider and implement at least is_active and sendSMS().'''
|
|
|
|
|
|
|
|
@property
|
|
|
|
def get_name(self):
|
|
|
|
return "Base SMS Provider"
|
|
|
|
|
|
|
|
@property
|
|
|
|
def get_logo(self):
|
|
|
|
return ""
|
|
|
|
|
|
|
|
@property
|
|
|
|
def is_active(self):
|
|
|
|
'''Returns True if the provider is properly configured and ready to use.'''
|
|
|
|
raise NotImplementedError(f"{type(self)} does not implement is_active!")
|
|
|
|
|
|
|
|
@property
|
|
|
|
def get_edit_url(self):
|
2020-05-23 09:12:48 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
@property
|
|
|
|
def get_balance(self):
|
|
|
|
return False
|
2020-04-13 10:08:59 +00:00
|
|
|
|
|
|
|
def sendSMS(self, recipients: Union[str, list], message: str):
|
|
|
|
'''Send an SMS message to one or more recipients
|
|
|
|
|
|
|
|
:param recipients: Recipient phone number as a string, or a list of multiple phone number strings
|
|
|
|
:param message: Message to be sent as a string
|
|
|
|
'''
|
|
|
|
|
|
|
|
raise NotImplementedError(f"{type(self)} does not implement sendSMS()!")
|