def export_data(self, token):
        user = queries.user_from_token(self.db, token)
        products_list = queries.get_all_products(self.db, user)
        supplies_list = queries.get_all_supplies(self.db, user)
        orders_list = queries.get_all_orders(self.db, user)
        orders_history = queries.get_order_history(self.db, user)

        orders, supplies, products, history = [], [], [], []
        if products_list:
            for product in products_list:
                products.append(Product(*product).__dict__)
        if supplies_list:
            for supply in supplies_list:
                supplies.append(Supply(*supply).__dict__)
        if orders_list:
            for order in orders_list:
                orders.append(Order(*tuple(order)).__dict__)
        if orders_history:
            for order_history in orders_history:
                history.append(Order(*tuple(order)).__dict__)
        data = {'orders': orders, 'products': products, 'supplies': supplies,
                'history': history}
        return data
 def create_product(self, token, data):
     user = queries.user_from_token(self.db, token)
     product_id = queries.create_product(self.db, data, user)
     return product_id
 def update_order(self, token, order_id, data):
     user = queries.user_from_token(self.db, token)
     queries.update_order(self.db, user, order_id, data)
     queries.update_order_price(self.db, order_id)
     return True
 def create_order(self, token, data):
     user = queries.user_from_token(self.db, token)
     order_id = queries.create_order(self.db, data, user)
     queries.update_order_price(self.db, order_id)
     return order_id
 def validate_user(self, token):
     user = queries.user_from_token(self.db, token)
     return user if user else False
 def create_supply(self, token, data):
     user = queries.user_from_token(self.db, token)
     supply_id = queries.create_supply(self.db, data, user)
     return supply_id