Sha256: d96ea8bfeb4ce388024175fc52d86cd3dfb8570c0a205b1a3f81602112b67589
Contents?: true
Size: 1.58 KB
Versions: 1
Compression:
Stored size: 1.58 KB
Contents
module CorreiosSigep module LogisticReverse class BaseClient DEFAULT_TIMEOUT = 30 def initialize timeout = CorreiosSigep.configuration.timeout || DEFAULT_TIMEOUT user = CorreiosSigep.configuration.user password = CorreiosSigep.configuration.password options = { adapter: :net_http_persistent, proxy: CorreiosSigep.configuration.proxy, wsdl: wsdl, open_timeout: timeout, read_timeout: timeout, basic_auth: [user, password], headers: { 'SOAPAction' => '' } } options.delete(:proxy) unless options[:proxy] @client = Savon.client(options) end def wsdl @wsdl ||= if ENV['GEM_ENV'] == 'test' || CorreiosSigep.configuration.development? 'https://apphom.correios.com.br/logisticaReversaWS/logisticaReversaService/logisticaReversaWS?wsdl' else 'https://cws.correios.com.br/logisticaReversaWS/logisticaReversaService/logisticaReversaWS?wsdl' end end def invoke(method, message) @client.instance_variable_set( :@wsdl, Wasabi::Document.new(CorreiosSigep.configuration.wsdl_base_url) ) if wsdl_base_url_changed? @client.call(method, message: message) end private def wsdl_base_url_changed? wsdl_base_url && wsdl_base_url != @client.instance_variable_get(:@wsdl).document end def wsdl_base_url CorreiosSigep.configuration.wsdl_base_url end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
correios_sigep-2.2.0 | lib/correios_sigep/logistic_reverse/base_client.rb |