diff --git a/Gemfile.lock b/Gemfile.lock index 9f155d8..e11a0cd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - fnsapi (1.1.2) + fnsapi (1.1.3) savon GEM diff --git a/README.md b/README.md index 2c5fb38..1d9090a 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ fnsapi_user_token = nil get_message_timeout = 60 log_enabled = false logger = Logger.new($stdout) +proxy_url = nil ``` ### get message timeout @@ -62,6 +63,12 @@ If this option id true, all SAVON logs will be written in logger. By default it's a `stdout` stream but if you use this gem with Rails application, logger will be configurated as `Rails.logger` automaticaly. +### proxy_url + +By default is not set. FNS API check requests permissions by IP address, if you have multiple servers, you can set up yor own proxy server and make requests from him. +Example: `'http://user:pass@host.domain:port'` or other formats supported by `savon gem` + + ## Usage There are two methods: diff --git a/lib/fnsapi/base_service.rb b/lib/fnsapi/base_service.rb index fb2a5d5..aec53ae 100644 --- a/lib/fnsapi/base_service.rb +++ b/lib/fnsapi/base_service.rb @@ -23,7 +23,8 @@ def client_params(additional_params = {}) namespaces: namespaces, env_namespace: :soap, log: Fnsapi.configuration.log_enabled, - logger: Fnsapi.configuration.logger + logger: Fnsapi.configuration.logger, + proxy: Fnsapi.configuration.proxy_url }.merge(additional_params) end diff --git a/lib/fnsapi/configuration.rb b/lib/fnsapi/configuration.rb index 2e1742e..483d2bc 100644 --- a/lib/fnsapi/configuration.rb +++ b/lib/fnsapi/configuration.rb @@ -11,7 +11,8 @@ class Configuration :tmp_file_name, :get_message_timeout, :log_enabled, - :logger + :logger, + :proxy_url attr_writer :fnsapi_user_token, :fnsapi_master_key diff --git a/lib/fnsapi/version.rb b/lib/fnsapi/version.rb index c13d1cc..ca8f9b0 100644 --- a/lib/fnsapi/version.rb +++ b/lib/fnsapi/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Fnsapi - VERSION = '1.1.2' + VERSION = '1.1.3' end diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb index 4014938..0263862 100644 --- a/spec/configuration_spec.rb +++ b/spec/configuration_spec.rb @@ -36,6 +36,10 @@ expect(config.logger).to be_a(Logger) end + it 'returns correct value for default proxy url' do + expect(config.proxy_url).to be_nil + end + context 'when used in Rails app' do before do class Rails; end @@ -100,6 +104,12 @@ class Rails; end config.fnsapi_user_token = 'test' expect(config.fnsapi_user_token).to eq('test') end + + it 'changes value for proxy_url' do + expect { config.proxy_url = 'http://user:pass@host:3128' }.to( + change { config.proxy_url }.from(nil).to('http://user:pass@host:3128') + ) + end end describe 'required attributes' do