Class: MercadoPublicoCl::Resources::Tender
- Inherits:
-
Data
- Object
- Data
- MercadoPublicoCl::Resources::Tender
- Extended by:
- Base::ClassMethods
- Defined in:
- lib/mercado_publico_cl/resources/tender.rb
Instance Attribute Summary collapse
-
#administrative_act ⇒ Object
readonly
Returns the value of attribute administrative_act.
-
#administrative_act_code ⇒ Object
readonly
Returns the value of attribute administrative_act_code.
-
#allows_subcontracting ⇒ Object
readonly
Returns the value of attribute allows_subcontracting.
-
#award ⇒ Object
readonly
Returns the value of attribute award.
-
#bip_code ⇒ Object
readonly
Returns the value of attribute bip_code.
-
#buyer ⇒ Object
readonly
Returns the value of attribute buyer.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#complaints_count ⇒ Object
readonly
Returns the value of attribute complaints_count.
-
#contract_contact ⇒ Object
readonly
Returns the value of attribute contract_contact.
-
#contract_duration ⇒ Object
readonly
Returns the value of attribute contract_duration.
-
#contract_duration_tender_unit ⇒ Object
readonly
Returns the value of attribute contract_duration_tender_unit.
-
#contract_duration_type ⇒ Object
readonly
Returns the value of attribute contract_duration_type.
-
#contract_duration_unit ⇒ Object
readonly
Returns the value of attribute contract_duration_unit.
-
#contract_duration_unit_code ⇒ Object
readonly
Returns the value of attribute contract_duration_unit_code.
-
#contract_notes ⇒ Object
readonly
Returns the value of attribute contract_notes.
-
#contract_status_code ⇒ Object
readonly
Returns the value of attribute contract_status_code.
-
#contracting_restriction ⇒ Object
readonly
Returns the value of attribute contracting_restriction.
-
#convocation_type ⇒ Object
readonly
Returns the value of attribute convocation_type.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#currency_code ⇒ Object
readonly
Returns the value of attribute currency_code.
-
#dates ⇒ Object
readonly
Returns the value of attribute dates.
-
#days_to_close ⇒ Object
readonly
Returns the value of attribute days_to_close.
-
#delivery_address ⇒ Object
readonly
Returns the value of attribute delivery_address.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#estimated_amount ⇒ Object
readonly
Returns the value of attribute estimated_amount.
-
#estimated_amount_justification ⇒ Object
readonly
Returns the value of attribute estimated_amount_justification.
-
#estimated_amount_type ⇒ Object
readonly
Returns the value of attribute estimated_amount_type.
-
#estimated_amount_type_code ⇒ Object
readonly
Returns the value of attribute estimated_amount_type_code.
-
#evaluation_duration ⇒ Object
readonly
Returns the value of attribute evaluation_duration.
-
#evaluation_duration_unit ⇒ Object
readonly
Returns the value of attribute evaluation_duration_unit.
-
#evaluation_duration_unit_code ⇒ Object
readonly
Returns the value of attribute evaluation_duration_unit_code.
-
#evaluation_time_unit ⇒ Object
readonly
Returns the value of attribute evaluation_time_unit.
-
#evaluation_time_unit_code ⇒ Object
readonly
Returns the value of attribute evaluation_time_unit_code.
-
#extends_deadline ⇒ Object
readonly
Returns the value of attribute extends_deadline.
-
#funding_source ⇒ Object
readonly
Returns the value of attribute funding_source.
-
#informed ⇒ Object
readonly
Returns the value of attribute informed.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#payment_contact ⇒ Object
readonly
Returns the value of attribute payment_contact.
-
#payment_type_code ⇒ Object
readonly
Returns the value of attribute payment_type_code.
-
#public_technical_offers ⇒ Object
readonly
Returns the value of attribute public_technical_offers.
-
#publicity_justification ⇒ Object
readonly
Returns the value of attribute publicity_justification.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#renewable ⇒ Object
readonly
Returns the value of attribute renewable.
-
#renewal_period ⇒ Object
readonly
Returns the value of attribute renewal_period.
-
#renewal_value ⇒ Object
readonly
Returns the value of attribute renewal_value.
-
#requires_contraloria ⇒ Object
readonly
Returns the value of attribute requires_contraloria.
-
#site_visit_address ⇒ Object
readonly
Returns the value of attribute site_visit_address.
-
#stages_count ⇒ Object
readonly
Returns the value of attribute stages_count.
-
#stages_status ⇒ Object
readonly
Returns the value of attribute stages_status.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
-
#status_label ⇒ Object
readonly
Returns the value of attribute status_label.
-
#template_based ⇒ Object
readonly
Returns the value of attribute template_based.
-
#tender_kind_code ⇒ Object
readonly
Returns the value of attribute tender_kind_code.
-
#tender_payment_method ⇒ Object
readonly
Returns the value of attribute tender_payment_method.
-
#tender_payment_method_code ⇒ Object
readonly
Returns the value of attribute tender_payment_method_code.
-
#tender_type ⇒ Object
readonly
Returns the value of attribute tender_type.
-
#tender_type_code ⇒ Object
readonly
Returns the value of attribute tender_type_code.
-
#visible_amount ⇒ Object
readonly
Returns the value of attribute visible_amount.
-
#works_status_code ⇒ Object
readonly
Returns the value of attribute works_status_code.
Class Method Summary collapse
- .active ⇒ Object
- .all ⇒ Object
- .amount_attrs(raw, codes) ⇒ Object
- .base_attrs(raw, codes) ⇒ Object
- .contact_attrs(raw) ⇒ Object
- .endpoint ⇒ Object
- .extract_attributes(raw) ⇒ Object
- .extract_codes(raw) ⇒ Object
- .find(code) ⇒ Object
- .from_payload(raw) ⇒ Object
- .nested_attrs(raw) ⇒ Object
- .public_type_prefixes ⇒ Object
- .time_attrs(raw, codes) ⇒ Object
- .where(date: nil, status: nil, supplier_code: nil, agency_code: nil) ⇒ Object
Instance Method Summary collapse
- #agency_code ⇒ Object
- #agency_name ⇒ Object
- #allows_subcontracting? ⇒ Boolean
- #award_date ⇒ Object
- #awarded? ⇒ Boolean
- #awarded_supplier_name ⇒ Object
-
#awarded_supplier_rut ⇒ Object
El proveedor adjudicado viene en la Adjudicacion de cada ítem (RutProveedor/NombreProveedor), no en la de nivel licitación.
- #closing_date ⇒ Object
- #creation_date ⇒ Object
- #extends_deadline? ⇒ Boolean
-
#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.
- #informed? ⇒ Boolean
- #inspect ⇒ Object (also: #to_s)
- #item_awards ⇒ Object
- #private? ⇒ Boolean
-
#public? ⇒ Boolean
OJO: con tender_type desconocido (nil) AMBOS devuelven false — significa “no se pudo clasificar”, no “ni pública ni privada”.
- #public_technical_offers? ⇒ Boolean
- #public_works? ⇒ Boolean
- #publication_date ⇒ Object
- #renewable? ⇒ Boolean
- #requires_contraloria? ⇒ Boolean
- #summary? ⇒ Boolean
-
#supplier_code ⇒ Object
Best-effort: la API no expone CodigoEmpresa en los payloads observados; preferir awarded_supplier_rut.
- #template_based? ⇒ Boolean
- #visible_amount? ⇒ Boolean
Methods included from Base::ClassMethods
client, detail_payload, extract_list, fetch_list, fetch_single, list_key
Instance Attribute Details
#administrative_act ⇒ Object (readonly)
Returns the value of attribute administrative_act
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def administrative_act @administrative_act end |
#administrative_act_code ⇒ Object (readonly)
Returns the value of attribute 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_subcontracting ⇒ Object (readonly)
Returns the value of attribute allows_subcontracting
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def allows_subcontracting @allows_subcontracting end |
#award ⇒ Object (readonly)
Returns the value of attribute award
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def award @award end |
#bip_code ⇒ Object (readonly)
Returns the value of attribute bip_code
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def bip_code @bip_code end |
#buyer ⇒ Object (readonly)
Returns the value of attribute buyer
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def buyer @buyer end |
#code ⇒ Object (readonly)
Returns the value of attribute code
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def code @code end |
#complaints_count ⇒ Object (readonly)
Returns the value of attribute complaints_count
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def complaints_count @complaints_count end |
#contract_contact ⇒ Object (readonly)
Returns the value of attribute contract_contact
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def contract_contact @contract_contact end |
#contract_duration ⇒ Object (readonly)
Returns the value of attribute contract_duration
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def contract_duration @contract_duration end |
#contract_duration_tender_unit ⇒ Object (readonly)
Returns the value of attribute 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_type ⇒ Object (readonly)
Returns the value of attribute 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_unit ⇒ Object (readonly)
Returns the value of attribute 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_code ⇒ Object (readonly)
Returns the value of attribute 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_notes ⇒ Object (readonly)
Returns the value of attribute contract_notes
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def contract_notes @contract_notes end |
#contract_status_code ⇒ Object (readonly)
Returns the value of attribute 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_restriction ⇒ Object (readonly)
Returns the value of attribute contracting_restriction
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def contracting_restriction @contracting_restriction end |
#convocation_type ⇒ Object (readonly)
Returns the value of attribute convocation_type
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def convocation_type @convocation_type end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def currency @currency end |
#currency_code ⇒ Object (readonly)
Returns the value of attribute currency_code
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def currency_code @currency_code end |
#dates ⇒ Object (readonly)
Returns the value of attribute dates
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def dates @dates end |
#days_to_close ⇒ Object (readonly)
Returns the value of attribute 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_address ⇒ Object (readonly)
Returns the value of attribute delivery_address
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def delivery_address @delivery_address end |
#description ⇒ Object (readonly)
Returns the value of attribute description
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def description @description end |
#estimated_amount ⇒ Object (readonly)
Returns the value of attribute estimated_amount
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def estimated_amount @estimated_amount end |
#estimated_amount_justification ⇒ Object (readonly)
Returns the value of attribute 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_type ⇒ Object (readonly)
Returns the value of attribute 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_code ⇒ Object (readonly)
Returns the value of attribute 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_duration ⇒ Object (readonly)
Returns the value of attribute evaluation_duration
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def evaluation_duration @evaluation_duration end |
#evaluation_duration_unit ⇒ Object (readonly)
Returns the value of attribute 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_code ⇒ Object (readonly)
Returns the value of attribute 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_unit ⇒ Object (readonly)
Returns the value of attribute 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_code ⇒ Object (readonly)
Returns the value of attribute 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_deadline ⇒ Object (readonly)
Returns the value of attribute extends_deadline
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def extends_deadline @extends_deadline end |
#funding_source ⇒ Object (readonly)
Returns the value of attribute funding_source
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def funding_source @funding_source end |
#informed ⇒ Object (readonly)
Returns the value of attribute informed
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def informed @informed end |
#items ⇒ Object (readonly)
Returns the value of attribute items
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def items @items end |
#name ⇒ Object (readonly)
Returns the value of attribute name
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def name @name end |
#payment_contact ⇒ Object (readonly)
Returns the value of attribute payment_contact
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def payment_contact @payment_contact end |
#payment_type_code ⇒ Object (readonly)
Returns the value of attribute 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_offers ⇒ Object (readonly)
Returns the value of attribute 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_justification ⇒ Object (readonly)
Returns the value of attribute publicity_justification
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def publicity_justification @publicity_justification end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def raw @raw end |
#renewable ⇒ Object (readonly)
Returns the value of attribute renewable
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def renewable @renewable end |
#renewal_period ⇒ Object (readonly)
Returns the value of attribute renewal_period
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def renewal_period @renewal_period end |
#renewal_value ⇒ Object (readonly)
Returns the value of attribute renewal_value
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def renewal_value @renewal_value end |
#requires_contraloria ⇒ Object (readonly)
Returns the value of attribute requires_contraloria
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def requires_contraloria @requires_contraloria end |
#site_visit_address ⇒ Object (readonly)
Returns the value of attribute 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_count ⇒ Object (readonly)
Returns the value of attribute stages_count
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def stages_count @stages_count end |
#stages_status ⇒ Object (readonly)
Returns the value of attribute stages_status
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def stages_status @stages_status end |
#status ⇒ Object (readonly)
Returns the value of attribute status
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def status @status end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def status_code @status_code end |
#status_label ⇒ Object (readonly)
Returns the value of attribute status_label
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def status_label @status_label end |
#template_based ⇒ Object (readonly)
Returns the value of attribute template_based
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def template_based @template_based end |
#tender_kind_code ⇒ Object (readonly)
Returns the value of attribute 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_method ⇒ Object (readonly)
Returns the value of attribute 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_code ⇒ Object (readonly)
Returns the value of attribute 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_type ⇒ Object (readonly)
Returns the value of attribute tender_type
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def tender_type @tender_type end |
#tender_type_code ⇒ Object (readonly)
Returns the value of attribute 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_amount ⇒ Object (readonly)
Returns the value of attribute visible_amount
5 6 7 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 5 def visible_amount @visible_amount end |
#works_status_code ⇒ Object (readonly)
Returns the value of attribute 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
.active ⇒ Object
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 |
.all ⇒ Object
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 |
.endpoint ⇒ Object
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
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_prefixes ⇒ Object
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_code ⇒ Object
287 288 289 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 287 def agency_code buyer&.code end |
#agency_name ⇒ Object
291 292 293 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 291 def agency_name buyer&.name end |
#allows_subcontracting? ⇒ Boolean
267 268 269 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 267 def allows_subcontracting? allows_subcontracting == true end |
#award_date ⇒ Object
307 308 309 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 307 def award_date dates&.award end |
#awarded? ⇒ Boolean
283 284 285 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 283 def awarded? status == :awarded || !award.nil? end |
#awarded_supplier_name ⇒ Object
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_rut ⇒ Object
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_date ⇒ Object
299 300 301 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 299 def closing_date dates&.closing end |
#creation_date ⇒ Object
295 296 297 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 295 def creation_date dates&.creation end |
#extends_deadline? ⇒ 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.
255 256 257 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 255 def has_contract? contract_status_code == 1 end |
#informed? ⇒ Boolean
226 227 228 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 226 def informed? informed == true end |
#inspect ⇒ Object 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_awards ⇒ Object
331 332 333 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 331 def item_awards Array(items).filter_map(&:award) end |
#private? ⇒ 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.
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
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
259 260 261 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 259 def public_works? works_status_code == 2 end |
#publication_date ⇒ Object
303 304 305 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 303 def publication_date dates&.publication end |
#renewable? ⇒ Boolean
279 280 281 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 279 def renewable? renewable == true end |
#requires_contraloria? ⇒ Boolean
245 246 247 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 245 def requires_contraloria? requires_contraloria == true end |
#summary? ⇒ 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_code ⇒ Object
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
275 276 277 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 275 def template_based? template_based == true end |
#visible_amount? ⇒ Boolean
263 264 265 |
# File 'lib/mercado_publico_cl/resources/tender.rb', line 263 def visible_amount? visible_amount == true end |