def _validate_configure_twilio(self):
"""configure twilio client
we will provide to ways to configure clients :
- One, you can configure twilio keys from environment variables if not,
- Then Second, you ca send keys as function arguments too,
- Priority wil be given to function arguments
:return: twilio client instance
"""
if self.account_sid is None:
self.account_sid = getattr(settings, 'TWILIO_ACCOUNT_SID', None)
if self.auth_token is None:
self.auth_token = getattr(settings, 'TWILIO_AUTH_TOKEN', None)
if self.account_sid is None or self.auth_token is None:
raise RuntimeWarning(
'to send sms via {0} you need to configure TWILIO_ACCOUNT_SID & TWILIO_AUTH_TOKEN in \n'
'environment variables or send account_sid & auth_token as function arguments.'.format(self.name)
)
self.twilio_client = TwilioRestClient(self.account_sid, self.auth_token)
评论列表
文章目录