Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add class that represents authentication node in the xml

  • Loading branch information...
commit 5e948fbfe96e31793dbe82daba80502b48843dbb 1 parent cc88702
@rafaelss authored
View
2  lib/cielo.rb
@@ -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"
View
12 lib/cielo/authentication.rb
@@ -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
1  lib/cielo/transaction.rb
@@ -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
View
11 spec/cielo/authentication_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.