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 Ingenico ePayments 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 Ingenico ePayments platform.

connectTimeout

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

socketTimeout

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

maxConnections

The number of connections with the Ingenico ePayments 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 Ingenico ePayments 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 Ingenico ePayments platform.



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

def api_endpoint
  @api_endpoint
end

#connect_timeoutObject

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



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

def connect_timeout
  @connect_timeout
end

#integratorObject

Returns the value of attribute integrator.



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

def integrator
  @integrator
end

#max_connectionsObject

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



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

def max_connections
  @max_connections
end

#proxy_configurationObject

ProxyConfiguration containing proxy settings.



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

def proxy_configuration
  @proxy_configuration
end

#shopping_cart_extensionObject

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



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

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 Ingenico ePayments platform.



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

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