mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-20 00:37:26 +00:00
18 lines
516 B
Ruby
18 lines
516 B
Ruby
# frozen_string_literal: true
|
|
|
|
class EnterpriseBuilder < DfcBuilder
|
|
def self.enterprise(enterprise)
|
|
variants = VariantFetcher.new(enterprise).scope.to_a
|
|
catalog_items = variants.map(&method(:catalog_item))
|
|
supplied_products = catalog_items.map(&:product)
|
|
|
|
DataFoodConsortium::Connector::Enterprise.new(
|
|
enterprise.name
|
|
).tap do |e|
|
|
e.semanticId = urls.enterprise_url(enterprise.id)
|
|
e.suppliedProducts = supplied_products
|
|
e.catalogItems = catalog_items
|
|
end
|
|
end
|
|
end
|