Class: Ingenico::Connect::SDK::ProxyConfiguration
- Inherits:
-
Object
- Object
- Ingenico::Connect::SDK::ProxyConfiguration
- Defined in:
- lib/ingenico/connect/sdk/proxy_configuration.rb
Overview
Contains the url, username and password of a proxy.
Instance Attribute Summary collapse
-
#host ⇒ Object
proxy hostname.
-
#password ⇒ Object
proxy authentication password.
-
#port ⇒ Object
proxy port.
-
#scheme ⇒ Object
proxy scheme (http or https).
-
#username ⇒ Object
proxy authentication username.
Instance Method Summary collapse
-
#initialize(args) ⇒ ProxyConfiguration
constructor
Initialize a new ProxyConfiguration from the parameter hash.
-
#proxy_uri ⇒ Object
Returns 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. Arguments read from the hash are:
- host
-
Host part of the url to the proxy.
- port
-
Port the proxy will be accessed through.
- scheme
-
HTTP scheme used to communicate with the proxy (HTTP or HTTPS).
- address
-
Full uri to the proxy excluding username and password. If given this uri takes precedence over individual host, port and scheme.
- username
-
Username used in authentication to the proxy.
- password
-
Password used to authenticate to the proxy.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ingenico/connect/sdk/proxy_configuration.rb', line 16 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 ⇒ Object
proxy hostname
45 46 47 |
# File 'lib/ingenico/connect/sdk/proxy_configuration.rb', line 45 def host @host end |
#password ⇒ Object
proxy authentication password
54 55 56 |
# File 'lib/ingenico/connect/sdk/proxy_configuration.rb', line 54 def password @password end |
#port ⇒ Object
proxy port
48 49 50 |
# File 'lib/ingenico/connect/sdk/proxy_configuration.rb', line 48 def port @port end |
#scheme ⇒ Object
proxy scheme (http or https)
42 43 44 |
# File 'lib/ingenico/connect/sdk/proxy_configuration.rb', line 42 def scheme @scheme end |
#username ⇒ Object
proxy authentication username
51 52 53 |
# File 'lib/ingenico/connect/sdk/proxy_configuration.rb', line 51 def username @username end |
Instance Method Details
#proxy_uri ⇒ Object
Returns a url string representation of the proxy, excluding authentication.
57 58 59 |
# File 'lib/ingenico/connect/sdk/proxy_configuration.rb', line 57 def proxy_uri "#{scheme}://#{host}:#{port}" end |
#to_s ⇒ Object
61 62 63 |
# File 'lib/ingenico/connect/sdk/proxy_configuration.rb', line 61 def to_s proxy_uri end |