Class: TorgApi::Api::Lot

Inherits:
Base
  • Object
show all
Defined in:
lib/torg_api/api/lot.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

#idInteger

Returns id.

Returns:

  • (Integer)

    id



6
7
8
# File 'lib/torg_api/api/lot.rb', line 6

def id
  @id
end

#numInteger

Returns Номер.

Returns:

  • (Integer)

    Номер



8
9
10
# File 'lib/torg_api/api/lot.rb', line 8

def num
  @num
end

#specificationsArray

Returns Спецификации.

Returns:

  • (Array)

    Спецификации



10
11
12
# File 'lib/torg_api/api/lot.rb', line 10

def specifications
  @specifications
end

Class Method Details

.find(tender_id, num) ⇒ Tender

Поиск закупки по id

Parameters:

  • id (Integer)

    id закупки

Returns:

  • (Tender)

    возвращает объект закупки



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/torg_api/api/lot.rb', line 15

def find(tender_id, num)
  responce = JSON.parse(
    torg_resource["tenders/#{tender_id}"].get(
      accept: :json,
      content_type: :json,
      format: :json
    ),
    symbolize_names: true
  )
  lot = responce[:lots].select { |value| value[:num] == num }.first
  new(lot) if lot
end