Example #1
0
 def get_product(self, product_id: str) -> Product:
     try:
         return next(
             Product.parse_obj(product) for product in self.data
             if product["id"] == product_id)
     except StopIteration:
         raise NotFound(f"Product {product_id} not found")
Example #2
0
 def get_products(self) -> List[Product]:
     return [Product.parse_obj(product) for product in self.data]