# Path: app/helpers/product_catalog/data_classes.py
# class Product:
#     """
#     Data class for products.
#     """
#     name: str
#     description: str
#     image: str
#     labels: List[str]
#     price: float
#     created_at: int
#     id: str = None
# 
# 
#     @staticmethod
#     def deserialize(document):
#         """
#         Helper function for parsing a Firestore document to a Product object.
# 
#         Parameters:
#            document (DocumentSnapshot): A snapshot of Firestore document.
# 
#         Output:
#            A Product object.
#         """
#         data = document.to_dict()
#         if data:
#             return Product(
#                 id=document.id,
#                 name=data.get('name'),
#                 description=data.get('description'),
#                 image=data.get('image'),
#                 labels=data.get('labels'),
#                 price=data.get('price'),
#                 created_at=data.get('created_at')
#             )
# 
#         return None
# 
# class PromoEntry:
#     """
#     Data class for promotions.
#     """
#     label: str
#     score: float
#     id: str = None
# 
# 
#     @staticmethod
#     def deserialize(document):
#         """
#         Helper function for parsing a Firestore document to a PromoEntry object.
# 
#         Parameters:
#            document (DocumentSnapshot): A snapshot of Firestore document.
# 
#         Output:
#            A PromoEntry object.
#         """
#         data = document.to_dict()
#         if data:
#             return PromoEntry(
#                 id=document.id,
#                 label=data.get('label'),
#                 score=data.get('score')
#             )
# 
#         return None


from dataclasses import asdict
from google.cloud import firestore
from .data_classes import Product, PromoEntry
import os
import uuid
    firestore_client.collection('products').document(product_id).set(asdict(product))
    return product_id

def get_product(product_id):
    """
    Helper function for getting a product.

    Parameters:
       product_id (str): The ID of the product.

    Output:
       A Product object.
    """

    product = firestore_client.collection('products').document(product_id).get()
    return Product.deserialize(product)


def list_products():
    """
    Helper function for listing products.

    Parameters:
       None.

    Output:
       A list of Product objects.
    """

    products = firestore_client.collection('products').order_by('created_at').get()

# Path: app/helpers/product_catalog/data_classes.py
# class Product:
#     """
#     Data class for products.
#     """
#     name: str
#     description: str
#     image: str
#     labels: List[str]
#     price: float
#     created_at: int
#     id: str = None
# 
# 
#     @staticmethod
#     def deserialize(document):
#         """
#         Helper function for parsing a Firestore document to a Product object.
# 
#         Parameters:
#            document (DocumentSnapshot): A snapshot of Firestore document.
# 
#         Output:
#            A Product object.
#         """
#         data = document.to_dict()
#         if data:
#             return Product(
#                 id=document.id,
#                 name=data.get('name'),
#                 description=data.get('description'),
#                 image=data.get('image'),
#                 labels=data.get('labels'),
#                 price=data.get('price'),
#                 created_at=data.get('created_at')
#             )
# 
#         return None
# 
# class PromoEntry:
#     """
#     Data class for promotions.
#     """
#     label: str
#     score: float
#     id: str = None
# 
# 
#     @staticmethod
#     def deserialize(document):
#         """
#         Helper function for parsing a Firestore document to a PromoEntry object.
# 
#         Parameters:
#            document (DocumentSnapshot): A snapshot of Firestore document.
# 
#         Output:
#            A PromoEntry object.
#         """
#         data = document.to_dict()
#         if data:
#             return PromoEntry(
#                 id=document.id,
#                 label=data.get('label'),
#                 score=data.get('score')
#             )
# 
#         return None


# Path: app/helpers/product_catalog/helpers.py
from dataclasses import asdict
from google.cloud import firestore
from .data_classes import Product, PromoEntry
import os
import uuid

    firestore_client.collection('products').document(product_id).set(asdict(product))
    return product_id

def get_product(product_id):
    """
    Helper function for getting a product.

    Parameters:
       product_id (str): The ID of the product.

    Output:
       A Product object.
    """

    product = firestore_client.collection('products').document(product_id).get()
    return Product.deserialize(product)


def list_products():
    """
    Helper function for listing products.

    Parameters:
       None.

    Output:
       A list of Product objects.
    """

    products = firestore_client.collection('products').order_by('created_at').get()

    product_list = [Product.deserialize(product) for product in list(products)]