Permalink
Browse files

add class that represents authentication node in the xml

  • Loading branch information...
1 parent cc88702 commit 5e948fbfe96e31793dbe82daba80502b48843dbb @rafaelss committed May 23, 2012
Showing with 26 additions and 0 deletions.
  1. +2 −0 lib/cielo.rb
  2. +12 −0 lib/cielo/authentication.rb
  3. +1 −0 lib/cielo/transaction.rb
  4. +11 −0 spec/cielo/authentication_spec.rb
View
@@ -14,6 +14,8 @@ module Cielo
autoload :TransactionRequest, "cielo/transaction_request"
autoload :Transaction, "cielo/transaction"
+ autoload :Authentication, "cielo/authentication"
+
autoload :AuthorizationRequest, "cielo/authorization_request"
autoload :Authorization, "cielo/authorization"
@@ -0,0 +1,12 @@
+module Cielo
+ class Authentication
+ include HappyMapper
+
+ tag "autenticacao"
+ element :code, Integer, :tag => "codigo"
+ element :message, String, :tag => "mensagem"
+ element :time, Time, :tag => "data-hora"
+ element :total, Integer, :tag => "valor"
+ element :eci, Integer
+ end
+end
View
@@ -8,6 +8,7 @@ class Transaction
element :status, Integer
element :authentication_url, String, :tag => "url-autenticacao"
+ has_one :authentication, Authentication
has_one :authorization, Authorization
has_one :capture, Capture
has_one :cancelation, Cancelation
@@ -0,0 +1,11 @@
+require "spec_helper"
+
+describe Cielo::Authentication do
+ let(:xml) { '<autenticacao><codigo>5</codigo><mensagem>Transacao sem autenticacao</mensagem><data-hora>2012-05-23T12:20:26.831-03:00</data-hora><valor>2390</valor><eci>1</eci></autenticacao>' }
+ subject { described_class.parse(xml, :single => true) }
+ its(:code) { should == 5 }
+ its(:message) { should == "Transacao sem autenticacao" }
+ its(:time) { should == Time.parse("2012-05-23T12:20:26.831-03:00") }
+ its(:total) { should == 2390 }
+ its(:eci) { should == 1 }
+end

0 comments on commit 5e948fb

Please sign in to comment.