in app/helpers/orders/data_classes.py [0:0]
def deserialize(document):
"""
Helper function for parsing a Firestore document to an Order object.
Parameters:
document (DocumentSnapshot): A snapshot of Firestore document.
Output:
An Order object.
"""
data = document.to_dict()
if data:
return Order(
id=document.id,
amount=data.get('amount'),
shipping=Shipping.deserialize(data.get('shipping')),
status=data.get('status'),
items=data.get('items')
)
return None