Class: Facturapi::Service::Procesar

Inherits:
Object
  • Object
show all
Defined in:
lib/facturapi/service/procesar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dte) ⇒ Procesar

Returns a new instance of Procesar.



7
8
9
10
# File 'lib/facturapi/service/procesar.rb', line 7

def initialize(dte)
  @dte = dte
  @client = Facturapi::Client.new
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/facturapi/service/procesar.rb', line 5

def client
  @client
end

#dteObject

Returns the value of attribute dte.



4
5
6
# File 'lib/facturapi/service/procesar.rb', line 4

def dte
  @dte
end

Instance Method Details

#sendObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/facturapi/service/procesar.rb', line 12

def send
  file = Base64.strict_encode64(dte.as_node.to_s)
  params = { file: file, formato: 2 }
  response = client.call(:procesar, params)
  Nokogiri::XML(response)
  # doc = Nokogiri::XML(response)
  # ok = doc.css('WSPLANO>Resultado').text
  # mensaje = doc.css('WSPLANO>Mensaje').text
  # error = doc.css('Documento>Error').text
end