def _create_from_draft(
     self, obj: types.ProductTypeDraft, id: typing.Optional[str] = None
 ) -> types.ProductType:
     object_id = str(uuid.UUID(id) if id is not None else uuid.uuid4())
     return types.ProductType(
         id=str(object_id),
         version=1,
         name=obj.name,
         description=obj.description,
         key=obj.key,
         created_at=datetime.datetime.now(),
         last_modified_at=datetime.datetime.now(),
         attributes=obj.attributes,
     )
 def _create_from_draft(
     self, draft: types.ProductTypeDraft, id: typing.Optional[str] = None
 ) -> types.ProductType:
     object_id = str(uuid.UUID(id) if id is not None else uuid.uuid4())
     return types.ProductType(
         id=str(object_id),
         version=1,
         name=draft.name,
         description=draft.description,
         key=draft.key,
         created_at=datetime.datetime.now(datetime.timezone.utc),
         last_modified_at=datetime.datetime.now(datetime.timezone.utc),
         attributes=self._create_attributes_from_draft(draft.attributes),
     )
示例#3
0
 def post_load(self, data, **kwargs):
     return types.ProductType(**data)