Class: TorgApi::Api::Offer

Inherits:
Base
  • Object
show all
Defined in:
lib/torg_api/api/offer.rb

Overview

Оферта участника

Constant Summary

Constants inherited from Base

Base::REMOVE_HASH_ATTRS

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Base

attr_accessor, attributes, #initialize, #to_h, torg_resource

Constructor Details

This class inherits a constructor from TorgApi::Base

Instance Attribute Details

#bidder_idInteger

Returns id участника.

Returns:

  • (Integer)

    id участника



16
17
18
# File 'lib/torg_api/api/offer.rb', line 16

def bidder_id
  @bidder_id
end

#idInteger

Returns id созданного объекта.

Returns:

  • (Integer)

    id созданного объекта



12
13
14
# File 'lib/torg_api/api/offer.rb', line 12

def id
  @id
end

#lot_idInteger

Returns id лота.

Returns:

  • (Integer)

    id лота



14
15
16
# File 'lib/torg_api/api/offer.rb', line 14

def lot_id
  @lot_id
end

#numString

Returns номер оферты.

Returns:

  • (String)

    номер оферты



18
19
20
# File 'lib/torg_api/api/offer.rb', line 18

def num
  @num
end

#offer_specificationsArray

Returns Спецификация оферты.

Returns:

  • (Array)

    Спецификация оферты



26
27
28
# File 'lib/torg_api/api/offer.rb', line 26

def offer_specifications
  @offer_specifications
end

#status_idInteger

Returns id статуса.

Returns:

  • (Integer)

    id статуса



24
25
26
# File 'lib/torg_api/api/offer.rb', line 24

def status_id
  @status_id
end

#type_idInteger

Returns id типа оферты.

Returns:

  • (Integer)

    id типа оферты



22
23
24
# File 'lib/torg_api/api/offer.rb', line 22

def type_id
  @type_id
end

#versionInteger

Returns версия.

Returns:

  • (Integer)

    версия



20
21
22
# File 'lib/torg_api/api/offer.rb', line 20

def version
  @version
end

Class Method Details

.create(lot_id, bidder_id, hash, torg_spec_id, tender_id) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/torg_api/api/offer.rb', line 29

def create(lot_id, bidder_id, hash, torg_spec_id, tender_id)
  responce_o = JSON.parse(
    torg_resource["tenders/#{tender_id}/bidders/#{bidder_id}/offers"].post(
      offer: {
        lot_id: lot_id,
        bidder_id: bidder_id,
        num: hash[:num],
        version: 0,
        type_id: CoverLabels::REQUEST,
        status_id: OfferStatuses::NEW,
        offer_specifications_attributes: {
          '0' => {
            specification_id: torg_spec_id,
            cost: hash[:cost],
            cost_nds: hash[:cost_nds],
            final_cost: hash[:cost],
            final_cost_nds: hash[:cost_nds]
          }
        }
      },
      accept: :json,
      content_type: :json,
      format: :json
    ),
    symbolize_names: true
  )
  new(responce_o)
end

.find(tender_id, bidder_id, lot_id, offer_num, spec_id) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/torg_api/api/offer.rb', line 58

def find(tender_id, bidder_id, lot_id, offer_num, spec_id)
  responce = JSON.parse(
    torg_resource["tenders/#{tender_id}/bidders/#{bidder_id}/offers"].get(
      accept: :json,
      content_type: :json,
      format: :json
    ),
    symbolize_names: true
  )
  offer = responce.select { |value|
    value[:lot_id] == lot_id &&
    value[:num] == offer_num &&
    value[:version] == 0 &&
    value[:offer_specifications][0][:specification_id] == spec_id
  }
  offer
end