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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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')
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}
def test_if_name_is_string(self): name = self.valid_customer.get('name') Validations.name_is_string(name)
def test_if_name_is_not_string(self): name = self.invalid_customer.get('name') validation = Validations.name_is_string(name) self.assertFalse(validation)
def test_if_email_is_invalid(self): email = self.invalid_customer.get('email') validation = Validations.email_validate(email) self.assertFalse(validation)
def test_if_email_is_valid(self): email = self.valid_user.get('email') Validations.email_validate(email)
def test_if_price_is_numeric(self): price = self.product.get('price') Validations.value_is_numeral(price)
def test_if_review_score_is_numeric(self): reviewScore = self.product.get('reviewScore') Validations.value_is_numeral(reviewScore)