Add boilerplate for Reach SMS callbacks

This is enough to update a notification in DB:

1. First create a notification in the UI and sent it.

2. Then reset its attributes to pretend it's for Reach.

    update notifications set
      sent_at = null,
      sent_by = null,
      notification_status='sending'
    where id='some-uuid';

3. Change "notification_id" to "<some-uuid>" in the code.

4. Call the boilerplate endpoint for Reach callbacks.

    curl -X POST localhost:6011/notifications/sms/reach

Interestingly there's no foreign key constraint on "sent_by" in the
DB, so this just works: the notification is updated.
This commit is contained in:
Ben Thorner
2022-03-24 16:41:08 +00:00
parent a962721915
commit b439fd0718
7 changed files with 83 additions and 5 deletions

25
app/clients/sms/reach.py Normal file
View File

@@ -0,0 +1,25 @@
from app.clients.sms import SmsClient, SmsClientResponseException
def get_reach_responses(status, detailed_status_code=None):
if status == 'TODO-d':
return ("delivered", "TODO: Delivered")
elif status == 'TODO-tf':
return ("temporary-failure", "TODO: Temporary failure")
elif status == 'TODO-pf':
return ("permanent-failure", "TODO: Permanent failure")
else:
raise KeyError
class ReachClientResponseException(SmsClientResponseException):
pass # TODO (custom exception for errors)
class ReachClient(SmsClient):
def get_name(self):
pass # TODO
def send_sms(self, to, content, reference, international, multi=True, sender=None):
pass # TODO