Class: MercadoPublicoCl::Query
- Inherits:
-
Object
- Object
- MercadoPublicoCl::Query
- Defined in:
- lib/mercado_publico_cl/query.rb
Constant Summary collapse
- RESOURCE_STATUS_ENUMS =
{ tender: Enums::TenderStatus, purchase_order: Enums::PurchaseOrderStatus }.freeze
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
-
#initialize(resource:, params: {}) ⇒ Query
constructor
A new instance of Query.
- #to_h ⇒ Object
Constructor Details
#initialize(resource:, params: {}) ⇒ Query
Returns a new instance of Query.
12 13 14 15 16 17 |
# File 'lib/mercado_publico_cl/query.rb', line 12 def initialize(resource:, params: {}) @resource = resource validate_resource! @params = sanitize(params) validate! end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/mercado_publico_cl/query.rb', line 10 def params @params end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
10 11 12 |
# File 'lib/mercado_publico_cl/query.rb', line 10 def resource @resource end |
Instance Method Details
#to_h ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mercado_publico_cl/query.rb', line 19 def to_h result = {} if params[:code] result[:codigo] = params[:code] return result end result[:fecha] = DateFormatter.call(effective_date) if needs_date? result[:estado] = api_status if params[:status] result[:proveedor] = params[:supplier_code] if params[:supplier_code] result[:CodigoOrganismo] = params[:agency_code] if params[:agency_code] result end |