Class: TorgApi::Api::Offer
Overview
Оферта участника
Constant Summary
Constants inherited from Base
Class Method Summary collapse
Methods inherited from Base
Class Method Details
.create(lot_id, bidder_id, hash) ⇒ Integer
Создаёт оферту
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/torg_api/api/offer.rb', line 11 def create(lot_id, bidder_id, hash) o = nil TorgApi::Models::Offer.transaction do o = TorgApi::Models::Offer.create!( lot_id: lot_id, bidder_id: bidder_id, num: hash[:offer_num], version: 0, type_id: CoverLabels::REQUEST, status_id: extract_status(hash[:winner]) ) TorgApi::Models::Specification.where(lot_id: lot_id).each do |spec| TorgApi::Models::OfferSpecification.create!( offer_id: o.id, specification_id: spec.id, cost: hash[:final_price_notax], cost_nds: hash[:final_price], final_cost: hash[:final_price_notax], final_cost_nds: hash[:final_price] ) end end o.id end |
.extract_status(winner) ⇒ Object
38 39 40 |
# File 'lib/torg_api/api/offer.rb', line 38 def extract_status(winner) winner ? OfferStatuses::WIN : OfferStatuses::NEW end |