Merge pull request #242 from alphagov/mmg-client-fix

Update to processing the the response from MMG
This commit is contained in:
Rebecca Law
2016-04-20 11:27:37 +01:00
6 changed files with 52 additions and 13 deletions

View File

@@ -12,6 +12,12 @@ mmg_response_map = {
"success": True,
"notification_status": 'delivered'
},
'0': {
"message": 'Delivered',
"notification_statistics_status": STATISTICS_DELIVERED,
"success": True,
"notification_status": 'delivered'
},
'default': {
"message": 'Declined',
"success": False,

View File

@@ -12,7 +12,7 @@ sms_response_mapper = {'MMG': get_mmg_responses,
def validate_callback_data(data, fields, client_name):
errors = []
for f in fields:
if len(data.get(f, '')) <= 0:
if not str(data.get(f, '')):
error = "{} callback failed: {} missing".format(client_name, f)
errors.append(error)
return errors if len(errors) > 0 else None

View File

@@ -147,7 +147,7 @@ def process_mmg_response():
[current_app.logger.info(e) for e in validation_errors]
return jsonify(result='error', message=validation_errors), 400
success, errors = process_sms_client_response(status=data.get('status'),
success, errors = process_sms_client_response(status=str(data.get('status')),
reference=data.get('CID'),
client_name='MMG')
if errors: