class CobroDigital::Operador
Attributes
client[RW]
http_method[RW]
render[RW]
response[RW]
webservice[RW]
Public Class Methods
new(attrs={})
click to toggle source
# File lib/cobro_digital/operador.rb, line 6 def initialize(attrs={}) @http_method = attrs[:http_method] @webservice = attrs[:webservice] @render = attrs[:render] @client = nil end
Public Instance Methods
call(id_comercio, sid, opt = {})
click to toggle source
# File lib/cobro_digital/operador.rb, line 17 def call(id_comercio, sid, opt = {}) @client = CobroDigital::Client.new(opt.merge(:id_comercio => id_comercio, :sid => sid, :http_method => http_method)) @response = @client.call(request) end
parse_response()
click to toggle source
# File lib/cobro_digital/operador.rb, line 22 def parse_response output = response.body[:webservice_cobrodigital_response][:output] parsed_response = JSON.parse(output) raw_datos = parsed_response['datos'] || [] datos = raw_datos.map do |row| row.is_a?(Array) ? row : (JSON.parse(row) rescue row) end.flatten { resultado: (parsed_response['ejecucion_correcta'] == '1'), log: parsed_response['log'], datos: datos } end
request()
click to toggle source
# File lib/cobro_digital/operador.rb, line 13 def request { :metodo_webservice => @webservice }.merge(render) end