Class: Transbank::Webpay::Response
- Inherits:
-
Object
- Object
- Transbank::Webpay::Response
- Includes:
- Helper, Reader, Validations
- Defined in:
- lib/transbank/webpay/response.rb
Constant Summary
Constants included from Helper
Helper::XS_DATE_TIME, Helper::XS_INTEGER
Constants included from Reader
Transbank::Webpay::Reader::RESPONSE_CODE
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Attributes included from Reader
Attributes included from Validations
Instance Method Summary collapse
- #exception? ⇒ Boolean
- #http_code ⇒ Object
-
#initialize(content, action, params) ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Methods included from Helper
#camelcase, #typecasting, #underscore, #xml_to_hash
Methods included from Reader
#attributes?, #body, #doc, #response_code_display, #xml_error_display
Methods included from Validations
#errors_display, #valid?, #validate_response!
Constructor Details
#initialize(content, action, params) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 15 16 17 18 |
# File 'lib/transbank/webpay/response.rb', line 10 def initialize(content, action, params) @content = content @action = action @params = params @attributes = xml_to_hash(xml_return) @errors = [] validate_response! end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
39 40 41 |
# File 'lib/transbank/webpay/response.rb', line 39 def method_missing(method_name, *args, &block) attributes.respond_to?(method_name) && attributes.send(method_name) || super end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/transbank/webpay/response.rb', line 8 def attributes @attributes end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
8 9 10 |
# File 'lib/transbank/webpay/response.rb', line 8 def exception @exception end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/transbank/webpay/response.rb', line 8 def params @params end |
Instance Method Details
#exception? ⇒ Boolean
31 32 33 |
# File 'lib/transbank/webpay/response.rb', line 31 def exception? false end |
#http_code ⇒ Object
20 21 22 |
# File 'lib/transbank/webpay/response.rb', line 20 def http_code content.code end |
#inspect ⇒ Object
24 25 26 27 28 29 |
# File 'lib/transbank/webpay/response.rb', line 24 def inspect result = ["valid: #{valid?}"] result << attributes.inspect if attributes? result << "error: \"#{errors_display}\"" if errors.any? "#<#{self.class} #{result.join(', ')}>" end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
43 44 45 |
# File 'lib/transbank/webpay/response.rb', line 43 def respond_to_missing?(method_name, include_private = false) attributes.respond_to?(method_name, include_private) || super end |