Sha256: 5041747132d0f7e0e9aa2bae96f0a83fdb0ac399783a15c5114a34dc0b11c6b4

Contents?: true

Size: 769 Bytes

Versions: 1

Compression:

Stored size: 769 Bytes

Contents

module Cieloz
  class Requisicao
    class Resposta
      include ActiveModel::Serializers::Xml
      include Helpers

      STATUSES = {
        "0" => :criada,
        "1" => :em_andamento,
        "2" => :autenticada,
        "3" => :nao_autenticada,
        "4" => :autorizada,
        "5" => :nao_autorizada,
        "6" => :capturada,
        "9" => :cancelada,
        "10" => :em_autenticacao,
        "12" => :em_cancelamento
      }

      attr_reader :xml

      def self.from xml
        obj = new.from_xml xml
        obj.instance_variable_set :@xml, xml
        obj
      end

      STATUSES.each do |_, status_type|
        define_method "#{status_type}?" do
          success? and STATUSES[status] == status_type
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cieloz-0.0.2 lib/cieloz/requisicao/resposta.rb