class TorgApi::Api::Bidder

Участник закупки

Attributes

contractor_id[RW]

@return [Integer] ID участника

id[RW]

@return [Integer] id

tender_id[RW]

@return [Integer] ID закупки

Public Class Methods

create(contractor_id, tender_id, date_offer = nil) click to toggle source

Создаёт участника в системе и возвращает его id @param contractor_id [Integer] id контрагента @param tender_id [Integer] id закупки @param date_offer [Time] Дата и время регистрации конверта участника @return [Bidder]

# File lib/torg_api/api/bidder.rb, line 19
def create(contractor_id, tender_id, date_offer = nil)
  responce_b = JSON.parse(
    torg_resource["tenders/#{tender_id}/bidders"].post(
      bidder: {
        tender_id: tender_id,
        contractor_id: contractor_id,
        covers_attributes: {
          '0' => {
            _destroy: false,
            compound_register_time_attributes: {
              date: date_offer && date_offer.strftime('%d.%m.%Y'),
              time: date_offer && date_offer.strftime('%H:%M')
            },
            type_id: CoverLabels::REQUEST,
            delegate: 'B2B-Center',
            provision: 'Электронный конверт'
          }
        }
      },
      accept: :json,
      content_type: :json,
      format: :json
    ),
    symbolize_names: true
  )

  new(responce_b)
end

Public Instance Methods

add_file(file, name = nil, note = nil) click to toggle source

Добавляет файл предложения участника к нему @param file [String] имя файла и путь к нему @param name [String] имя файла во внешней системе @param note [String] Комментарии @return Nothing

# File lib/torg_api/api/bidder.rb, line 69
def add_file(file, name = nil, note = nil)
  document = if file.start_with?('http')
    { remote_document_url: file }
  else
    { document: File.open(file) }
  end
  responce_f = JSON.parse(
    TorgApi::Base.torg_resource["tender_files"].post(
      tender_file: {
        area_id: TenderFileArea::BIDDER,
        year: Date.current.year,
        external_filename: name
      }.merge(document),
      accept: :json,
      content_type: :json,
      format: :json
    ),
    symbolize_names: true
  )

  responce_bf = JSON.parse(
    TorgApi::Base.torg_resource["tenders/#{tender_id}/bidders/#{id}"].patch(
      bidder: {
        bidder_files_attributes: {
          '0' => {
            note: note,
            tender_file_id: responce_f[:id],
            bidder_id: id
          }
        }
      },
      accept: :json,
      content_type: :json,
      format: :json
    ),
    symbolize_names: true
  )
  responce_bf
end
file_exists?(file_name) click to toggle source

Проверяет, есть ли файл с таким именем у данного участника @param file_name [String] Имя файла во внешней системе return [Boolean]

# File lib/torg_api/api/bidder.rb, line 51
def file_exists?(file_name)
  responce = JSON.parse(
    TorgApi::Base.torg_resource["tenders/#{tender_id}/bidders/#{id}/file_exists"].get(
      params: { file_name: file_name },
      accept: :json,
      content_type: :json,
      format: :json
    ),
    symbolize_names: true
  )
  responce[:exists]
end