Class: OnlinePayments::SDK::CommunicatorConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/onlinepayments/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, api_key_id: nil, secret_api_key: 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 Online Payments platform.

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

    the identifier of the secret_api_key used to authenticate requests.

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

    the key used to authenticate requests sent to the Online Payments platform.

  • 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 Online Payments 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 Online Payments platform.

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

    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_configuration (OnlinePayments::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 (OnlinePayments::SDK::Domain::ShoppingCartExtension, nil) (defaults to: nil)

    stores shopping cart-related metadata.



51
52
53
54
55
56
57
58
59
60
61
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
# File 'lib/onlinepayments/sdk/communicator_configuration.rb', line 51

def initialize(properties: nil, api_endpoint: nil,
               api_key_id: nil, secret_api_key: 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['onlinePayments.api.authorizationType'])
    @connect_timeout = properties['onlinePayments.api.connectTimeout']
    @socket_timeout = properties['onlinePayments.api.socketTimeout']
    @max_connections = get_property(properties, 'onlinePayments.api.maxConnections', DEFAULT_MAX_CONNECTIONS)

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

  if api_endpoint
    @api_endpoint = api_endpoint
  end
  if api_key_id
    @api_key_id = api_key_id
  end
  if secret_api_key
    @secret_api_key = secret_api_key
  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 Online Payments platform

Returns:

  • (String)

    the current value of api_endpoint



18
19
20
# File 'lib/onlinepayments/sdk/communicator_configuration.rb', line 18

def api_endpoint
  @api_endpoint
end

#api_key_idString

Identifier of the secret_api_key used in authentication.

Returns:

  • (String)

    the current value of api_key_id



18
19
20
# File 'lib/onlinepayments/sdk/communicator_configuration.rb', line 18

def api_key_id
  @api_key_id
end

#authorization_typeString

String representing the authentication algorithm used

Returns:

  • (String)

    the current value of authorization_type



18
19
20
# File 'lib/onlinepayments/sdk/communicator_configuration.rb', line 18

def authorization_type
  @authorization_type
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



18
19
20
# File 'lib/onlinepayments/sdk/communicator_configuration.rb', line 18

def connect_timeout
  @connect_timeout
end

#integratorString

Name of the integrator

Returns:

  • (String)

    the current value of integrator



18
19
20
# File 'lib/onlinepayments/sdk/communicator_configuration.rb', line 18

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



18
19
20
# File 'lib/onlinepayments/sdk/communicator_configuration.rb', line 18

def max_connections
  @max_connections
end

#proxy_configurationOnlinePayments::SDK::ProxyConfiguration

Proxy settings.

Returns:



18
19
20
# File 'lib/onlinepayments/sdk/communicator_configuration.rb', line 18

def proxy_configuration
  @proxy_configuration
end

#secret_api_keyString

Secret key used in authentication

Returns:

  • (String)

    the current value of secret_api_key



18
19
20
# File 'lib/onlinepayments/sdk/communicator_configuration.rb', line 18

def secret_api_key
  @secret_api_key
end

#shopping_cart_extensionOnlinePayments::SDK::Domain::ShoppingCartExtension

Shopping cart-related metadata.

Returns:



18
19
20
# File 'lib/onlinepayments/sdk/communicator_configuration.rb', line 18

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



18
19
20
# File 'lib/onlinepayments/sdk/communicator_configuration.rb', line 18

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)


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

def self.default_max_connections
  DEFAULT_MAX_CONNECTIONS
end