def _create_from_draft(self, draft: types.ShoppingListDraft, id: Optional[str] = None) -> types.ShoppingList: object_id = str(uuid.UUID(id)) if id is not None else uuid.uuid4() line_items = None if draft.line_items: line_items = [ self._create_line_item_from_draft(line_item) for line_item in draft.line_items ] text_line_items = None if draft.text_line_items: text_line_items = [ self._create_line_item_text_from_draft(text_line_item) for text_line_item in draft.text_line_items ] return types.ShoppingList( id=str(object_id), version=1, custom=utils.create_from_draft(draft.custom), customer=draft.customer, delete_days_after_last_modification=draft. delete_days_after_last_modification, description=draft.description, key=draft.key, line_items=line_items, name=draft.name, slug=draft.slug, text_line_items=text_line_items, anonymous_id=draft.anonymous_id, )
def post_load(self, data, **kwargs): return types.ShoppingList(**data)