Class: PagSeguro::ManualSubscriptionCharger::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, object) ⇒ Response

Returns a new instance of Response.



10
11
12
13
# File 'lib/pagseguro/manual_subscription_charger/response.rb', line 10

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

Instance Attribute Details

#objectObject (readonly)

Set the boject that will receive errors or updates



8
9
10
# File 'lib/pagseguro/manual_subscription_charger/response.rb', line 8

def object
  @object
end

#responseObject (readonly)

The http response.



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

def response
  @response
end

Instance Method Details

#serializeObject



15
16
17
18
19
20
21
22
23
# File 'lib/pagseguro/manual_subscription_charger/response.rb', line 15

def serialize
  if success?
    object.update_attributes(ResponseSerializer.new(xml).serialize)
  else
    object.errors.add response
  end

  object
end

#success?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/pagseguro/manual_subscription_charger/response.rb', line 25

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