Files
openfoodnetwork/engines/dfc_provider/app/services/offer_builder.rb
Maikel Linke 583ac65920 Move building of Offer to the right module
The DfcBuilder was doing everything to start with but we are moving its
parts to smaller modules now.
2024-01-12 14:57:58 +11:00

22 lines
475 B
Ruby

# frozen_string_literal: true
class OfferBuilder < DfcBuilder
def self.build(variant)
id = urls.enterprise_offer_url(
enterprise_id: variant.product.supplier_id,
id: variant.id,
)
DataFoodConsortium::Connector::Offer.new(
id,
price: variant.price.to_f,
stockLimitation: stock_limitation(variant),
)
end
def self.apply(offer, variant)
variant.on_hand = offer.stockLimitation
variant.price = offer.price
end
end