Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to use proxy URL #76

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
10 changes: 5 additions & 5 deletions lib/mundi_api/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class Configuration
# The password to use with basic authentication
@basic_auth_password = 'TODO: Replace'

# The proxy server to use for the request
@proxy = nil

# The attribute accessors for public properties.
class << self
attr_accessor :array_serialization
attr_accessor :base_uri
attr_accessor :service_referer_name
attr_accessor :basic_auth_user_name
attr_accessor :basic_auth_password
attr_accessor :array_serialization, :base_uri, :service_referer_name, :basic_auth_user_name,
:basic_auth_password, :proxy
end
end
end
9 changes: 3 additions & 6 deletions lib/mundi_api/http/faraday_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def initialize(timeout: nil, cache: false,
faraday.request :multipart
faraday.request :url_encoded
faraday.ssl[:ca_file] = Certifi.where
faraday.proxy = Configuration.proxy if Configuration.proxy
faraday.request :retry, max: max_retries, interval: if max_retries &&
retry_interval
retry_interval
Expand All @@ -35,9 +36,7 @@ def execute_as_string(http_request)
http_request.query_url
) do |request|
request.headers = http_request.headers
unless http_request.parameters.empty?
request.body = http_request.parameters
end
request.body = http_request.parameters unless http_request.parameters.empty?
end
convert_response(response)
end
Expand All @@ -49,9 +48,7 @@ def execute_as_binary(http_request)
http_request.query_url
) do |request|
request.headers = http_request.headers
unless http_request.parameters.empty?
request.body = http_request.parameters
end
request.body = http_request.parameters unless http_request.parameters.empty?
end
convert_response(response)
end
Expand Down
13 changes: 5 additions & 8 deletions lib/mundi_api/mundi_api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,11 @@ def config
end

# Initializer with authentication and configuration parameters.
def initialize(service_referer_name: nil, basic_auth_user_name: nil,
basic_auth_password: nil)
Configuration.service_referer_name = service_referer_name if
service_referer_name
Configuration.basic_auth_user_name = basic_auth_user_name if
basic_auth_user_name
Configuration.basic_auth_password = basic_auth_password if
basic_auth_password
def initialize(service_referer_name: nil, basic_auth_user_name: nil, basic_auth_password: nil, proxy: nil)
Configuration.service_referer_name = service_referer_name if service_referer_name
Configuration.basic_auth_user_name = basic_auth_user_name if basic_auth_user_name
Configuration.basic_auth_password = basic_auth_password if basic_auth_password
Configuration.proxy = proxy if proxy
end
end
end
2 changes: 1 addition & 1 deletion mundi_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.add_dependency('test-unit', '~> 3.1', '>= 3.1.5')
s.add_dependency('certifi', '~> 2016')
s.add_dependency('faraday-http-cache', '~> 1.2', '>= 1.2.2')
s.required_ruby_version = '~> 2.0'
s.required_ruby_version = '< 3.1'
s.files = Dir['{bin,lib,man,test,spec}/**/*', 'README*', 'LICENSE*']
s.require_paths = ['lib']
end