Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
fnsapi (1.1.2)
fnsapi (1.1.3)
savon

GEM
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion lib/fnsapi/base_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion lib/fnsapi/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/fnsapi/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Fnsapi
VERSION = '1.1.2'
VERSION = '1.1.3'
end
10 changes: 10 additions & 0 deletions spec/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down