Add internation api key for firetext.

We want to start using Firetext for sending international SMS. They
require us to use a different API key for international SMS because it
requires a new code path to switch the sender ID to something that the
country will accept.
This PR does not include switching the sender of international SMS to
Firetext but sets us up to do so.
This commit is contained in:
Rebecca Law
2021-03-16 14:53:42 +00:00
parent f2167aae2b
commit f3fdd3b09b
9 changed files with 66 additions and 29 deletions

View File

@@ -66,6 +66,7 @@ class FiretextClient(SmsClient):
super(SmsClient, self).__init__(*args, **kwargs)
self.current_app = current_app
self.api_key = current_app.config.get('FIRETEXT_API_KEY')
self.international_api_key = current_app.config.get('FIRETEXT_INTERNATIONAL_API_KEY')
self.from_number = current_app.config.get('FROM_NUMBER')
self.name = 'firetext'
self.url = current_app.config.get('FIRETEXT_URL')
@@ -91,10 +92,9 @@ class FiretextClient(SmsClient):
self.statsd_client.incr("clients.firetext.error")
self.current_app.logger.warning(log_message)
def send_sms(self, to, content, reference, sender=None):
def send_sms(self, to, content, reference, international, sender=None):
data = {
"apiKey": self.api_key,
"apiKey": self.international_api_key if international else self.api_key,
"from": self.from_number if sender is None else sender,
"to": to.replace('+', ''),
"message": content,

View File

@@ -97,7 +97,7 @@ class MMGClient(SmsClient):
def get_name(self):
return self.name
def send_sms(self, to, content, reference, multi=True, sender=None):
def send_sms(self, to, content, reference, international, multi=True, sender=None):
data = {
"reqType": "BULK",
"MSISDN": to,

View File

@@ -99,6 +99,7 @@ class Config(object):
# Firetext API Key
FIRETEXT_API_KEY = os.getenv("FIRETEXT_API_KEY")
FIRETEXT_INTERNATIONAL_API_KEY = os.getenv("FIRETEXT_INTERNATIONAL_API_KEY", "placeholder")
# Prefix to identify queues in SQS
NOTIFICATION_QUEUE_PREFIX = os.getenv('NOTIFICATION_QUEUE_PREFIX')

View File

@@ -68,7 +68,8 @@ def send_sms_to_provider(notification):
to=notification.normalised_to,
content=str(template),
reference=str(notification.id),
sender=notification.reply_to_text
sender=notification.reply_to_text,
international=notification.international
)
except Exception as e:
notification.billable_units = template.fragment_count