Class: PagSeguro::AuthorizationRequest::Response

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

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



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

def initialize(response)
  @response = response
end

Instance Method Details

#serializeObject



8
9
10
11
12
13
14
15
# File 'lib/pagseguro/authorization_request/response.rb', line 8

def serialize
  if success?
    xml = Nokogiri::XML(response.body).css('authorizationRequest').first
    ResponseSerializer.new(xml).serialize
  else
    { errors: Errors.new(response) }
  end
end

#success?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/pagseguro/authorization_request/response.rb', line 17

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