Class: MercadoPublicoCl::TenderItemAward

Inherits:
Data
  • Object
show all
Defined in:
lib/mercado_publico_cl/value_objects/tender_award.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount

Returns:

  • (Object)

    the current value of amount



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_award.rb', line 4

def amount
  @amount
end

#quantityObject (readonly)

Returns the value of attribute quantity

Returns:

  • (Object)

    the current value of quantity



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_award.rb', line 4

def quantity
  @quantity
end

#rawObject (readonly)

Returns the value of attribute raw

Returns:

  • (Object)

    the current value of raw



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_award.rb', line 4

def raw
  @raw
end

#supplier_branchObject (readonly)

Returns the value of attribute supplier_branch

Returns:

  • (Object)

    the current value of supplier_branch



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_award.rb', line 4

def supplier_branch
  @supplier_branch
end

#supplier_codeObject (readonly)

Returns the value of attribute supplier_code

Returns:

  • (Object)

    the current value of supplier_code



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_award.rb', line 4

def supplier_code
  @supplier_code
end

#supplier_nameObject (readonly)

Returns the value of attribute supplier_name

Returns:

  • (Object)

    the current value of supplier_name



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_award.rb', line 4

def supplier_name
  @supplier_name
end

#supplier_rutObject (readonly)

Returns the value of attribute supplier_rut

Returns:

  • (Object)

    the current value of supplier_rut



4
5
6
# File 'lib/mercado_publico_cl/value_objects/tender_award.rb', line 4

def supplier_rut
  @supplier_rut
end

Class Method Details

.from_payload(raw) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mercado_publico_cl/value_objects/tender_award.rb', line 13

def self.from_payload(raw)
  return nil if raw.nil? || raw.empty?

  new(
    supplier_code: Resources::Base.to_int(raw["CodigoEmpresa"] || raw["CodigoProveedor"]),
    supplier_rut: raw["RutProveedor"] || raw["RutSucursal"] || raw["Rut"],
    supplier_name: raw["NombreProveedor"] || raw["NombreOferente"] || raw["Nombre"],
    supplier_branch: raw["NombreSucursal"],
    quantity: Resources::Base.to_float(raw["Cantidad"]),
    amount: Resources::Base.to_float(raw["MontoUnitario"] || raw["Monto"]),
    raw: raw
  )
end

Instance Method Details

#inspectObject Also known as: to_s



27
28
29
# File 'lib/mercado_publico_cl/value_objects/tender_award.rb', line 27

def inspect
  "#<TenderItemAward supplier=#{supplier_name.inspect} qty=#{quantity}>"
end