Class: PagSeguro::Authorization::Response
- Inherits:
-
Object
- Object
- PagSeguro::Authorization::Response
- Defined in:
- lib/pagseguro/authorization/response.rb
Instance Method Summary collapse
-
#initialize(response, object) ⇒ Response
constructor
A new instance of Response.
- #serialize ⇒ Object
- #serialize_collection ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response, object) ⇒ Response
Returns a new instance of Response.
4 5 6 7 |
# File 'lib/pagseguro/authorization/response.rb', line 4 def initialize(response, object) @response = response @object = object end |
Instance Method Details
#serialize ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pagseguro/authorization/response.rb', line 9 def serialize if success? xml = Nokogiri::XML(response.body).css('authorization').first serializer = ResponseSerializer.new(xml).serialize object.update_attributes(serializer) else object.errors.add(response) end object end |
#serialize_collection ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/pagseguro/authorization/response.rb', line 21 def serialize_collection if success? object. = else object.errors.add(response) end object end |
#success? ⇒ Boolean
31 32 33 |
# File 'lib/pagseguro/authorization/response.rb', line 31 def success? response.success? && response.xml? end |