DRY-up overriding shortcode with sender

This avoids duplicating the logic when we add a new provider.
This commit is contained in:
Ben Thorner
2022-03-25 13:26:16 +00:00
parent 3b082477f0
commit 27ddc4501e
6 changed files with 39 additions and 52 deletions

View File

@@ -23,6 +23,7 @@ class SmsClient(Client):
def init_app(self, current_app, statsd_client):
self.current_app = current_app
self.statsd_client = statsd_client
self.from_number = self.current_app.config.get('FROM_NUMBER')
def record_outcome(self, success):
log_message = "Provider request for {} {}".format(
@@ -39,6 +40,7 @@ class SmsClient(Client):
def send_sms(self, to, content, reference, international, sender=None):
start_time = monotonic()
sender = self.from_number if sender is None else sender
try:
response = self.try_send_sms(to, content, reference, international, sender)