class Transbank::Oneclick::Request
Attributes
action[RW]
client[RW]
rescue_exceptions[RW]
xml[RW]
Public Class Methods
new(action, params = {}, opt = {})
click to toggle source
# File lib/transbank/oneclick/request.rb, line 6 def initialize(action, params = {}, opt = {}) opt = { rescue_exceptions: Transbank::Oneclick.configuration.rescue_exceptions, http_options: {} }.merge(opt) self.action = action self.rescue_exceptions = opt[:rescue_exceptions] self.xml = Document.new(action, params) self.client = Client.new opt.delete(:http_options) end
Public Instance Methods
response()
click to toggle source
# File lib/transbank/oneclick/request.rb, line 18 def response @Response ||= begin Response.new client.post(xml.canonicalize), action rescue match_class(rescue_exceptions) => error ExceptionResponse.new error, action end end
Private Instance Methods
match_class(exceptions)
click to toggle source
# File lib/transbank/oneclick/request.rb, line 27 def match_class(exceptions) m = Module.new (class << m; self; end).instance_eval do define_method(:===) do |error| (exceptions || []).include? error.class end end m end