Exemplo n.º 1
0
 def get(self, id):
     """
     Search a Product by id.
     """
     token = request.headers.get('Authorization')
     auth = Validations.validate_user_authorization(token)
     
     return ProductManager.get_product(id)
Exemplo n.º 2
0
 def delete(self, id):
     """
     Delete a Product by id.
     """
     token = request.headers.get('Authorization')
     auth = Validations.validate_user_authorization(token)
     
     return ProductManager.delete_product(id)
Exemplo n.º 3
0
    def delete(self, client_id, product_id):
        """
        Delete product from wishlist by client_id and product_id
        """
        token = request.headers.get('Authorization')
        auth = Validations.validate_user_authorization(token)

        return WishlistManager.delete_wishlist(client_id, product_id)
Exemplo n.º 4
0
    def get(self, client_id):
        """
        Search wishlist by client_id
        """
        token = request.headers.get('Authorization')
        auth = Validations.validate_user_authorization(token)

        return WishlistManager.get_wishlist(client_id)
Exemplo n.º 5
0
 def delete(self, email):
     """
     Delete a consumer by email.
     """
     token = request.headers.get('Authorization')
     auth = Validations.validate_user_authorization(token)
     
     email_valid = Validations.email_validate(email)
     return CustomerManager.delete_customer(email)
Exemplo n.º 6
0
    def post(self):
        """
        Register new wishlist. :product_id can be a registered product id in our base or a challenge API product id.
        """
        token = request.headers.get('Authorization')
        auth = Validations.validate_user_authorization(token)

        json_data = request.json
        return WishlistManager.register_new_wishlist(json_data)
Exemplo n.º 7
0
 def put(self, id):
     """
     Update a Product by id.
     """
     token = request.headers.get('Authorization')
     auth = Validations.validate_user_authorization(token)
     
     json_data = request.json
     validation = Validations.product_validate(json_data)
     return ProductManager.update_existing_product(id, json_data)
Exemplo n.º 8
0
 def post(self):
     """
     Register a new Product.
     """
     token = request.headers.get('Authorization')
     auth = Validations.validate_user_authorization(token)
     
     json_data = request.json
     validation = Validations.product_validate(json_data)
     return ProductManager.register_new_product(json_data)
Exemplo n.º 9
0
 def put(self, email):
     """
     Update a consumer by email.
     """
     token = request.headers.get('Authorization')
     auth = Validations.validate_user_authorization(token)
     
     json_data = request.json
     data_valid = Validations.customer_validate(json_data)
     return CustomerManager.update_existing_customer(email, json_data)
Exemplo n.º 10
0
 def post(self):
     """
     Register a new customer.
     """
     token = request.headers.get('Authorization')
     auth = Validations.validate_user_authorization(token)
     
     json_data = request.json
     validation = Validations.customer_validate(json_data)
     return CustomerManager.register_new_customer(json_data)
Exemplo n.º 11
0
 def login(self):
     user = self.user.get('email')
     token = Validations.encode_hash(self.user.get('password'))
     user = Validations.validate_user_authorization(token, user=user)
     return {"status": "Successful login!", "token": token}