Class: Worldline::Connect::SDK::ProxyConfiguration
- Inherits:
-
Object
- Object
- Worldline::Connect::SDK::ProxyConfiguration
- Defined in:
- lib/worldline/connect/sdk/proxy_configuration.rb
Overview
Contains the URL, username and password of a proxy.
Instance Attribute Summary collapse
-
#host ⇒ String
Proxy hostname.
-
#password ⇒ String
Proxy authentication password.
-
#port ⇒ Integer
Proxy port.
-
#scheme ⇒ String
Proxy scheme (http or https).
-
#username ⇒ String
Proxy authentication username.
Instance Method Summary collapse
-
#initialize(args) ⇒ ProxyConfiguration
constructor
Initialize a new ProxyConfiguration from the parameter hash.
-
#proxy_uri ⇒ String
A URL string representation of the proxy, excluding authentication.
- #to_s ⇒ Object
Constructor Details
#initialize(args) ⇒ ProxyConfiguration
Initialize a new ProxyConfiguration from the parameter hash. In order to be complete either host, port and scheme, or an address is required.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/worldline/connect/sdk/proxy_configuration.rb', line 24 def initialize(args) host = args[:host] port = args[:port] username = args[:username] password = args[:password] scheme = args[:scheme] || 'http' # Don't switch the order, a given address overrides host, port and username address = args[:address] host = address.host if address port = address.port if address scheme = address.scheme if address raise ArgumentError.new('scheme is required') unless scheme and not scheme.strip.empty? raise ArgumentError.new('host is required') unless host and not host.strip.empty? raise ArgumentError.new('port is required') unless port and port > 0 and port <= 65535 @host = host @port = port @username = username @password = password @scheme = scheme end |
Instance Attribute Details
#host ⇒ String
Proxy hostname
11 12 13 |
# File 'lib/worldline/connect/sdk/proxy_configuration.rb', line 11 def host @host end |
#password ⇒ String
Proxy authentication password
11 12 13 |
# File 'lib/worldline/connect/sdk/proxy_configuration.rb', line 11 def password @password end |
#port ⇒ Integer
Proxy port
11 12 13 |
# File 'lib/worldline/connect/sdk/proxy_configuration.rb', line 11 def port @port end |
#scheme ⇒ String
Proxy scheme (http or https)
11 12 13 |
# File 'lib/worldline/connect/sdk/proxy_configuration.rb', line 11 def scheme @scheme end |
#username ⇒ String
Proxy authentication username
11 12 13 |
# File 'lib/worldline/connect/sdk/proxy_configuration.rb', line 11 def username @username end |
Instance Method Details
#proxy_uri ⇒ String
Returns a URL string representation of the proxy, excluding authentication.
56 57 58 |
# File 'lib/worldline/connect/sdk/proxy_configuration.rb', line 56 def proxy_uri "#{scheme}://#{host}:#{port}" end |
#to_s ⇒ Object
60 61 62 |
# File 'lib/worldline/connect/sdk/proxy_configuration.rb', line 60 def to_s proxy_uri end |