# -*- coding: utf-8 -*-

from django.http import JsonResponse

from utils.error.errno_utils import StatusCodeField


def response_data(status_code, message=None, description=None, data={}):
    return {
        'status': status_code,
        'message': message,
        'description': description,
        'data': data,
    }


def response(status_code, message=None, description=None, data={}):
    message, description = (status_code.message, status_code.description) if isinstance(status_code, StatusCodeField) else (message, description)
    return JsonResponse(response_data(status_code, message, description, data), safe=False)
