def on_get(self, req, resp): try: name, code, sortBy, minPrice, maxPrice, offset, limit, productIds = restUtils.getQueryParams(req) products = bl.getProducts( name = name, code = code, sortBy = sortBy, minPrice = minPrice, maxPrice = maxPrice, offset = offset, limit = limit, productIds = productIds ) result = {'products':products} print(result) resp.body = json.dumps(result, sort_keys=True, default=Product.serialize) resp.status = falcon.HTTP_200 #Status Ok except: #Return 500 - internal error resp.status = falcon.HTTP_500
def on_get(self, req, resp, userId): try: name, code, sortBy, minPrice, maxPrice, offset, limit, productIds = restUtils.getQueryParams(req) userId = int(userId) #Fetch products using queryparams and pathparam userId productsInCart = bl.getShoppingCartProducts(name=name, code=code, sortBy=sortBy, minPrice=minPrice, maxPrice=maxPrice, offset=offset, limit=limit, productIds=productIds, userId=userId) result = {'products':productsInCart} resp.body = json.dumps(result, sort_keys=True) resp.status = falcon.HTTP_200 except: #Return 500 - internal error resp.status = falcon.HTTP_500