Skip to content

Commit

Permalink
Add optional proxy for NetSuite requests through Savon (#547)
Browse files Browse the repository at this point in the history
This change adds an optional `proxy` attribute on the `NetSuite::Configuration` that is passed to the generated Savon client used for requests to NetSuite.
  • Loading branch information
dbecker-stripe authored Jun 13, 2022
1 parent a291ac3 commit 1ee5527
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/netsuite/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
21 changes: 21 additions & 0 deletions spec/netsuite/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1ee5527

Please sign in to comment.