Class: CobroDigital::Operador
- Inherits:
-
Object
- Object
- CobroDigital::Operador
- Defined in:
- lib/cobro_digital/operador.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#render ⇒ Object
Returns the value of attribute render.
-
#response ⇒ Object
Returns the value of attribute response.
-
#webservice ⇒ Object
Returns the value of attribute webservice.
Instance Method Summary collapse
- #call(id_comercio, sid, opt = {}) ⇒ Object
-
#initialize(attrs = {}) ⇒ Operador
constructor
A new instance of Operador.
- #parse_response ⇒ Object
- #request ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Operador
Returns a new instance of Operador.
6 7 8 9 10 |
# File 'lib/cobro_digital/operador.rb', line 6 def initialize(attrs={}) @http_method = attrs[:http_method] @webservice = attrs[:webservice] @render = attrs[:render] end |
Instance Attribute Details
#http_method ⇒ Object
Returns the value of attribute http_method.
4 5 6 |
# File 'lib/cobro_digital/operador.rb', line 4 def http_method @http_method end |
#render ⇒ Object
Returns the value of attribute render.
4 5 6 |
# File 'lib/cobro_digital/operador.rb', line 4 def render @render end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/cobro_digital/operador.rb', line 4 def response @response end |
#webservice ⇒ Object
Returns the value of attribute webservice.
4 5 6 |
# File 'lib/cobro_digital/operador.rb', line 4 def webservice @webservice end |
Instance Method Details
#call(id_comercio, sid, opt = {}) ⇒ Object
16 17 18 19 |
# File 'lib/cobro_digital/operador.rb', line 16 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 ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cobro_digital/operador.rb', line 21 def parse_response parsed_response = JSON.parse(response.body[:webservice_cobrodigital_response][:output]) datos = [] if parsed_response['datos'].present? parsed_response['datos'].each do |data| _data = data.split("\"") _data.delete("") datos << _data end end { resultado: (parsed_response['ejecucion_correcta'] == '1'), log: parsed_response['log'], datos: datos.flatten } end |
#request ⇒ Object
12 13 14 |
# File 'lib/cobro_digital/operador.rb', line 12 def request { :metodo_webservice => @webservice }.merge(render) end |