Ejemplo n.º 1
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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
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)
Ejemplo n.º 10
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)
Ejemplo n.º 11
0
 def register(self):
     token = Validations.encode_hash(self.user.get('password'))
     user = User()
     user.username = self.user.get('username')
     user.email = self.user.get('email')
     user.password = token
     resp = user.save()
     if resp.get('status'):
         return {"status": "user registered", "token": token}
     return resp.get('msg')
Ejemplo n.º 12
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}
Ejemplo n.º 13
0
 def test_if_name_is_string(self):
     name = self.valid_customer.get('name')
     Validations.name_is_string(name)
Ejemplo n.º 14
0
 def test_if_name_is_not_string(self):
     name = self.invalid_customer.get('name')
     validation = Validations.name_is_string(name)
     self.assertFalse(validation)
Ejemplo n.º 15
0
 def test_if_email_is_invalid(self):
     email = self.invalid_customer.get('email')
     validation = Validations.email_validate(email)
     self.assertFalse(validation)
Ejemplo n.º 16
0
 def test_if_email_is_valid(self):
     email = self.valid_user.get('email')
     Validations.email_validate(email)
Ejemplo n.º 17
0
 def test_if_price_is_numeric(self):
     price = self.product.get('price')
     Validations.value_is_numeral(price)
Ejemplo n.º 18
0
 def test_if_review_score_is_numeric(self):
     reviewScore = self.product.get('reviewScore')
     Validations.value_is_numeral(reviewScore)