Class: Paymaster::BaseResponse
- Inherits:
-
Object
- Object
- Paymaster::BaseResponse
- Defined in:
- lib/paymaster/base_response.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(args = {}) ⇒ BaseResponse
constructor
A new instance of BaseResponse.
Constructor Details
#initialize(args = {}) ⇒ BaseResponse
Returns a new instance of BaseResponse.
5 6 7 8 9 |
# File 'lib/paymaster/base_response.rb', line 5 def initialize(args={}) args.each do |k, v| public_send "#{k}=", v end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
3 4 5 |
# File 'lib/paymaster/base_response.rb', line 3 def data @data end |
Class Method Details
.parse(body) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/paymaster/base_response.rb', line 16 def parse(body) response = Hash.from_xml(body)["Response"] if response["Retval"].to_i != 1 Paymaster::RequestError.new(response) else response = response["Retdata"] response = response[root] if root attrs = {} response.each do |key, value| next unless field = fields[key] attrs[field[:name]] = send(field[:type], value) end new(attrs.merge(data: response)) end end |
Instance Method Details
#error? ⇒ Boolean
11 12 13 |
# File 'lib/paymaster/base_response.rb', line 11 def error? false end |