mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-08 00:28:26 -04:00
Remove the abstract ClientResponses class. Refactor aws_ses not to require the class.
All three client now use a response_map for the delivery receipt processing.
This commit is contained in:
@@ -1,33 +1,33 @@
|
||||
import boto3
|
||||
from flask import current_app
|
||||
from monotonic import monotonic
|
||||
from app.clients import ClientResponse, STATISTICS_DELIVERED, STATISTICS_FAILURE
|
||||
from app.clients import STATISTICS_DELIVERED, STATISTICS_FAILURE
|
||||
from app.clients.email import (EmailClientException, EmailClient)
|
||||
|
||||
ses_response_map = {
|
||||
'Bounce': {
|
||||
"message": 'Bounced',
|
||||
"success": False,
|
||||
"notification_status": 'bounce',
|
||||
"notification_statistics_status": STATISTICS_FAILURE
|
||||
},
|
||||
'Delivery': {
|
||||
"message": 'Delivered',
|
||||
"success": True,
|
||||
"notification_status": 'delivered',
|
||||
"notification_statistics_status": STATISTICS_DELIVERED
|
||||
},
|
||||
'Complaint': {
|
||||
"message": 'Complaint',
|
||||
"success": False,
|
||||
"notification_status": 'complaint',
|
||||
"notification_statistics_status": STATISTICS_FAILURE
|
||||
}
|
||||
}
|
||||
|
||||
class AwsSesResponses(ClientResponse):
|
||||
def __init__(self):
|
||||
ClientResponse.__init__(self)
|
||||
self.__response_model__ = {
|
||||
'Bounce': {
|
||||
"message": 'Bounced',
|
||||
"success": False,
|
||||
"notification_status": 'bounce',
|
||||
"notification_statistics_status": STATISTICS_FAILURE
|
||||
},
|
||||
'Delivery': {
|
||||
"message": 'Delivered',
|
||||
"success": True,
|
||||
"notification_status": 'delivered',
|
||||
"notification_statistics_status": STATISTICS_DELIVERED
|
||||
},
|
||||
'Complaint': {
|
||||
"message": 'Complaint',
|
||||
"success": False,
|
||||
"notification_status": 'complaint',
|
||||
"notification_statistics_status": STATISTICS_FAILURE
|
||||
}
|
||||
}
|
||||
|
||||
def get_aws_responses(status):
|
||||
return ses_response_map[status]
|
||||
|
||||
|
||||
class AwsSesClientException(EmailClientException):
|
||||
|
||||
Reference in New Issue
Block a user