# Path: api/serializers/request_serializers.py
# class GetReminderRequest(TokenSerializer):
#     pass
# 
# class UpdateReminderRequest(TokenSerializer):
#     field = serializers.CharField(max_length=16)
#     value = serializers.BooleanField()
# 
# Path: api/utils.py
# def invalid_data_response(request_serializer):
#     """
#     Returns the error message depending on missing/invalid data in serializer.
#     """
#     return Response({'detail': request_serializer.errors,
#                      'data': {}}, status=status.HTTP_400_BAD_REQUEST)
# 
# def validate_api_secret_key(secret_key):
#     """
#     Checks if request received from known origin Application. If not returns 404 (not found) status
#     """
#     if secret_key != settings.API_SECRET_KEY:
#         logger.info('Incorrect API key: "{}"'.format(secret_key))
#         raise Http404('The API key isn\t correct!')
# 
# Path: app/models.py
# class TheUser(models.Model):
#     """
#     Class for user objects in database.
#     """
#     REMINDER_TEMPLATE = json.dumps({
#         "common": {
#             "fb_page": True,
#             "fb_group": True,
#             "twitter": True,
#             "vk": True,
#             "disabled_all": False
#         },
#         "api": {
#             "app_rate": True
#         },
#         "web": {
#             "app_download": True,
#         },
#     })
# 
#     id_user = models.OneToOneField(User)
#     user_photo = models.ImageField(blank=True, upload_to='user', storage=OverwriteStorage())
#     auth_token = models.CharField(max_length=50, null=True, blank=True)
#     subscription = models.BooleanField(default=True)
#     reminder = models.CharField(max_length=256, null=False, default=REMINDER_TEMPLATE)
# 
#     # ------------------------------------------------------------------------------------------------------------------
#     def __str__(self):
#         return str(self.id_user)
# 
#     # ------------------------------------------------------------------------------------------------------------------
#     def get_api_reminders(self):
#         """
#         Returns the reminders only necessary for API endpoints.
#         """
#         data = json.loads(self.reminder)
# 
#         mobile_data = dict(data['common'])
#         mobile_data.update(data['api'])
# 
#         return mobile_data
# 
#     # ------------------------------------------------------------------------------------------------------------------
#     def get_web_reminders(self):
#         """
#         Returns the reminders only necessary for web part.
#         """
#         data = json.loads(self.reminder)
#         
#         web_data = dict(data['common'])
#         web_data.update(data['web'])
# 
#         return web_data
# 
#     # ------------------------------------------------------------------------------------------------------------------
#     def update_reminder(self, field, value):
#         """
#         Updates the reminder status.
#         """
#         data = json.loads(self.reminder)
# 
#         for key in data:
#             if field in data[key]:
#                 data[key][field] = value
# 
#         self.reminder = json.dumps(data)
#         self.save()


from django.shortcuts import get_object_or_404
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
from ..serializers.request_serializers import GetReminderRequest, UpdateReminderRequest
from ..utils import invalid_data_response, validate_api_secret_key
from app.models import TheUser
# -*- coding: utf-8 -*-





# ----------------------------------------------------------------------------------------------------------------------
@api_view(['POST'])
def get_reminders(request):
    """
    Returns the reminders status.
    """
    validate_api_secret_key(request.data.get('app_key'))


# Path: api/serializers/request_serializers.py
# class GetReminderRequest(TokenSerializer):
#     pass
# 
# class UpdateReminderRequest(TokenSerializer):
#     field = serializers.CharField(max_length=16)
#     value = serializers.BooleanField()
# 
# Path: api/utils.py
# def invalid_data_response(request_serializer):
#     """
#     Returns the error message depending on missing/invalid data in serializer.
#     """
#     return Response({'detail': request_serializer.errors,
#                      'data': {}}, status=status.HTTP_400_BAD_REQUEST)
# 
# def validate_api_secret_key(secret_key):
#     """
#     Checks if request received from known origin Application. If not returns 404 (not found) status
#     """
#     if secret_key != settings.API_SECRET_KEY:
#         logger.info('Incorrect API key: "{}"'.format(secret_key))
#         raise Http404('The API key isn\t correct!')
# 
# Path: app/models.py
# class TheUser(models.Model):
#     """
#     Class for user objects in database.
#     """
#     REMINDER_TEMPLATE = json.dumps({
#         "common": {
#             "fb_page": True,
#             "fb_group": True,
#             "twitter": True,
#             "vk": True,
#             "disabled_all": False
#         },
#         "api": {
#             "app_rate": True
#         },
#         "web": {
#             "app_download": True,
#         },
#     })
# 
#     id_user = models.OneToOneField(User)
#     user_photo = models.ImageField(blank=True, upload_to='user', storage=OverwriteStorage())
#     auth_token = models.CharField(max_length=50, null=True, blank=True)
#     subscription = models.BooleanField(default=True)
#     reminder = models.CharField(max_length=256, null=False, default=REMINDER_TEMPLATE)
# 
#     # ------------------------------------------------------------------------------------------------------------------
#     def __str__(self):
#         return str(self.id_user)
# 
#     # ------------------------------------------------------------------------------------------------------------------
#     def get_api_reminders(self):
#         """
#         Returns the reminders only necessary for API endpoints.
#         """
#         data = json.loads(self.reminder)
# 
#         mobile_data = dict(data['common'])
#         mobile_data.update(data['api'])
# 
#         return mobile_data
# 
#     # ------------------------------------------------------------------------------------------------------------------
#     def get_web_reminders(self):
#         """
#         Returns the reminders only necessary for web part.
#         """
#         data = json.loads(self.reminder)
#         
#         web_data = dict(data['common'])
#         web_data.update(data['web'])
# 
#         return web_data
# 
#     # ------------------------------------------------------------------------------------------------------------------
#     def update_reminder(self, field, value):
#         """
#         Updates the reminder status.
#         """
#         data = json.loads(self.reminder)
# 
#         for key in data:
#             if field in data[key]:
#                 data[key][field] = value
# 
#         self.reminder = json.dumps(data)
#         self.save()


# Path: api/views/reminder_views.py
from django.shortcuts import get_object_or_404
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
from ..serializers.request_serializers import GetReminderRequest, UpdateReminderRequest
from ..utils import invalid_data_response, validate_api_secret_key
from app.models import TheUser

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





# ----------------------------------------------------------------------------------------------------------------------
@api_view(['POST'])
def get_reminders(request):
    """
    Returns the reminders status.
    """
    validate_api_secret_key(request.data.get('app_key'))


    request_serializer = GetReminderRequest(data=request.data)