def _create_assets_from_draft( self, drafts: List[types.AssetDraft]) -> List[types.Asset]: assets: List[types.Asset] = [] for draft in drafts: custom: Optional[types.CustomFields] = None if draft.custom: custom = custom_fields_from_draft(self._storage, draft.custom) asset = types.Asset( sources=draft.sources, name=draft.name, description=draft.description, tags=draft.tags, custom=custom, key=draft.key, ) assets.append(asset) return assets
def _create_prices_from_draft( self, drafts: typing.List[types.PriceDraft] ) -> typing.List[types.Price]: prices: typing.List[types.Price] = [] for draft in drafts: custom = None if draft.custom: custom = custom_fields_from_draft(self._storage, draft.custom) price = types.Price( value=draft.value, country=draft.country, customer_group=draft.customer_group, channel=draft.channel, valid_from=draft.valid_from, valid_until=draft.valid_until, discounted=None, custom=custom, tiers=draft.tiers, ) prices.append(price) return prices
def _create_prices_from_draft( self, drafts: List[models.PriceDraft]) -> List[models.Price]: prices: List[models.Price] = [] for draft in drafts: custom = None if draft.custom: custom = custom_fields_from_draft(self._storage, draft.custom) price = models.Price( id=str(uuid.uuid4()), value=self._create_price_from_draft(draft.value), country=draft.country, customer_group=draft.customer_group, channel=draft.channel, valid_from=draft.valid_from, valid_until=draft.valid_until, discounted=None, custom=custom, tiers=draft.tiers, ) prices.append(price) return prices