Update to processing the the response from MMG

MMG changed the datatype and the status codes they send us for the delivery receipts.
This PR accounts for that change.
This commit is contained in:
Rebecca Law
2016-04-20 09:45:13 +01:00
parent 6ef8bb5ada
commit 41ce691704
6 changed files with 47 additions and 11 deletions

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: