Exemple #1
0
 def delete(self, request):
     """
 This function will check out a shop assistant from a store.
 """
     response = rh.checkout(request)
     if response == c.UNAUTHORIZED:
         return Response(cr.CeesResponse().getCeesResponse(1, 2, ''),
                         status=status.HTTP_401_UNAUTHORIZED)
     elif response == c.INTERNAL_SERVER_ERROR:
         return Response(cr.CeesResponse().getCeesResponse(1, 3, ''),
                         status=status.HTTP_500_INTERNAL_SERVER_ERROR)
     return Response(cr.CeesResponse().getCeesResponse(0, 0, ''),
                     status=status.HTTP_200_OK)
Exemple #2
0
 def delete(self, request):
     """
 Logout. This will delete token from database.
 """
     response = rh.logout(request)
     if response == c.UNAUTHORIZED:
         return Response(cr.CeesResponse().getCeesResponse(1, 2, ''),
                         status=status.HTTP_401_UNAUTHORIZED)
     elif response == c.INTERNAL_SERVER_ERROR:
         return Response(cr.CeesResponse().getCeesResponse(1, 3, ''),
                         status=status.HTTP_500_INTERNAL_SERVER_ERROR
                         )  # Database error. Returns HTTP 500.
     return Response(cr.CeesResponse().getCeesResponse(0, 0, ''),
                     status=status.HTTP_200_OK)  # Ok. Returns HTTP 200.
Exemple #3
0
 def get(self, request):
     """
 Gives back the projectId from a given license.
 """
     (response, projectId) = rh.getProjectId(request)
     if response == c.UNAUTHORIZED:
         return Response(cr.CeesResponse().getCeesResponse(1, 2, ''),
                         status=status.HTTP_401_UNAUTHORIZED)
     elif response == c.INTERNAL_SERVER_ERROR:
         return Response(cr.CeesResponse().getCeesResponse(1, 3, ''),
                         status=status.HTTP_500_INTERNAL_SERVER_ERROR)
     return Response(cr.CeesResponse().getCeesResponse(
         0, 0, str(projectId)),
                     status=status.HTTP_200_OK)
Exemple #4
0
 def get(self, request):
     """
 Gets the available stores (city and address) for a given shop assistant.
 """
     (response, stores) = rh.getStores(request)
     if response == c.UNAUTHORIZED:
         return Response(cr.CeesResponse().getCeesResponse(1, 2, ''),
                         status=status.HTTP_401_UNAUTHORIZED)
     elif response == c.INTERNAL_SERVER_ERROR:
         return Response(cr.CeesResponse().getCeesResponse(1, 3, ''),
                         status=status.HTTP_500_INTERNAL_SERVER_ERROR)
     elif response == c.NOT_FOUND:
         return Response(cr.CeesResponse().getCeesResponse(1, 4, ''),
                         status=status.HTTP_404_NOT_FOUND)
     return Response(cr.CeesResponse().getCeesResponse(0, 0, stores),
                     status=status.HTTP_200_OK)
Exemple #5
0
 def get(self, request):
     """
 Get the list of awaiting clients.
 """
     (response, clients) = rh.getArrivalsInfo(request)
     if response == c.UNAUTHORIZED:
         return Response(cr.CeesResponse().getCeesResponse(1, 2, ''),
                         status=status.HTTP_401_UNAUTHORIZED)
     elif response == c.INTERNAL_SERVER_ERROR:
         return Response(cr.CeesResponse().getCeesResponse(1, 3, ''),
                         status=status.HTTP_500_INTERNAL_SERVER_ERROR)
     elif response == c.NOT_FOUND:
         return Response(cr.CeesResponse().getCeesResponse(1, 4, ''),
                         status=status.HTTP_404_NOT_FOUND)
     return Response(cr.CeesResponse().getCeesResponse(0, 0, clients),
                     status=status.HTTP_200_OK)
Exemple #6
0
 def post(self, request):
     """
 Checkin shop assistant. Checks the authentication header and the city and address provided in the payload.
 """
     response = rh.checkin(request)
     if response == c.UNAUTHORIZED:
         return Response(cr.CeesResponse().getCeesResponse(1, 2, ''),
                         status=status.HTTP_401_UNAUTHORIZED)
     elif response == c.BAD_REQUEST:
         return Response(cr.CeesResponse().getCeesResponse(1, 1, ''),
                         status=status.HTTP_400_BAD_REQUEST)
     elif response == c.INTERNAL_SERVER_ERROR:
         return Response(cr.CeesResponse().getCeesResponse(1, 3, ''),
                         status=status.HTTP_500_INTERNAL_SERVER_ERROR)
     elif response == c.NOT_FOUND:
         return Response(cr.CeesResponse().getCeesResponse(1, 4, ''),
                         status=status.HTTP_404_NOT_FOUND)
     return Response(
         cr.CeesResponse().getCeesResponse(0, 0, ''),
         status=status.HTTP_201_CREATED)  # Checkin persisted. HTTP 201.
Exemple #7
0
 def post(self, request):
     """
 Creates a new registration in database.
 """
     response = rh.saveRegId(request)
     if response == c.UNAUTHORIZED:
         return Response(cr.CeesResponse().getCeesResponse(1, 2, ''),
                         status=status.HTTP_401_UNAUTHORIZED)
     elif response == c.BAD_REQUEST:
         return Response(cr.CeesResponse().getCeesResponse(1, 1, ''),
                         status=status.HTTP_400_BAD_REQUEST
                         )  # Validation Error. Returns HTTP 400.
     elif response == c.NOT_FOUND:
         return Response(cr.CeesResponse().getCeesResponse(1, 4, ''),
                         status=status.HTTP_404_NOT_FOUND)
     elif response == c.INTERNAL_SERVER_ERROR:
         return Response(cr.CeesResponse().getCeesResponse(1, 3, ''),
                         status=status.HTTP_500_INTERNAL_SERVER_ERROR)
     return Response(cr.CeesResponse().getCeesResponse(0, 0, ''),
                     status=status.HTTP_201_CREATED)
Exemple #8
0
 def post(self, request):
     """
 Store a new arrival with the incoming request from detection system.
 """
     response = rh.newArrival(request)
     if response == c.BAD_REQUEST:
         return Response(cr.CeesResponse().getCeesResponse(1, 1, ''),
                         status=status.HTTP_400_BAD_REQUEST
                         )  # Validation Error. Returns HTTP 400.
     elif response == c.NOT_FOUND:
         return Response(cr.CeesResponse().getCeesResponse(1, 4, ''),
                         status=status.HTTP_404_NOT_FOUND)
     elif response == c.FORBBIDEN:
         return Response(cr.CeesResponse().getCeesResponse(1, 2, ''),
                         status=status.HTTP_403_FORBIDDEN)
     elif response == c.INTERNAL_SERVER_ERROR:
         return Response(cr.CeesResponse().getCeesResponse(1, 3, ''),
                         status=status.HTTP_500_INTERNAL_SERVER_ERROR)
     return Response(cr.CeesResponse().getCeesResponse(0, 0, ''),
                     status=status.HTTP_201_CREATED)
Exemple #9
0
 def post(self, request):
     """
 Login shop assistants. If email and password matches returns a token.   
 """
     response = rh.login(request)
     (status_code, tokenId) = response
     if status_code == c.BAD_REQUEST:  # Validation error.
         return Response(cr.CeesResponse().getCeesResponse(1, 1, ''),
                         status=status.HTTP_400_BAD_REQUEST
                         )  # JSON format not valid or data parsing failed.
     elif status_code == c.INTERNAL_SERVER_ERROR:
         return Response(cr.CeesResponse().getCeesResponse(1, 3, ''),
                         status=status.HTTP_500_INTERNAL_SERVER_ERROR
                         )  # Internal Error.
     elif status_code == c.UNAUTHORIZED:
         return Response(
             cr.CeesResponse().getCeesResponse(1, 2, ''),
             status=status.HTTP_401_UNAUTHORIZED)  # Credentials not found.
     else:
         return Response(cr.CeesResponse().getCeesResponse(0, 0, tokenId),
                         status=status.HTTP_201_CREATED)  # Token created.
Exemple #10
0
 def put(self, request):
     """
 Update registrationId for the device linked to the request.
 """
     response = rh.updateRegId(request)
     if response == c.UNAUTHORIZED:
         return Response(cr.CeesResponse().getCeesResponse(1, 2, ''),
                         status=status.HTTP_401_UNAUTHORIZED)
     elif response == c.BAD_REQUEST:
         return Response(cr.CeesResponse().getCeesResponse(1, 1, ''),
                         status=status.HTTP_400_BAD_REQUEST
                         )  # Validation Error. Returns HTTP 400.
     elif response == c.NOT_FOUND:
         return Response(cr.CeesResponse().getCeesResponse(1, 4, ''),
                         status=status.HTTP_404_NOT_FOUND)
     elif response == c.INTERNAL_SERVER_ERROR:
         return Response(cr.CeesResponse().getCeesResponse(1, 3, ''),
                         status=status.HTTP_500_INTERNAL_SERVER_ERROR)
     else:
         return Response(cr.CeesResponse().getCeesResponse(0, 0, ''),
                         status=status.HTTP_201_CREATED)
Exemple #11
0
 def put(self, request):
     """
 Updates arrival status
 """
     response = rh.updateArrivalStatus(request)
     if response == c.UNAUTHORIZED:
         return Response(cr.CeesResponse().getCeesResponse(1, 2, ''),
                         status=status.HTTP_401_UNAUTHORIZED)
     elif response == c.BAD_REQUEST:
         return Response(cr.CeesResponse().getCeesResponse(1, 1, ''),
                         status=status.HTTP_400_BAD_REQUEST
                         )  # Validation Error. Returns HTTP 400.
     elif response == c.NOT_FOUND:
         return Response(cr.CeesResponse().getCeesResponse(1, 4, ''),
                         status=status.HTTP_404_NOT_FOUND)
     elif response == c.INTERNAL_SERVER_ERROR:
         return Response(cr.CeesResponse().getCeesResponse(1, 3, ''),
                         status=status.HTTP_500_INTERNAL_SERVER_ERROR)
     else:
         return Response(cr.CeesResponse().getCeesResponse(0, 0, ''),
                         status=status.HTTP_201_CREATED)