Module: NfePaulistana

Defined in:
lib/nfe-paulistana.rb,
lib/nfe-paulistana/gateway.rb,
lib/nfe-paulistana/version.rb,
lib/nfe-paulistana/response.rb,
lib/nfe-paulistana/xml_builder.rb

Defined Under Namespace

Classes: Gateway, Response, XmlBuilder

Constant Summary collapse

WSDL =
'https://nfe.prefeitura.sp.gov.br/ws/lotenfe.asmx?wsdl'
VERSION =
"1.0.2"

Class Method Summary collapse

Class Method Details

.enviar(data = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/nfe-paulistana.rb', line 13

def self.enviar(data = {})
  certificado = OpenSSL::PKCS12.new(File.read(data[:cert_path]), data[:cert_pass]) 
  client = get_client(certificado)

  begin
    response = client.call(:envio_rps, message: {
      input: [ 
          "EnvioRPSRequest", 
            {"xmlns" => "http://www.prefeitura.sp.gov.br/nfe"}
      ],
      body: XmlBuilder.new.xml_for(:envio_rps, data, certificado),
      version: 2
    })
    Response.new(xml: response.hash[:envio_rps_response][:retorno_xml], method: :envio_rps_response)
  rescue Savon::Error => error
  end
end