From 1ee55275561261acf3c15dde6782cc29fd5c7b1b Mon Sep 17 00:00:00 2001 From: dbecker-stripe <88861694+dbecker-stripe@users.noreply.github.com> Date: Mon, 13 Jun 2022 16:20:47 -0700 Subject: [PATCH] Add optional proxy for NetSuite requests through Savon (#547) This change adds an optional `proxy` attribute on the `NetSuite::Configuration` that is passed to the generated Savon client used for requests to NetSuite. --- lib/netsuite/configuration.rb | 13 +++++++++++++ spec/netsuite/configuration_spec.rb | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/lib/netsuite/configuration.rb b/lib/netsuite/configuration.rb index 936cbb24..c5063d52 100644 --- a/lib/netsuite/configuration.rb +++ b/lib/netsuite/configuration.rb @@ -27,6 +27,7 @@ def connection(params={}, credentials={}) logger: logger, log_level: log_level, log: !silent, # turn off logging entirely if configured + proxy: proxy, }.update(params)) cache_wsdl(client) return client @@ -394,5 +395,17 @@ def log_level(value = nil) def log_level=(value) attributes[:log_level] = value end + + def proxy=(proxy) + attributes[:proxy] = proxy + end + + def proxy(proxy = nil) + if proxy + self.proxy = proxy + else + attributes[:proxy] + end + end end end diff --git a/spec/netsuite/configuration_spec.rb b/spec/netsuite/configuration_spec.rb index 67ecffaf..9879a1be 100644 --- a/spec/netsuite/configuration_spec.rb +++ b/spec/netsuite/configuration_spec.rb @@ -476,4 +476,25 @@ end end + describe '#proxy' do + it 'defaults to nil' do + expect(config.proxy).to be_nil + end + + it 'can be set with proxy=' do + config.proxy = "https://my-proxy" + + expect(config.proxy).to eql("https://my-proxy") + + # ensure no exception is raised + config.connection + end + + it 'can be set with proxy(value)' do + config.proxy("https://my-proxy") + + expect(config.proxy).to eql("https://my-proxy") + end + end + end