Class: PagSeguro::Session::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/pagseguro/session/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(response, session) ⇒ Response

Returns a new instance of Response.



4
5
6
7
# File 'lib/pagseguro/session/response.rb', line 4

def initialize(response, session)
  @response = response
  @session = session
end

Instance Method Details

#serializeObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/pagseguro/session/response.rb', line 9

def serialize
  if success?
    xml = Nokogiri::XML(response.body).css("session").first
    session.update_attributes(ResponseSerializer.new(xml).serialize)
  else
    session.errors.add(response)
  end

  session
end

#success?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/pagseguro/session/response.rb', line 20

def success?
  response.success? && response.xml?
end