This commit is contained in:
Rebecca Law
2016-04-05 14:39:59 +01:00
parent 3820090a19
commit f2ee8f3eb7
4 changed files with 17 additions and 18 deletions

View File

@@ -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)

View File

@@ -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']

View File

@@ -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