mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-27 19:01:32 -05:00
- when a provider callback occurs and we update the status of the notification, also update the statistics table Adds: - Mapping object to the clients to handle mapping to various states from the response codes, this replaces the map. - query lookup in the DAO to get the query based on response type / template type Tests around rest class and dao to check correct updating of stats Missing: - multiple client callbacks will keep incrementing the counts of success/failure. This edge case needs to be handle in a future story.
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
|
|
class ClientException(Exception):
|
|
'''
|
|
Base Exceptions for sending notifications that fail
|
|
'''
|
|
pass
|
|
|
|
|
|
class Client(object):
|
|
'''
|
|
Base client for sending notifications.
|
|
'''
|
|
pass
|
|
|
|
|
|
STATISTICS_REQUESTED = 'requested'
|
|
STATISTICS_DELIVERED = 'delivered'
|
|
STATISTICS_FAILURE = 'failure'
|
|
|
|
|
|
class ClientResponse:
|
|
def __init__(self):
|
|
self.__response_model__ = None
|
|
|
|
def response_code_to_object(self, response_code):
|
|
return self.__response_model__[response_code]
|
|
|
|
def response_code_to_message(self, response_code):
|
|
return self.response_code_to_object(response_code)['message']
|
|
|
|
def response_code_to_notification_status(self, response_code):
|
|
return self.response_code_to_object(response_code)['notification_status']
|
|
|
|
def response_code_to_notification_statistics_status(self, response_code):
|
|
return self.response_code_to_object(response_code)['notification_statistics_status']
|
|
|
|
def response_code_to_notification_success(self, response_code):
|
|
return self.response_code_to_object(response_code)['success']
|