Class: OnlinePayments::SDK::ProxyConfiguration
- Inherits:
-
Object
- Object
- OnlinePayments::SDK::ProxyConfiguration
- Defined in:
- lib/onlinepayments/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.
23 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/onlinepayments/sdk/proxy_configuration.rb', line 23 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, 'scheme is required' unless scheme && !scheme.strip.empty? raise ArgumentError, 'host is required' unless host && !host.strip.empty? raise ArgumentError, 'port is required' unless port&.positive? && port <= 65535 @host = host @port = port @username = username @password = password @scheme = scheme end |
Instance Attribute Details
#host ⇒ String
Proxy hostname
10 11 12 |
# File 'lib/onlinepayments/sdk/proxy_configuration.rb', line 10 def host @host end |
#password ⇒ String
Proxy authentication password
10 11 12 |
# File 'lib/onlinepayments/sdk/proxy_configuration.rb', line 10 def password @password end |
#port ⇒ Integer
Proxy port
10 11 12 |
# File 'lib/onlinepayments/sdk/proxy_configuration.rb', line 10 def port @port end |
#scheme ⇒ String
Proxy scheme (http or https)
10 11 12 |
# File 'lib/onlinepayments/sdk/proxy_configuration.rb', line 10 def scheme @scheme end |
#username ⇒ String
Proxy authentication username
10 11 12 |
# File 'lib/onlinepayments/sdk/proxy_configuration.rb', line 10 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/onlinepayments/sdk/proxy_configuration.rb', line 56 def proxy_uri "#{scheme}://#{host}:#{port}" end |
#to_s ⇒ Object
60 61 62 |
# File 'lib/onlinepayments/sdk/proxy_configuration.rb', line 60 def to_s proxy_uri end |