Method: Nps::SoapClient#setup

Defined in:
lib/nps/soap_client.rb

#setupObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/nps/soap_client.rb', line 34

def setup
  client_config = {
      ssl_verify_mode: :none,
      wsdl: File.join(File.dirname(File.expand_path(__FILE__)), "/wsdl/" + @wsdl),
      logger: @logger,
      open_timeout: @open_timeout,
      read_timeout: @read_timeout,
      pretty_print_xml: true,
      log: @log
  }

  if @log_level
    lvl_config = {
      log_level: :debug
    }
    client_config.merge!(lvl_config)
  end
  
  if @verify_ssl
    ssl_config = {
        ssl_verify_mode: :peer,
        ssl_ca_cert_file: Certifi.where
    }
    client_config.merge!(ssl_config)
  end

  if @proxy
    proxy = {
        proxy: @proxy
    }
    client_config.merge!(proxy)
  end

  if @proxy_username
    proxy_auth = {
      headers: { "Proxy-Authorization" => "Basic #{secret}" }
    }
    client_config.merge!(proxy_auth)
  end


  @client = Savon.client client_config

end