Class: PagSeguro::TransactionCancellation::Response

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

Instance Method Summary collapse

Constructor Details

#initialize(response, object) ⇒ Response

Returns a new instance of Response.



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

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

Instance Method Details

#serializeObject



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

def serialize
  if success?
    xml = Nokogiri::XML(response.body)
    serializer = ResponseSerializer.new(xml).serialize
    object.update_attributes(serializer)
  else
    object.errors.add(response)
  end

  object
end

#success?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/pagseguro/transaction_cancellation/response.rb', line 21

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