Class: Ingenico::Connect::SDK::EndpointConfiguration

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

Overview

Base class for configuration classes in the SDK. This class stores the following:

api_endpoint

Base URL to the GlobalCollect platform, stored as a string.

connect_timeout

Timeout in seconds before a connection attempt times out.

socket_timeout

Timeout in seconds that occurs after not receiving transmitted data for socket_timeout seconds.

max_connections

The number of connections in the connection pool that will be kept alive.

proxy_configuration

ProxyConfiguration containing proxy settings.

Direct Known Subclasses

CommunicatorConfiguration

Constant Summary collapse

@@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 GlobalCollect platform.

connectTimeout

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

socketTimeout

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

maxConnections

The number of connections with the GlobalCollect 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 GlobalCollect platform using a proxy.

integrator

String

shoppingCartExtension

Will be used to initialize a Domain::Metadata::ShoppingCartExtension.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ingenico/connect/sdk/endpoint_configuration.rb', line 39

def initialize(properties=nil, prefix=nil)
  unless properties.nil?
    @api_endpoint = get_endpoint(properties, prefix)
    @connect_timeout = properties[prefix + '.connectTimeout']
    @socket_timeout = properties[prefix + '.socketTimeout']
    @max_connections = get_property(properties, prefix + '.maxConnections',
                                    @@DEFAULT_MAX_CONNECTIONS)
    proxy_uri = properties[prefix + '.proxy.uri']
    proxy_user = properties[prefix + '.proxy.username']
    proxy_pass = properties[prefix + '.proxy.password']

    unless proxy_uri.nil?
      @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
end

Instance Attribute Details

#api_endpointObject (readonly)

The base URL to the GlobalCollect platform.



137
138
139
# File 'lib/ingenico/connect/sdk/endpoint_configuration.rb', line 137

def api_endpoint
  @api_endpoint
end

#connect_timeoutObject

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



119
120
121
# File 'lib/ingenico/connect/sdk/endpoint_configuration.rb', line 119

def connect_timeout
  @connect_timeout
end

#integratorObject

Returns the value of attribute integrator.



131
132
133
# File 'lib/ingenico/connect/sdk/endpoint_configuration.rb', line 131

def integrator
  @integrator
end

#max_connectionsObject

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



126
127
128
# File 'lib/ingenico/connect/sdk/endpoint_configuration.rb', line 126

def max_connections
  @max_connections
end

#proxy_configurationObject

ProxyConfiguration containing proxy settings.



129
130
131
# File 'lib/ingenico/connect/sdk/endpoint_configuration.rb', line 129

def proxy_configuration
  @proxy_configuration
end

#shopping_cart_extensionObject

Domain::Metadata::ShoppingCartExtension containing shopping cart-related metadata.



134
135
136
# File 'lib/ingenico/connect/sdk/endpoint_configuration.rb', line 134

def shopping_cart_extension
  @shopping_cart_extension
end

#socket_timeoutObject

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



122
123
124
# File 'lib/ingenico/connect/sdk/endpoint_configuration.rb', line 122

def socket_timeout
  @socket_timeout
end

Class Method Details

.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.



18
19
20
# File 'lib/ingenico/connect/sdk/endpoint_configuration.rb', line 18

def self.DEFAULT_MAX_CONNECTIONS
  @@DEFAULT_MAX_CONNECTIONS
end