Simplify getting name of email / sms providers

Previously we used a combination of "provider.name" and "get_name()"
which was confusing. Using a non-property function also gave me the
impression that the name was more dynamic than it actually is.
This commit is contained in:
Ben Thorner
2022-03-24 17:31:53 +00:00
parent eef4868651
commit e6e16a81d0
8 changed files with 22 additions and 20 deletions

View File

@@ -21,5 +21,6 @@ class SmsClient(Client):
def send_sms(self, *args, **kwargs):
raise NotImplementedError('TODO Need to implement.')
def get_name(self):
@property
def name(self):
raise NotImplementedError('TODO Need to implement.')

View File

@@ -68,12 +68,12 @@ class FiretextClient(SmsClient):
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')
self.statsd_client = statsd_client
def get_name(self):
return self.name
@property
def name(self):
return 'firetext'
def record_outcome(self, success, response):
status_code = response.status_code if response else 503

View File

@@ -74,7 +74,6 @@ class MMGClient(SmsClient):
self.current_app = current_app
self.api_key = current_app.config.get('MMG_API_KEY')
self.from_number = current_app.config.get('FROM_NUMBER')
self.name = 'mmg'
self.statsd_client = statsd_client
self.mmg_url = current_app.config.get('MMG_URL')
@@ -94,8 +93,9 @@ class MMGClient(SmsClient):
self.statsd_client.incr("clients.mmg.error")
self.current_app.logger.warning(log_message)
def get_name(self):
return self.name
@property
def name(self):
return 'mmg'
def send_sms(self, to, content, reference, international, multi=True, sender=None):
data = {