Class: Ingenico::Connect::SDK::Factory
- Inherits:
-
Object
- Object
- Ingenico::Connect::SDK::Factory
- Defined in:
- lib/ingenico/connect/sdk/factory.rb
Overview
Convenience class that constructs instances of several other classes in the SDK. Provides methods to construct CommunicatorConfiguration, Session, Communicator and Client instances.
Class Method Summary collapse
-
.create_client_from_communicator(communicator) ⇒ Ingenico::Connect::SDK::Client
Creates and returns an Client that provides the a high-level interface with the Ingenico ePayments platform.
-
.create_client_from_configuration(configuration) ⇒ Ingenico::Connect::SDK::Client
Creates and returns an Client that provides the a high-level interface with the Ingenico ePayments platform.
-
.create_client_from_file(configuration_file_name, api_key_id, secret_api_key) ⇒ Ingenico::Connect::SDK::Client
Creates and returns an Client that provides the a high-level interface with the Ingenico ePayments platform.
-
.create_client_from_session(session) ⇒ Ingenico::Connect::SDK::Client
Creates and returns an Client that provides the a high-level interface with the Ingenico ePayments platform.
-
.create_communicator_from_configuration(configuration) ⇒ Ingenico::Connect::SDK::Communicator
Creates and returns an Communicator that can be used for communication with the Ingenico ePayments platform.
-
.create_communicator_from_file(configuration_file_name, api_key_id, secret_api_key) ⇒ Ingenico::Connect::SDK::Communicator
Creates and returns an Communicator that is used for communication with the Ingenico ePayments platform.
-
.create_communicator_from_session(session) ⇒ Ingenico::Connect::SDK::Communicator
Creates and returns an Communicator that is used for communication with the Ingenico ePayments platform.
-
.create_configuration(configuration_file_name, api_key_id, secret_api_key) ⇒ Ingenico::Connect::SDK::CommunicatorConfiguration
Creates and returns a CommunicatorConfiguration based on the configuration in the file located at configuration_file_name.
-
.create_session_from_configuration(configuration, meta_data_provider: nil, connection: nil, authenticator: nil) ⇒ Ingenico::Connect::SDK::Session
Creates and returns a Session from an CommunicatorConfiguration, an MetaDataProvider, an Connection and an Authenticator.
-
.create_session_from_file(configuration_file_name, api_key_id, secret_api_key, meta_data_provider: nil, connection: nil, authenticator: nil) ⇒ Ingenico::Connect::SDK::Session
Creates and returns a Session from a file containing the communicator configuration, api_key_id, secret_api_key, an MetaDataProvider, an Connection and an Authenticator.
Class Method Details
.create_client_from_communicator(communicator) ⇒ Ingenico::Connect::SDK::Client
Creates and returns an Client that provides the a high-level interface with the Ingenico ePayments platform. If a code block is given, the created client is returned to the code block and closed afterwards.
146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/ingenico/connect/sdk/factory.rb', line 146 def self.create_client_from_communicator(communicator) client = Client.new(communicator) if block_given? begin yield client ensure client.close end else return client end end |
.create_client_from_configuration(configuration) ⇒ Ingenico::Connect::SDK::Client
Creates and returns an Client that provides the a high-level interface with the Ingenico ePayments platform. If a code block is given, the created client is returned to the code block and closed afterwards.
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/ingenico/connect/sdk/factory.rb', line 121 def self.create_client_from_configuration(configuration) communicator = create_communicator_from_configuration(configuration) client = Client.new(communicator) if block_given? begin yield client ensure client.close end else return client end end |
.create_client_from_file(configuration_file_name, api_key_id, secret_api_key) ⇒ Ingenico::Connect::SDK::Client
Creates and returns an Client that provides the a high-level interface with the Ingenico ePayments platform. If a code block is given, the created client is returned to the code block and closed afterwards.
197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/ingenico/connect/sdk/factory.rb', line 197 def self.create_client_from_file(configuration_file_name, api_key_id, secret_api_key) communicator = create_communicator_from_file(configuration_file_name, api_key_id, secret_api_key) client = Client.new(communicator) if block_given? begin yield client ensure client.close end else return client end end |
.create_client_from_session(session) ⇒ Ingenico::Connect::SDK::Client
Creates and returns an Client that provides the a high-level interface with the Ingenico ePayments platform. If a code block is given, the created client is returned to the code block and closed afterwards.
170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/ingenico/connect/sdk/factory.rb', line 170 def self.create_client_from_session(session) communicator = create_communicator_from_session(session) client = Client.new(communicator) if block_given? begin yield client ensure client.close end else return client end end |
.create_communicator_from_configuration(configuration) ⇒ Ingenico::Connect::SDK::Communicator
Creates and returns an Communicator that can be used for communication with the Ingenico ePayments platform.
93 94 95 96 |
# File 'lib/ingenico/connect/sdk/factory.rb', line 93 def self.create_communicator_from_configuration(configuration) session = create_session_from_configuration(configuration) Communicator.new(session, DefaultImpl::DefaultMarshaller.INSTANCE) end |
.create_communicator_from_file(configuration_file_name, api_key_id, secret_api_key) ⇒ Ingenico::Connect::SDK::Communicator
Creates and returns an Communicator that is used for communication with the Ingenico ePayments platform.
104 105 106 107 108 |
# File 'lib/ingenico/connect/sdk/factory.rb', line 104 def self.create_communicator_from_file(configuration_file_name, api_key_id, secret_api_key) configuration = create_configuration(configuration_file_name, api_key_id, secret_api_key) session = create_session_from_configuration(configuration) Communicator.new(session, DefaultImpl::DefaultMarshaller.INSTANCE) end |
.create_communicator_from_session(session) ⇒ Ingenico::Connect::SDK::Communicator
Creates and returns an Communicator that is used for communication with the Ingenico ePayments platform.
85 86 87 |
# File 'lib/ingenico/connect/sdk/factory.rb', line 85 def self.create_communicator_from_session(session) Communicator.new(session, DefaultImpl::DefaultMarshaller.INSTANCE) end |
.create_configuration(configuration_file_name, api_key_id, secret_api_key) ⇒ Ingenico::Connect::SDK::CommunicatorConfiguration
Creates and returns a CommunicatorConfiguration based on the configuration in the file located at configuration_file_name.
26 27 28 29 30 31 |
# File 'lib/ingenico/connect/sdk/factory.rb', line 26 def self.create_configuration(configuration_file_name, api_key_id, secret_api_key) properties = YAML::load_file(configuration_file_name) CommunicatorConfiguration.new(properties: properties, api_key_id: api_key_id, secret_api_key: secret_api_key) end |
.create_session_from_configuration(configuration, meta_data_provider: nil, connection: nil, authenticator: nil) ⇒ Ingenico::Connect::SDK::Session
Creates and returns a Session from an CommunicatorConfiguration, an MetaDataProvider, an Connection and an Authenticator. If an authenticator is not given, a DefaultImpl::DefaultAuthenticator is created using the api_key_id and secret_api_key in the CommunicatorConfiguration.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ingenico/connect/sdk/factory.rb', line 43 def self.create_session_from_configuration(configuration, meta_data_provider: nil, connection: nil, authenticator: nil) unless = MetaDataProvider.new(configuration.integrator, shopping_cart_extension: configuration.shopping_cart_extension) end unless connection connection = DefaultImpl::DefaultConnection.new({ connect_timeout: configuration.connect_timeout, socket_timeout: configuration.socket_timeout, max_connections: configuration.max_connections, proxy_configuration: configuration.proxy_configuration }) end unless authenticator authenticator = DefaultImpl::DefaultAuthenticator.new(configuration., configuration.api_key_id, configuration.secret_api_key) end Session.new(configuration.api_endpoint, connection, authenticator, ) end |
.create_session_from_file(configuration_file_name, api_key_id, secret_api_key, meta_data_provider: nil, connection: nil, authenticator: nil) ⇒ Ingenico::Connect::SDK::Session
Creates and returns a Session from a file containing the communicator configuration, api_key_id, secret_api_key, an MetaDataProvider, an Connection and an Authenticator. If an authenticator is not given, a DefaultImpl::DefaultAuthenticator is created using the api_key_id and secret_api_key in the CommunicatorConfiguration.
74 75 76 77 78 79 |
# File 'lib/ingenico/connect/sdk/factory.rb', line 74 def self.create_session_from_file(configuration_file_name, api_key_id, secret_api_key, meta_data_provider: nil, connection: nil, authenticator: nil) configuration = create_configuration(configuration_file_name, api_key_id, secret_api_key) create_session_from_configuration(configuration, meta_data_provider: , connection: connection, authenticator: authenticator) end |