Class: OnlinePayments::SDK::EndpointConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/onlinepayments/sdk/endpoint_configuration.rb

Overview

Base class for configuration classes in the SDK.

Direct Known Subclasses

CommunicatorConfiguration

Constant Summary collapse

DEFAULT_CONNECT_TIMEOUT =
10
DEFAULT_SOCKET_TIMEOUT =
10
DEFAULT_MAX_CONNECTIONS =
10

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(properties = nil, prefix = nil) ⇒ EndpointConfiguration

Initializes a new EndpointConfiguration.

The given properties is searched for settings using properties[prefix + ‘.setting_name’] The following settings are searched:

endpoint

This property is searched for endpoint.host, endpoint.scheme and endpoint.port. The found host, scheme and port are used to construct the base URL to the Online Payments platform.

connectTimeout

The number of seconds before a connection attempt with the Online Payments platform times out.

socketTimeout

The number of seconds before a timeout occurs when transmitting data to or from the Online Payments platform.

maxConnections

The number of connections with the Online Payments platform that are kept alive in the connection pool. These connections will be reused when possible.

proxy

This property is searched for proxy.uri, proxy.username and proxy.password. The found URI, username and password are used for connecting to the Online Payments platform using a proxy.

integrator

Name of the integrator

shoppingCartExtension

Will be used to initialize a Domain::ShoppingCartExtension.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/onlinepayments/sdk/endpoint_configuration.rb', line 54

def initialize(properties = nil, prefix = nil)
  return unless properties

  @api_endpoint = get_endpoint(properties, prefix)
  @connect_timeout = get_property(properties, "#{prefix}.connectTimeout", DEFAULT_CONNECT_TIMEOUT)
  @socket_timeout = get_property(properties, "#{prefix}.socketTimeout", DEFAULT_SOCKET_TIMEOUT)
  @max_connections = get_property(properties, "#{prefix}.maxConnections", DEFAULT_MAX_CONNECTIONS)

  proxy_uri = properties["#{prefix}.proxy.uri"]
  if proxy_uri
    proxy_user = properties["#{prefix}.proxy.username"]
    proxy_pass = properties["#{prefix}.proxy.password"]
    @proxy_configuration = ProxyConfiguration.new(address: URI(proxy_uri),
                                                  username: proxy_user,
                                                  password: proxy_pass)
  end
  @integrator = properties["#{prefix}.integrator"]
  @shopping_cart_extension = get_shopping_cart_extension(properties, prefix)
end

Instance Attribute Details

#api_endpointString

The base URL to the Online Payments platform.

Returns:

  • (String)

    the current value of api_endpoint



15
16
17
# File 'lib/onlinepayments/sdk/endpoint_configuration.rb', line 15

def api_endpoint
  @api_endpoint
end

#connect_timeoutInteger

The number of seconds before a connection attempt with the Online Payments platform times out.

Returns:

  • (Integer)

    the current value of connect_timeout



15
16
17
# File 'lib/onlinepayments/sdk/endpoint_configuration.rb', line 15

def connect_timeout
  @connect_timeout
end

#integratorString

Name of the integrator

Returns:

  • (String)

    the current value of integrator



15
16
17
# File 'lib/onlinepayments/sdk/endpoint_configuration.rb', line 15

def integrator
  @integrator
end

#max_connectionsInteger

The number of connections with the Online Payments platform that are kept alive in the connection pool. These connections will be reused when possible.

Returns:

  • (Integer)

    the current value of max_connections



15
16
17
# File 'lib/onlinepayments/sdk/endpoint_configuration.rb', line 15

def max_connections
  @max_connections
end

#proxy_configurationOnlinePayments::SDK::ProxyConfiguration

Proxy settings.

Returns:



15
16
17
# File 'lib/onlinepayments/sdk/endpoint_configuration.rb', line 15

def proxy_configuration
  @proxy_configuration
end

#shopping_cart_extensionOnlinePayments::SDK::Domain::ShoppingCartExtension

Shopping cart-related metadata.

Returns:



15
16
17
# File 'lib/onlinepayments/sdk/endpoint_configuration.rb', line 15

def shopping_cart_extension
  @shopping_cart_extension
end

#socket_timeoutInteger

The number of seconds before a timeout occurs when transmitting data to or from the Online Payments platform.

Returns:

  • (Integer)

    the current value of socket_timeout



15
16
17
# File 'lib/onlinepayments/sdk/endpoint_configuration.rb', line 15

def socket_timeout
  @socket_timeout
end

Class Method Details

.default_connect_timeoutObject

The default number of seconds before a connection attempt with the Online Payments platform times out. Used if connectTimeout is not present in the properties.



22
23
24
# File 'lib/onlinepayments/sdk/endpoint_configuration.rb', line 22

def self.default_connect_timeout
  DEFAULT_CONNECT_TIMEOUT
end

.default_max_connectionsObject

The default number of connections that are kept alive in the connection pool. Used if maxConnections is not present in the properties.



34
35
36
# File 'lib/onlinepayments/sdk/endpoint_configuration.rb', line 34

def self.default_max_connections
  DEFAULT_MAX_CONNECTIONS
end

.default_socket_timeoutObject

The default number of seconds before a timeout occurs when transmitting data to or from the Online Payments platform. Used if socketTimeout is not present in the properties.



28
29
30
# File 'lib/onlinepayments/sdk/endpoint_configuration.rb', line 28

def self.default_socket_timeout
  DEFAULT_SOCKET_TIMEOUT
end