def post(self): data = api.payload response = DbOps.get_product('', data['pkey']) if response['success']: return response['product_object'], 200 else: return response['message'], 500
def post(self): data = api.payload response = DbOps.check_stock('', data['basket_id']) if response['success']: return response['in_stock'], 200 else: return response['message'], 500
def get(self): """ Returns a list of all of the products """ response = DbOps.get_all_products('') if response['success']: return response['products'], 200 else: return response['message'], 500
def post(self): """ Edit the product description """ data = api.payload response = DbOps.edit_product_description('', data['pkey'], data['new_desc']) if response['changed']: return response['product_object'], 200 else: return response['message'], 500
def post(self): """ Calculate tax """ data = api.payload response = DbOps.calculate_tax('', data['state'], data['subtotal']) if response['changed']: return response['tax_amount'], 200 else: print(response['message']) return response['message'], 500
def post(self): """ Checks if an item is on sale """ data = api.payload response = DbOps.check_sale('', data['date'], data['product_id']) if response['changed']: return { "msg": response['message'], "on_sale": response['on_sale'] }, 200 else: return response['message'], 500
def post(self): """ Update the shipping info on an order """ data = api.payload response = DbOps.update_order_status('', data['basket_id'], data['date'], data['shipper'], data['shipnum']) if response['changed']: return response['shipped'], 200 else: return response['message'], 500
def post(self): """ Add a new product """ data = api.payload response = DbOps.add_new_product('', data['product_name'], data['product_desc'], data['product_img_file'], data['product_price'], data['product_status']) if response['changed']: return response['product_object'], 200 else: return response['message'], 500