# Path: ratechecker/views.py
# class RateCheckerStatus(APIView):
#     def get(self, request, format=None):
#         try:
#             load_ts = Region.objects.latest("data_timestamp").data_timestamp
#         except Region.DoesNotExist:
#             load_ts = None
# 
#         return Response({"load": load_ts})
# 
# @api_view(["GET"])
# def rate_checker(request):
#     """
#     Return available rates in percentage and number of institutions
#     with the corresponding rate
#     (i.e. "4.75": 2 means there are 2 institutions with the rate of 4.75%)
#     """
# 
#     if request.method == "GET":
# 
#         # Clean the parameters, make sure no leading or trailing spaces,
#         # transform them to upper cases
#         fixed_data = {
#             k: v.strip().upper() for k, v in request.query_params.items()
#         }  # noqa
#         fixed_data = set_lock_max_min(fixed_data)
#         serializer = ParamsSerializer(data=fixed_data)
# 
#         if serializer.is_valid():
#             rate_results = get_rates(serializer.validated_data)
#             rate_results["request"] = serializer.validated_data
#             return Response(rate_results)
#         else:
#             return Response(
#                 serializer.errors, status=status.HTTP_400_BAD_REQUEST
#             )


from ratechecker.views import RateCheckerStatus, rate_checker
    from django.urls import re_path
    from django.conf.urls import url as re_path


try:
except ImportError:


urlpatterns = [
    re_path(r"rate-checker$", rate_checker, name="rate-checker"),
    re_path(
        r"rate-checker/status$",
        RateCheckerStatus.as_view(),
        name="rate-checker-status",

# Path: ratechecker/views.py
# class RateCheckerStatus(APIView):
#     def get(self, request, format=None):
#         try:
#             load_ts = Region.objects.latest("data_timestamp").data_timestamp
#         except Region.DoesNotExist:
#             load_ts = None
# 
#         return Response({"load": load_ts})
# 
# @api_view(["GET"])
# def rate_checker(request):
#     """
#     Return available rates in percentage and number of institutions
#     with the corresponding rate
#     (i.e. "4.75": 2 means there are 2 institutions with the rate of 4.75%)
#     """
# 
#     if request.method == "GET":
# 
#         # Clean the parameters, make sure no leading or trailing spaces,
#         # transform them to upper cases
#         fixed_data = {
#             k: v.strip().upper() for k, v in request.query_params.items()
#         }  # noqa
#         fixed_data = set_lock_max_min(fixed_data)
#         serializer = ParamsSerializer(data=fixed_data)
# 
#         if serializer.is_valid():
#             rate_results = get_rates(serializer.validated_data)
#             rate_results["request"] = serializer.validated_data
#             return Response(rate_results)
#         else:
#             return Response(
#                 serializer.errors, status=status.HTTP_400_BAD_REQUEST
#             )


# Path: ratechecker/urls.py
from ratechecker.views import RateCheckerStatus, rate_checker
    from django.urls import re_path
    from django.conf.urls import url as re_path



try:
except ImportError:


urlpatterns = [
    re_path(r"rate-checker$", rate_checker, name="rate-checker"),
    re_path(
        r"rate-checker/status$",
        RateCheckerStatus.as_view(),
        name="rate-checker-status",

    ),