mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:26:08 -05:00
Added base object for response statuses, and tests around it's behaviour
This commit is contained in:
@@ -6,58 +6,34 @@ from app.clients.sms import (
|
||||
)
|
||||
from flask import current_app
|
||||
from requests import request, RequestException, HTTPError
|
||||
from app.clients import ClientResponse
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
firetext_response_status = {
|
||||
'0': {
|
||||
"firetext_message": 'delivered',
|
||||
"success": True,
|
||||
"notify_status": 'delivered'
|
||||
},
|
||||
'1': {
|
||||
"firetext_message": 'declined',
|
||||
"success": False,
|
||||
"notify_status": 'failed'
|
||||
},
|
||||
'2': {
|
||||
"firetext_message": 'Undelivered (Pending with Network)',
|
||||
"success": False,
|
||||
"notify_status": 'sent'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class FiretextResponses:
|
||||
response_model = {
|
||||
'0': {
|
||||
"firetext_message": 'delivered',
|
||||
"stats_mapping": 'delivered',
|
||||
"success": True,
|
||||
"notify_status": 'delivered'
|
||||
},
|
||||
'1': {
|
||||
"firetext_message": 'declined',
|
||||
"success": False,
|
||||
"stats_mapping": 'failure',
|
||||
"notify_status": 'failed'
|
||||
},
|
||||
'2': {
|
||||
"firetext_message": 'Undelivered (Pending with Network)',
|
||||
"success": False,
|
||||
"stats_mapping": None,
|
||||
"notify_status": 'sent'
|
||||
class FiretextResponses(ClientResponse):
|
||||
def __init__(self):
|
||||
ClientResponse.__init__(self)
|
||||
self.__response_model__ = {
|
||||
'0': {
|
||||
"message": 'Delivered',
|
||||
"notification_statistics_status": 'delivered',
|
||||
"success": True,
|
||||
"notification_status": 'delivered'
|
||||
},
|
||||
'1': {
|
||||
"message": 'Declined',
|
||||
"success": False,
|
||||
"notification_statistics_status": 'failed',
|
||||
"notification_status": 'failed'
|
||||
},
|
||||
'2': {
|
||||
"message": 'Undelivered (Pending with Network)',
|
||||
"success": False,
|
||||
"notification_statistics_status": None,
|
||||
"notification_status": 'sent'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def response_code_to_message(self, response_code):
|
||||
return self.response_model.get(response_code)['firetext_message']
|
||||
|
||||
def response_code_to_notify_status(self, response_code):
|
||||
return self.response_model.get(response_code)['notify_status']
|
||||
|
||||
def response_code_to_notify_stats(self, response_code):
|
||||
return self.response_model.get(response_code)['stats_mapping']
|
||||
|
||||
|
||||
class FiretextClientException(SmsClientException):
|
||||
|
||||
Reference in New Issue
Block a user