in app/helpers/product_catalog/data_classes.py [0:0]
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