Class: MercadoPublicoCl::Resources::Tender

Inherits:
Data
  • Object
show all
Extended by:
Base::ClassMethods
Defined in:
lib/mercado_publico_cl/resources/tender.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base::ClassMethods

client, detail_payload, extract_list, fetch_list, fetch_single, list_key

Instance Attribute Details

#administrative_actObject (readonly)

Returns the value of attribute administrative_act

Returns:

  • (Object)

    the current value of administrative_act



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def administrative_act
  @administrative_act
end

#administrative_act_codeObject (readonly)

Returns the value of attribute administrative_act_code

Returns:

  • (Object)

    the current value of administrative_act_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def administrative_act_code
  @administrative_act_code
end

#allows_subcontractingObject (readonly)

Returns the value of attribute allows_subcontracting

Returns:

  • (Object)

    the current value of allows_subcontracting



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def allows_subcontracting
  @allows_subcontracting
end

#awardObject (readonly)

Returns the value of attribute award

Returns:

  • (Object)

    the current value of award



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def award
  @award
end

#bip_codeObject (readonly)

Returns the value of attribute bip_code

Returns:

  • (Object)

    the current value of bip_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def bip_code
  @bip_code
end

#buyerObject (readonly)

Returns the value of attribute buyer

Returns:

  • (Object)

    the current value of buyer



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def buyer
  @buyer
end

#codeObject (readonly)

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def code
  @code
end

#complaints_countObject (readonly)

Returns the value of attribute complaints_count

Returns:

  • (Object)

    the current value of complaints_count



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def complaints_count
  @complaints_count
end

#contract_contactObject (readonly)

Returns the value of attribute contract_contact

Returns:

  • (Object)

    the current value of contract_contact



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def contract_contact
  @contract_contact
end

#contract_durationObject (readonly)

Returns the value of attribute contract_duration

Returns:

  • (Object)

    the current value of contract_duration



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def contract_duration
  @contract_duration
end

#contract_duration_tender_unitObject (readonly)

Returns the value of attribute contract_duration_tender_unit

Returns:

  • (Object)

    the current value of contract_duration_tender_unit



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def contract_duration_tender_unit
  @contract_duration_tender_unit
end

#contract_duration_typeObject (readonly)

Returns the value of attribute contract_duration_type

Returns:

  • (Object)

    the current value of contract_duration_type



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def contract_duration_type
  @contract_duration_type
end

#contract_duration_unitObject (readonly)

Returns the value of attribute contract_duration_unit

Returns:

  • (Object)

    the current value of contract_duration_unit



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def contract_duration_unit
  @contract_duration_unit
end

#contract_duration_unit_codeObject (readonly)

Returns the value of attribute contract_duration_unit_code

Returns:

  • (Object)

    the current value of contract_duration_unit_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def contract_duration_unit_code
  @contract_duration_unit_code
end

#contract_notesObject (readonly)

Returns the value of attribute contract_notes

Returns:

  • (Object)

    the current value of contract_notes



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def contract_notes
  @contract_notes
end

#contract_status_codeObject (readonly)

Returns the value of attribute contract_status_code

Returns:

  • (Object)

    the current value of contract_status_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def contract_status_code
  @contract_status_code
end

#contracting_restrictionObject (readonly)

Returns the value of attribute contracting_restriction

Returns:

  • (Object)

    the current value of contracting_restriction



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def contracting_restriction
  @contracting_restriction
end

#convocation_typeObject (readonly)

Returns the value of attribute convocation_type

Returns:

  • (Object)

    the current value of convocation_type



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def convocation_type
  @convocation_type
end

#currencyObject (readonly)

Returns the value of attribute currency

Returns:

  • (Object)

    the current value of currency



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def currency
  @currency
end

#currency_codeObject (readonly)

Returns the value of attribute currency_code

Returns:

  • (Object)

    the current value of currency_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def currency_code
  @currency_code
end

#datesObject (readonly)

Returns the value of attribute dates

Returns:

  • (Object)

    the current value of dates



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def dates
  @dates
end

#days_to_closeObject (readonly)

Returns the value of attribute days_to_close

Returns:

  • (Object)

    the current value of days_to_close



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def days_to_close
  @days_to_close
end

#delivery_addressObject (readonly)

Returns the value of attribute delivery_address

Returns:

  • (Object)

    the current value of delivery_address



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def delivery_address
  @delivery_address
end

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def description
  @description
end

#estimated_amountObject (readonly)

Returns the value of attribute estimated_amount

Returns:

  • (Object)

    the current value of estimated_amount



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def estimated_amount
  @estimated_amount
end

#estimated_amount_justificationObject (readonly)

Returns the value of attribute estimated_amount_justification

Returns:

  • (Object)

    the current value of estimated_amount_justification



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def estimated_amount_justification
  @estimated_amount_justification
end

#estimated_amount_typeObject (readonly)

Returns the value of attribute estimated_amount_type

Returns:

  • (Object)

    the current value of estimated_amount_type



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def estimated_amount_type
  @estimated_amount_type
end

#estimated_amount_type_codeObject (readonly)

Returns the value of attribute estimated_amount_type_code

Returns:

  • (Object)

    the current value of estimated_amount_type_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def estimated_amount_type_code
  @estimated_amount_type_code
end

#evaluation_durationObject (readonly)

Returns the value of attribute evaluation_duration

Returns:

  • (Object)

    the current value of evaluation_duration



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def evaluation_duration
  @evaluation_duration
end

#evaluation_duration_unitObject (readonly)

Returns the value of attribute evaluation_duration_unit

Returns:

  • (Object)

    the current value of evaluation_duration_unit



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def evaluation_duration_unit
  @evaluation_duration_unit
end

#evaluation_duration_unit_codeObject (readonly)

Returns the value of attribute evaluation_duration_unit_code

Returns:

  • (Object)

    the current value of evaluation_duration_unit_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def evaluation_duration_unit_code
  @evaluation_duration_unit_code
end

#evaluation_time_unitObject (readonly)

Returns the value of attribute evaluation_time_unit

Returns:

  • (Object)

    the current value of evaluation_time_unit



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def evaluation_time_unit
  @evaluation_time_unit
end

#evaluation_time_unit_codeObject (readonly)

Returns the value of attribute evaluation_time_unit_code

Returns:

  • (Object)

    the current value of evaluation_time_unit_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def evaluation_time_unit_code
  @evaluation_time_unit_code
end

#extends_deadlineObject (readonly)

Returns the value of attribute extends_deadline

Returns:

  • (Object)

    the current value of extends_deadline



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def extends_deadline
  @extends_deadline
end

#funding_sourceObject (readonly)

Returns the value of attribute funding_source

Returns:

  • (Object)

    the current value of funding_source



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def funding_source
  @funding_source
end

#informedObject (readonly)

Returns the value of attribute informed

Returns:

  • (Object)

    the current value of informed



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def informed
  @informed
end

#itemsObject (readonly)

Returns the value of attribute items

Returns:

  • (Object)

    the current value of items



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def items
  @items
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def name
  @name
end

#payment_contactObject (readonly)

Returns the value of attribute payment_contact

Returns:

  • (Object)

    the current value of payment_contact



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def payment_contact
  @payment_contact
end

#payment_type_codeObject (readonly)

Returns the value of attribute payment_type_code

Returns:

  • (Object)

    the current value of payment_type_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def payment_type_code
  @payment_type_code
end

#public_technical_offersObject (readonly)

Returns the value of attribute public_technical_offers

Returns:

  • (Object)

    the current value of public_technical_offers



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def public_technical_offers
  @public_technical_offers
end

#publicity_justificationObject (readonly)

Returns the value of attribute publicity_justification

Returns:

  • (Object)

    the current value of publicity_justification



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def publicity_justification
  @publicity_justification
end

#rawObject (readonly)

Returns the value of attribute raw

Returns:

  • (Object)

    the current value of raw



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def raw
  @raw
end

#renewableObject (readonly)

Returns the value of attribute renewable

Returns:

  • (Object)

    the current value of renewable



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def renewable
  @renewable
end

#renewal_periodObject (readonly)

Returns the value of attribute renewal_period

Returns:

  • (Object)

    the current value of renewal_period



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def renewal_period
  @renewal_period
end

#renewal_valueObject (readonly)

Returns the value of attribute renewal_value

Returns:

  • (Object)

    the current value of renewal_value



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def renewal_value
  @renewal_value
end

#requires_contraloriaObject (readonly)

Returns the value of attribute requires_contraloria

Returns:

  • (Object)

    the current value of requires_contraloria



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def requires_contraloria
  @requires_contraloria
end

#site_visit_addressObject (readonly)

Returns the value of attribute site_visit_address

Returns:

  • (Object)

    the current value of site_visit_address



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def site_visit_address
  @site_visit_address
end

#stages_countObject (readonly)

Returns the value of attribute stages_count

Returns:

  • (Object)

    the current value of stages_count



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def stages_count
  @stages_count
end

#stages_statusObject (readonly)

Returns the value of attribute stages_status

Returns:

  • (Object)

    the current value of stages_status



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def stages_status
  @stages_status
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def status
  @status
end

#status_codeObject (readonly)

Returns the value of attribute status_code

Returns:

  • (Object)

    the current value of status_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def status_code
  @status_code
end

#status_labelObject (readonly)

Returns the value of attribute status_label

Returns:

  • (Object)

    the current value of status_label



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def status_label
  @status_label
end

#template_basedObject (readonly)

Returns the value of attribute template_based

Returns:

  • (Object)

    the current value of template_based



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def template_based
  @template_based
end

#tender_kind_codeObject (readonly)

Returns the value of attribute tender_kind_code

Returns:

  • (Object)

    the current value of tender_kind_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def tender_kind_code
  @tender_kind_code
end

#tender_payment_methodObject (readonly)

Returns the value of attribute tender_payment_method

Returns:

  • (Object)

    the current value of tender_payment_method



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def tender_payment_method
  @tender_payment_method
end

#tender_payment_method_codeObject (readonly)

Returns the value of attribute tender_payment_method_code

Returns:

  • (Object)

    the current value of tender_payment_method_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def tender_payment_method_code
  @tender_payment_method_code
end

#tender_typeObject (readonly)

Returns the value of attribute tender_type

Returns:

  • (Object)

    the current value of tender_type



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def tender_type
  @tender_type
end

#tender_type_codeObject (readonly)

Returns the value of attribute tender_type_code

Returns:

  • (Object)

    the current value of tender_type_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def tender_type_code
  @tender_type_code
end

#visible_amountObject (readonly)

Returns the value of attribute visible_amount

Returns:

  • (Object)

    the current value of visible_amount



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def visible_amount
  @visible_amount
end

#works_status_codeObject (readonly)

Returns the value of attribute works_status_code

Returns:

  • (Object)

    the current value of works_status_code



5
6
7
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5

def works_status_code
  @works_status_code
end

Class Method Details

.activeObject



93
94
95
96
# File 'lib/mercado_publico_cl/resources/tender.rb', line 93

def self.active
  query = Query.new(resource: :tender, params: { status: :active })
  fetch_list(query.to_h)
end

.allObject



88
89
90
91
# File 'lib/mercado_publico_cl/resources/tender.rb', line 88

def self.all
  query = Query.new(resource: :tender, params: { status: :all })
  fetch_list(query.to_h)
end

.amount_attrs(raw, codes) ⇒ Object



171
172
173
174
175
176
177
178
179
180
181
# File 'lib/mercado_publico_cl/resources/tender.rb', line 171

def self.amount_attrs(raw, codes)
  {
    estimated_amount: Base.to_float(raw["MontoEstimado"]),
    estimated_amount_type: Enums::EstimatedAmountType.to_symbol(codes[:estimated_amount_type]),
    estimated_amount_type_code: codes[:estimated_amount_type],
    estimated_amount_justification: raw["JustificacionMontoEstimado"],
    tender_payment_method: Enums::TenderPaymentMethod.to_symbol(codes[:payment_method]),
    tender_payment_method_code: codes[:payment_method],
    payment_type_code: Base.to_int(raw["TipoPago"])
  }
end

.base_attrs(raw, codes) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/mercado_publico_cl/resources/tender.rb', line 133

def self.base_attrs(raw, codes)
  {
    code: raw["CodigoExterno"],
    name: raw["Nombre"],
    description: raw["Descripcion"],
    status: Enums::TenderStatus.to_symbol(codes[:status]),
    status_code: codes[:status],
    status_label: raw["Estado"],
    tender_type: Enums::TenderType.to_symbol(codes[:tender_type]),
    tender_type_code: codes[:tender_type],
    tender_kind_code: codes[:tender_kind],
    convocation_type: raw["TipoConvocatoria"],
    currency: Enums::Currency.to_symbol(codes[:currency]),
    currency_code: codes[:currency],
    informed: Base.to_bool(raw["Informada"]),
    requires_contraloria: Base.to_bool(raw["TomaRazon"]),
    public_technical_offers: Base.to_bool(raw["EstadoPublicidadOfertas"]),
    publicity_justification: raw["JustificacionPublicidad"],
    contract_status_code: Base.to_int(raw["Contrato"]),
    works_status_code: Base.to_int(raw["Obras"]),
    complaints_count: Base.to_int(raw["CantidadReclamos"]),
    days_to_close: Base.to_int(raw["DiasCierreLicitacion"]),
    visible_amount: Base.to_bool(raw["VisibilidadMonto"]),
    allows_subcontracting: Base.to_bool(raw["SubContratacion"]),
    extends_deadline: Base.to_bool(raw["ExtensionPlazo"]),
    template_based: Base.to_bool(raw["EsBaseTipo"]),
    renewable: Base.to_bool(raw["EsRenovable"]),
    renewal_value: raw["ValorTiempoRenovacion"],
    renewal_period: raw["PeriodoTiempoRenovacion"],
    funding_source: raw["FuenteFinanciamiento"],
    contracting_restriction: raw["ProhibicionContratacion"],
    contract_notes: raw["ObservacionContract"],
    site_visit_address: raw["DireccionVisita"],
    delivery_address: raw["DireccionEntrega"],
    bip_code: raw["CodigoBIP"]
  }
end

.contact_attrs(raw) ⇒ Object



202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/mercado_publico_cl/resources/tender.rb', line 202

def self.contact_attrs(raw)
  {
    payment_contact: TenderContact.from_payload(
      name: raw["NombreResponsablePago"],
      email: raw["EmailResponsablePago"]
    ),
    contract_contact: TenderContact.from_payload(
      name: raw["NombreResponsableContrato"],
      email: raw["EmailResponsableContrato"],
      phone: raw["FonoResponsableContrato"]
    )
  }
end

.endpointObject



77
78
79
# File 'lib/mercado_publico_cl/resources/tender.rb', line 77

def self.endpoint
  "/servicios/v1/publico/licitaciones.json"
end

.extract_attributes(raw) ⇒ Object



109
110
111
112
113
114
115
116
117
# File 'lib/mercado_publico_cl/resources/tender.rb', line 109

def self.extract_attributes(raw)
  codes = extract_codes(raw)
  base_attrs(raw, codes).merge(
    amount_attrs(raw, codes),
    time_attrs(raw, codes),
    contact_attrs(raw),
    nested_attrs(raw)
  )
end

.extract_codes(raw) ⇒ Object



119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/mercado_publico_cl/resources/tender.rb', line 119

def self.extract_codes(raw)
  {
    status: Base.to_int(raw["CodigoEstado"]),
    tender_type: raw["Tipo"],
    tender_kind: Base.to_int(raw["CodigoTipo"]),
    currency: raw["Moneda"],
    estimated_amount_type: Base.to_int(raw["Estimacion"] || raw["TipoEstimacionMonto"]),
    payment_method: Base.to_int(raw["Modalidad"] || raw["ModalidadPago"]),
    eval_unit: Base.to_int(raw["UnidadTiempoEvaluacion"]),
    contract_unit: Base.to_int(raw["UnidadTiempoDuracionContrato"]),
    admin_act: Base.to_int(raw["TipoActo"])
  }
end

.find(code) ⇒ Object

Raises:



81
82
83
84
85
86
# File 'lib/mercado_publico_cl/resources/tender.rb', line 81

def self.find(code)
  raise InvalidQueryError, "code is required" if code.nil? || code.to_s.strip.empty?

  query = Query.new(resource: :tender, params: { code: code })
  fetch_single(query.to_h)
end

.from_payload(raw) ⇒ Object



105
106
107
# File 'lib/mercado_publico_cl/resources/tender.rb', line 105

def self.from_payload(raw)
  new(**extract_attributes(raw))
end

.nested_attrs(raw) ⇒ Object



216
217
218
219
220
221
222
223
224
# File 'lib/mercado_publico_cl/resources/tender.rb', line 216

def self.nested_attrs(raw)
  {
    buyer: TenderBuyer.from_payload(raw["Comprador"]),
    items: Array(raw.dig("Items", "Listado")).map { |item| TenderItem.from_payload(item) },
    dates: TenderDates.from_payload(raw["Fechas"] || raw),
    award: TenderAward.from_payload(raw["Adjudicacion"]),
    raw: raw
  }
end

.public_type_prefixesObject



70
71
72
73
74
75
# File 'lib/mercado_publico_cl/resources/tender.rb', line 70

def self.public_type_prefixes
  %w[
    public_tender_ personal_services_tender public_works_tender_ concession_
    coordinated_purchase selection_tender other_tender_
  ].freeze
end

.time_attrs(raw, codes) ⇒ Object



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/mercado_publico_cl/resources/tender.rb', line 183

def self.time_attrs(raw, codes)
  {
    evaluation_time_unit: Enums::TimeUnit.to_symbol(codes[:eval_unit]),
    evaluation_time_unit_code: codes[:eval_unit],
    evaluation_duration: raw["Tiempo"],
    evaluation_duration_unit: Enums::TimeUnit.to_symbol(Base.to_int(raw["UnidadTiempo"])),
    evaluation_duration_unit_code: Base.to_int(raw["UnidadTiempo"]),
    contract_duration: raw["TiempoDuracionContrato"],
    contract_duration_unit: Enums::TimeUnit.to_symbol(codes[:contract_unit]),
    contract_duration_unit_code: codes[:contract_unit],
    contract_duration_type: raw["TipoDuracionContrato"],
    contract_duration_tender_unit: raw["UnidadTiempoContratoLicitacion"],
    administrative_act: Enums::AdministrativeAct.to_symbol(codes[:admin_act]),
    administrative_act_code: codes[:admin_act],
    stages_count: Base.to_int(raw["Etapas"]),
    stages_status: raw["EstadoEtapas"]
  }
end

.where(date: nil, status: nil, supplier_code: nil, agency_code: nil) ⇒ Object



98
99
100
101
102
103
# File 'lib/mercado_publico_cl/resources/tender.rb', line 98

def self.where(date: nil, status: nil, supplier_code: nil, agency_code: nil)
  params = { date: date, status: status, supplier_code: supplier_code, agency_code: agency_code }
           .reject { |_, v| v.nil? }
  query = Query.new(resource: :tender, params: params)
  fetch_list(query.to_h)
end

Instance Method Details

#agency_codeObject



287
288
289
# File 'lib/mercado_publico_cl/resources/tender.rb', line 287

def agency_code
  buyer&.code
end

#agency_nameObject



291
292
293
# File 'lib/mercado_publico_cl/resources/tender.rb', line 291

def agency_name
  buyer&.name
end

#allows_subcontracting?Boolean

Returns:

  • (Boolean)


267
268
269
# File 'lib/mercado_publico_cl/resources/tender.rb', line 267

def allows_subcontracting?
  allows_subcontracting == true
end

#award_dateObject



307
308
309
# File 'lib/mercado_publico_cl/resources/tender.rb', line 307

def award_date
  dates&.award
end

#awarded?Boolean

Returns:

  • (Boolean)


283
284
285
# File 'lib/mercado_publico_cl/resources/tender.rb', line 283

def awarded?
  status == :awarded || !award.nil?
end

#awarded_supplier_nameObject



317
318
319
# File 'lib/mercado_publico_cl/resources/tender.rb', line 317

def awarded_supplier_name
  item_awards.filter_map(&:supplier_name).first
end

#awarded_supplier_rutObject

El proveedor adjudicado viene en la Adjudicacion de cada ítem (RutProveedor/NombreProveedor), no en la de nivel licitación.



313
314
315
# File 'lib/mercado_publico_cl/resources/tender.rb', line 313

def awarded_supplier_rut
  item_awards.filter_map(&:supplier_rut).first
end

#closing_dateObject



299
300
301
# File 'lib/mercado_publico_cl/resources/tender.rb', line 299

def closing_date
  dates&.closing
end

#creation_dateObject



295
296
297
# File 'lib/mercado_publico_cl/resources/tender.rb', line 295

def creation_date
  dates&.creation
end

#extends_deadline?Boolean

Returns:

  • (Boolean)


271
272
273
# File 'lib/mercado_publico_cl/resources/tender.rb', line 271

def extends_deadline?
  extends_deadline == true
end

#has_contract?Boolean

Doc oficial: “Contrato: 1=Si 0=No”; otros valores observados (p.ej. 2) no tienen semántica documentada y cuentan como false.

Returns:

  • (Boolean)


255
256
257
# File 'lib/mercado_publico_cl/resources/tender.rb', line 255

def has_contract?
  contract_status_code == 1
end

#informed?Boolean

Returns:

  • (Boolean)


226
227
228
# File 'lib/mercado_publico_cl/resources/tender.rb', line 226

def informed?
  informed == true
end

#inspectObject Also known as: to_s



339
340
341
342
343
# File 'lib/mercado_publico_cl/resources/tender.rb', line 339

def inspect
  "#<MercadoPublicoCl::Tender code=#{code.inspect} status=#{status.inspect} " \
    "type=#{tender_type.inspect} agency=#{agency_name.inspect} " \
    "items=#{Array(items).size}>"
end

#item_awardsObject



331
332
333
# File 'lib/mercado_publico_cl/resources/tender.rb', line 331

def item_awards
  Array(items).filter_map(&:award)
end

#private?Boolean

Returns:

  • (Boolean)


239
240
241
242
243
# File 'lib/mercado_publico_cl/resources/tender.rb', line 239

def private?
  return false if tender_type.nil?

  !public?
end

#public?Boolean

OJO: con tender_type desconocido (nil) AMBOS devuelven false — significa “no se pudo clasificar”, no “ni pública ni privada”. Chequear tender_type_code si se necesita distinguir.

Returns:

  • (Boolean)


233
234
235
236
237
# File 'lib/mercado_publico_cl/resources/tender.rb', line 233

def public?
  return false if tender_type.nil?

  self.class.public_type_prefixes.any? { |p| tender_type.to_s.start_with?(p) }
end

#public_technical_offers?Boolean

Returns:

  • (Boolean)


249
250
251
# File 'lib/mercado_publico_cl/resources/tender.rb', line 249

def public_technical_offers?
  public_technical_offers == true
end

#public_works?Boolean

Returns:

  • (Boolean)


259
260
261
# File 'lib/mercado_publico_cl/resources/tender.rb', line 259

def public_works?
  works_status_code == 2
end

#publication_dateObject



303
304
305
# File 'lib/mercado_publico_cl/resources/tender.rb', line 303

def publication_date
  dates&.publication
end

#renewable?Boolean

Returns:

  • (Boolean)


279
280
281
# File 'lib/mercado_publico_cl/resources/tender.rb', line 279

def renewable?
  renewable == true
end

#requires_contraloria?Boolean

Returns:

  • (Boolean)


245
246
247
# File 'lib/mercado_publico_cl/resources/tender.rb', line 245

def requires_contraloria?
  requires_contraloria == true
end

#summary?Boolean

Returns:

  • (Boolean)


335
336
337
# File 'lib/mercado_publico_cl/resources/tender.rb', line 335

def summary?
  raw["Comprador"].nil? && raw["Items"].nil? && raw["Fechas"].nil?
end

#supplier_codeObject

Best-effort: la API no expone CodigoEmpresa en los payloads observados; preferir awarded_supplier_rut.



323
324
325
326
327
328
329
# File 'lib/mercado_publico_cl/resources/tender.rb', line 323

def supplier_code
  from_items = item_awards.filter_map(&:supplier_code).first
  return from_items if from_items
  return nil unless award&.raw.is_a?(Hash)

  Base.to_int(award.raw["CodigoEmpresa"] || award.raw["CodigoProveedor"])
end

#template_based?Boolean

Returns:

  • (Boolean)


275
276
277
# File 'lib/mercado_publico_cl/resources/tender.rb', line 275

def template_based?
  template_based == true
end

#visible_amount?Boolean

Returns:

  • (Boolean)


263
264
265
# File 'lib/mercado_publico_cl/resources/tender.rb', line 263

def visible_amount?
  visible_amount == true
end