def get_response(data):
    message = data.get('text')
    if data.get('code') == SMS_API_ERROR:
        success = False
        message = None
    elif data.get('code') != SMS_SUBMISSION_ACCEPTED:
        success = True
        message = _(u"[ERROR] %s") % message
    else:
        success = True

    response = {
        "payload": {
            "success": success,
            "task": "send"}}

    if message:
        messages = [{"to": data.get('identity'), "message": message}]
        sendouts = data.get('sendouts', [])
        if len(sendouts):
            messages += [{"to": data.get('identity'), "message": text}
                         for text in sendouts]
        response['payload'].update({"messages": messages})
    return HttpResponse(json.dumps(response), content_type='application/json')
dataset/ETHPy150Open kobotoolbox/kobocat/onadata/apps/sms_support/providers/smssync.py/get_response/original