Sha256: 927f2ebce9e9dccbed36d64864d66b2b993935b41e513f3ddc845af7002228b6

Contents?: true

Size: 959 Bytes

Versions: 4

Compression:

Stored size: 959 Bytes

Contents

require 'savon'

module NfseGyn
  class SoapClient
    def call(method, object)
      xml = "<ArquivoXML><![CDATA[#{object.to_xml}]]></ArquivoXML>"
      payload = client.call(method, message: xml)
      object.class::Response.new payload
    end

    private

    def client
      log = NfseGyn.configuration.log_level != :none
      @client ||= Savon.client(
        wsdl: NfseGyn.configuration.wsdl,
        env_namespace: :soap,
        namespace_identifier: nil,
        element_form_default: :unqualified,
        ssl_verify_mode: :none,
        ssl_cert_file: NfseGyn.configuration.cert_path,
        ssl_cert_key_file: NfseGyn.configuration.cert_key_path,
        ssl_ca_cert_file: NfseGyn.configuration.ca_cert_path,
        ssl_cert_key_password: NfseGyn.configuration.cert_key_password,
        log_level: log ? NfseGyn.configuration.log_level : nil,
        log: log,
        open_timeout: 120,
        read_timeout: 120
      )
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nfse_gyn-0.3.0 lib/nfse_gyn/soap_client.rb
nfse_gyn-0.2.0 lib/nfse_gyn/soap_client.rb
nfse_gyn-0.1.2 lib/nfse_gyn/soap_client.rb
nfse_gyn-0.1.1 lib/nfse_gyn/soap_client.rb