mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
WIP
This commit is contained in:
@@ -9,6 +9,8 @@ from requests import request, RequestException, HTTPError
|
||||
from app.clients import ClientResponse, STATISTICS_DELIVERED, STATISTICS_FAILURE
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FiretextResponses(ClientResponse):
|
||||
def __init__(self):
|
||||
ClientResponse.__init__(self)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from flask import current_app
|
||||
from monotonic import monotonic
|
||||
from requests import (request, RequestException, HTTPError)
|
||||
|
||||
from app.clients import (ClientResponse, STATISTICS_DELIVERED, STATISTICS_FAILURE)
|
||||
from app.clients.sms import (SmsClient, SmsClientException)
|
||||
|
||||
@@ -31,7 +30,6 @@ class FiretextResponses(ClientResponse):
|
||||
}
|
||||
|
||||
|
||||
|
||||
class MMGClientException(SmsClientException):
|
||||
def __init__(self, error_response):
|
||||
self.code = error_response['Error']
|
||||
|
||||
@@ -145,8 +145,6 @@ def is_not_a_notification(source):
|
||||
|
||||
@notifications.route('/notifications/sms/mmg', methods=['POST'])
|
||||
def process_mmg_response():
|
||||
print('here')
|
||||
current_app.logger.info('MMG client callback json{}'.format(request.json))
|
||||
current_app.logger.info('MMG client callback form{}'.format(request.form))
|
||||
status, error1 = _get_from_response(form=request.form, field='status', client_name='MMG')
|
||||
reference, error2 = _get_from_response(form=request.form, field='reference', client_name='MMG')
|
||||
@@ -154,7 +152,6 @@ def process_mmg_response():
|
||||
errors.remove(None)
|
||||
if len(errors) > 0:
|
||||
return jsonify(result='error', message=errors), 400
|
||||
|
||||
if reference == 'send-sms-code':
|
||||
return jsonify(result="success", message="MMG callback succeeded: send-sms-code"), 200
|
||||
|
||||
@@ -163,10 +160,10 @@ def _get_from_response(form, field, client_name):
|
||||
error = None
|
||||
form_field = None
|
||||
if len(form.get(field, '')) <= 0:
|
||||
print(
|
||||
current_app.logger.info(
|
||||
"{} callback failed: {} missing".format(client_name, field)
|
||||
)
|
||||
error="{} callback failed: {} missing".format(client_name, field)
|
||||
error = "{} callback failed: {} missing".format(client_name, field)
|
||||
else:
|
||||
form_field = form[field]
|
||||
return form_field, error
|
||||
@@ -177,7 +174,8 @@ def process_firetext_response():
|
||||
status, error1 = _get_from_response(form=request.form, field='status', client_name='Firetext')
|
||||
reference, error2 = _get_from_response(form=request.form, field='reference', client_name='Firetext')
|
||||
errors = [error1, error2]
|
||||
errors = errors.filter(None)
|
||||
errors = errors.remove(None)
|
||||
|
||||
if len(errors) > 0:
|
||||
return jsonify(result='error', message=errors), 400
|
||||
|
||||
|
||||
Reference in New Issue
Block a user