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