Class: Worldline::Acquiring::SDK::CommunicatorConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/worldline/acquiring/sdk/communicator_configuration.rb

Overview

A CommunicatorConfiguration stores all data used to initialize an Communicator.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(properties: nil, api_endpoint: nil, authorization_id: nil, authorization_secret: nil, oauth2_client_id: nil, oauth2_client_secret: nil, oauth2_token_uri: nil, authorization_type: nil, connect_timeout: nil, socket_timeout: nil, max_connections: nil, proxy_configuration: nil, integrator: nil, shopping_cart_extension: nil) ⇒ CommunicatorConfiguration

Creates a new CommunicatorConfiguration instance.

If a properties object is given, it will be parsed like a hash in order to read these attributes. If a value is given in both the properties hash and as a separate parameter, the separate parameter will take precedence over the value in the properties.

Parameters:

  • properties (Hash, nil) (defaults to: nil)

    hash that may contain any of the other parameters.

  • api_endpoint (String, nil) (defaults to: nil)

    the base URL to the Worldline Acquiring platform.

  • authorization_id (String, nil) (defaults to: nil)

    An id used for authorization. The meaning of this id is different for each authorization type. For instance, for OAuth2 this is the client id.

  • authorization_secret (String, nil) (defaults to: nil)

    A secret used for authorization. The meaning of this secret is different for each authorization type. For instance, for OAuth2 this is the client secret.

  • oauth2_client_id (String, nil) (defaults to: nil)

    The OAuth2 client id. This is an alias for authorization_id.

  • oauth2_client_secret (String, nil) (defaults to: nil)

    The OAuth2 client secret. This is an alias for authorization_secret.

  • oauth2_token_uri (String, nil) (defaults to: nil)

    The OAuth2 token URI.

  • authorization_type (String, nil) (defaults to: nil)

    string describing the authorization protocol to follow.

  • connect_timeout (Integer, nil) (defaults to: nil)

    the number of seconds before a connection attempt with the Worldline Acquiring platform times out.

  • socket_timeout (Integer, nil) (defaults to: nil)

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

  • max_connections (Integer, nil) (defaults to: nil)

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

  • proxy_configuration (Worldline::Acquiring::SDK::ProxyConfiguration, nil) (defaults to: nil)

    stores the URL to a proxy to be used in all communication, or nil if no proxy should be used.

  • integrator (String, nil) (defaults to: nil)

    name of the integrator

  • shopping_cart_extension (Worldline::Acquiring::SDK::Domain::ShoppingCartExtension, nil) (defaults to: nil)

    stores shopping cart-related metadata.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/worldline/acquiring/sdk/communicator_configuration.rb', line 62

def initialize(properties: nil, api_endpoint: nil,
               authorization_id: nil, authorization_secret: nil,
               oauth2_client_id: nil, oauth2_client_secret: nil, oauth2_token_uri: nil,
               authorization_type: nil,
               connect_timeout: nil, socket_timeout: nil,
               max_connections: nil, proxy_configuration: nil,
               integrator: nil, shopping_cart_extension: nil)
  unless properties.nil?
    @api_endpoint = get_endpoint(properties)
    @authorization_type = Authentication::AuthorizationType.get_authorization(properties['acquiring.api.authorizationType'])
    @oauth2_token_uri = properties['acquiring.api.oauth2.tokenUri']
    @connect_timeout = properties['acquiring.api.connectTimeout']
    @socket_timeout = properties['acquiring.api.socketTimeout']
    @max_connections = get_property(properties, 'acquiring.api.maxConnections', DEFAULT_MAX_CONNECTIONS)

    proxy_uri = properties['acquiring.api.proxy.uri']
    proxy_user = properties['acquiring.api.proxy.username']
    proxy_pass = properties['acquiring.api.proxy.password']
    unless proxy_uri.nil?
      @proxy_configuration = ProxyConfiguration.new(address: URI(proxy_uri),
                                                    username: proxy_user,
                                                    password: proxy_pass)
    end
    @integrator = properties['acquiring.api.integrator']
    @shopping_cart_extension = get_shopping_cart_extension(properties)
  end

  if api_endpoint
    @api_endpoint = api_endpoint
  end
  if authorization_id
    @authorization_id = authorization_id
  end
  if authorization_secret
    @authorization_secret = authorization_secret
  end
  if oauth2_client_id
    @authorization_id = oauth2_client_id
  end
  if oauth2_client_secret
    @authorization_secret = oauth2_client_secret
  end
  if oauth2_token_uri
    @oauth2_token_uri = oauth2_token_uri
  end
  if authorization_type
    @authorization_type = authorization_type
  end
  if connect_timeout
    @connect_timeout = connect_timeout
  end
  if socket_timeout
    @socket_timeout = socket_timeout
  end
  if max_connections
    @max_connections = max_connections
  end
  if proxy_configuration
    @proxy_configuration = proxy_configuration
  end
  if integrator
    @integrator = integrator
  end
  if shopping_cart_extension
    @shopping_cart_extension = shopping_cart_extension
  end
end

Instance Attribute Details

#api_endpointString

Base URL to the Worldline Acquiring platform

Returns:

  • (String)

    the current value of api_endpoint



22
23
24
# File 'lib/worldline/acquiring/sdk/communicator_configuration.rb', line 22

def api_endpoint
  @api_endpoint
end

#authorization_idString Also known as: oauth2_client_id

An id used for authorization. The meaning of this id is different for each authorization type. For instance, for OAuth2 this is the client id

Returns:

  • (String)

    the current value of authorization_id



22
23
24
# File 'lib/worldline/acquiring/sdk/communicator_configuration.rb', line 22

def authorization_id
  @authorization_id
end

#authorization_secretString Also known as: oauth2_client_secret

A secret used for authorization. The meaning of this secret is different for each authorization type. For instance, for OAuth2 this is the client secret

Returns:

  • (String)

    the current value of authorization_secret



22
23
24
# File 'lib/worldline/acquiring/sdk/communicator_configuration.rb', line 22

def authorization_secret
  @authorization_secret
end

#authorization_typeString

String representing the authentication algorithm used

Returns:

  • (String)

    the current value of authorization_type



22
23
24
# File 'lib/worldline/acquiring/sdk/communicator_configuration.rb', line 22

def authorization_type
  @authorization_type
end

#connect_timeoutInteger

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

Returns:

  • (Integer)

    the current value of connect_timeout



22
23
24
# File 'lib/worldline/acquiring/sdk/communicator_configuration.rb', line 22

def connect_timeout
  @connect_timeout
end

#integratorString

Name of the integrator

Returns:

  • (String)

    the current value of integrator



22
23
24
# File 'lib/worldline/acquiring/sdk/communicator_configuration.rb', line 22

def integrator
  @integrator
end

#max_connectionsInteger

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

Returns:

  • (Integer)

    the current value of max_connections



22
23
24
# File 'lib/worldline/acquiring/sdk/communicator_configuration.rb', line 22

def max_connections
  @max_connections
end

#oauth2_token_uriString

The OAuth2 token URI

Returns:

  • (String)

    the current value of oauth2_token_uri



22
23
24
# File 'lib/worldline/acquiring/sdk/communicator_configuration.rb', line 22

def oauth2_token_uri
  @oauth2_token_uri
end

#proxy_configurationWorldline::Acquiring::SDK::ProxyConfiguration

Proxy settings.

Returns:



22
23
24
# File 'lib/worldline/acquiring/sdk/communicator_configuration.rb', line 22

def proxy_configuration
  @proxy_configuration
end

#shopping_cart_extensionWorldline::Acquiring::SDK::Domain::ShoppingCartExtension

Shopping cart-related metadata.

Returns:



22
23
24
# File 'lib/worldline/acquiring/sdk/communicator_configuration.rb', line 22

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 Worldline Acquiring platform.

Returns:

  • (Integer)

    the current value of socket_timeout



22
23
24
# File 'lib/worldline/acquiring/sdk/communicator_configuration.rb', line 22

def socket_timeout
  @socket_timeout
end

Class Method Details

.default_max_connectionsInteger

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

Returns:

  • (Integer)


32
33
34
# File 'lib/worldline/acquiring/sdk/communicator_configuration.rb', line 32

def self.default_max_connections
  DEFAULT_MAX_CONNECTIONS
end