Sha256: 0d524b62ddb1d64674f3ce15230d402b6e5987103f599804246583a00015fc1d
Contents?: true
Size: 1.56 KB
Versions: 8
Compression:
Stored size: 1.56 KB
Contents
class Cieloz::RequisicaoTransacao class DadosPedido include Cieloz::Helpers IDIOMAS = [ "PT", "EN", "ES" ] # portugues, ingles, espanhol attr_accessor :numero, :valor, :moeda, :data_hora, :descricao, :idioma, :soft_descriptor validates :numero, :valor, :moeda, :data_hora, presence: true validates :numero, length: { maximum: 20 } validates :valor, length: { maximum: 12 } validates :valor, numericality: { only_integer: true }, unless: "@valor.blank?" validates :descricao, length: { maximum: 1024 } validates :idioma, inclusion: { in: IDIOMAS } validates :soft_descriptor, length: { maximum: 13 } def self.map(source, opts={}) mappings = attrs_from source, opts, :numero, :valor, :descricao, :data_hora, :moeda, :idioma, :soft_descriptor num, val, desc, time, cur, lang, soft = mappings val = (val * 100).round unless val.nil? or val.integer? time ||= Time.now cur ||= Cieloz::Configuracao.moeda lang ||= Cieloz::Configuracao.idioma soft ||= Cieloz::Configuracao.soft_descriptor new source: source, opts: opts, data_hora: time, numero: num, valor: val, moeda: cur, idioma: lang, descricao: desc, soft_descriptor: soft end def attributes { numero: @numero, valor: @valor, moeda: @moeda, data_hora: @data_hora.strftime("%Y-%m-%dT%H:%M:%S"), descricao: @descricao, idioma: @idioma, soft_descriptor: @soft_descriptor } end end end
Version data entries
8 entries across 8 versions & 1 rubygems