Class: Culqi::Sale

Inherits:
Object
  • Object
show all
Defined in:
lib/culqi/sale.rb

Constant Summary collapse

DEFAULTS =
{
  moneda:   'PEN',
  cod_pais: 'PE'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Sale

Returns a new instance of Sale.



22
23
24
# File 'lib/culqi/sale.rb', line 22

def initialize(attrs)
  attrs.each { |key, value| public_send("#{ key }=", value) }
end

Instance Attribute Details

#apellidosObject

Returns the value of attribute apellidos.



8
9
10
# File 'lib/culqi/sale.rb', line 8

def apellidos
  @apellidos
end

#ciudadObject

Returns the value of attribute ciudad.



8
9
10
# File 'lib/culqi/sale.rb', line 8

def ciudad
  @ciudad
end

#cod_paisObject

Returns the value of attribute cod_pais.



8
9
10
# File 'lib/culqi/sale.rb', line 8

def cod_pais
  @cod_pais
end

#codigo_comercioObject

Returns the value of attribute codigo_comercio.



8
9
10
# File 'lib/culqi/sale.rb', line 8

def codigo_comercio
  @codigo_comercio
end

#correo_electronicoObject

Returns the value of attribute correo_electronico.



8
9
10
# File 'lib/culqi/sale.rb', line 8

def correo_electronico
  @correo_electronico
end

#descripcionObject

Returns the value of attribute descripcion.



8
9
10
# File 'lib/culqi/sale.rb', line 8

def descripcion
  @descripcion
end

#direccionObject

Returns the value of attribute direccion.



8
9
10
# File 'lib/culqi/sale.rb', line 8

def direccion
  @direccion
end

#id_usuario_comercioObject

Returns the value of attribute id_usuario_comercio.



8
9
10
# File 'lib/culqi/sale.rb', line 8

def id_usuario_comercio
  @id_usuario_comercio
end

#monedaObject

Returns the value of attribute moneda.



8
9
10
# File 'lib/culqi/sale.rb', line 8

def moneda
  @moneda
end

#montoObject

Returns the value of attribute monto.



8
9
10
# File 'lib/culqi/sale.rb', line 8

def monto
  @monto
end

#nombresObject

Returns the value of attribute nombres.



8
9
10
# File 'lib/culqi/sale.rb', line 8

def nombres
  @nombres
end

#num_telObject

Returns the value of attribute num_tel.



8
9
10
# File 'lib/culqi/sale.rb', line 8

def num_tel
  @num_tel
end

#numero_pedidoObject

Returns the value of attribute numero_pedido.



8
9
10
# File 'lib/culqi/sale.rb', line 8

def numero_pedido
  @numero_pedido
end

Instance Method Details

#payloadObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/culqi/sale.rb', line 26

def payload
  {
    codigo_comercio:      (codigo_comercio || ENV['CULQI_CODIGO_COMERCIO']),
    numero_pedido:        numero_pedido,
    moneda:               (moneda || DEFAULTS[:moneda]),
    monto:                monto,
    descripcion:          descripcion[0..79],
    correo_electronico:   correo_electronico[0..49],
    cod_pais:             (cod_pais || DEFAULTS[:cod_pais]),
    ciudad:               ciudad,
    direccion:            direccion,
    num_tel:              num_tel[0..14],
    id_usuario_comercio:  id_usuario_comercio,
    nombres:              nombres[0..49],
    apellidos:            apellidos[0..49]
  }.to_json
end