Configuration
Config and Environment
The Config value object describes how the SDK connects to the EFL Leasing Online API:
- API key used for authentication.
- Environment (sandbox or production).
- Base URL of the API.
Use the factory methods to create configuration instances:
use Imoli\EflLeasingSdk\Config;
// Sandbox configuration (base URL is selected automatically)
$sandboxConfig = Config::sandbox(
apiKey: 'your-sandbox-api-key',
);
// Production configuration (you must provide the base URL)
$productionConfig = Config::production(
apiKey: 'your-production-api-key',
baseUrl: 'https://leasingonlineapi.efl.com.pl',
);
Config reference
The Config value object stores:
apiKey(string) – API key used to authenticate your requests.environment(Environment) – one ofEnvironment::SandboxorEnvironment::Production.baseUrl(string) – base URL of the EFL Leasing Online API (without a trailing/).
Config::sandbox() and Config::production() take care of normalising the base URL and selecting the right environment value.
Environment enum
The Environment enum is used internally to distinguish between sandbox and production environments:
use Imoli\EflLeasingSdk\Enum\Environment;
$env = Environment::Sandbox; // sandbox API
$env = Environment::Production; // production API
You usually do not need to instantiate Environment manually. It is derived from the factory method you use:
Config::sandbox()→Environment::SandboxConfig::production()→Environment::Production
Choosing an HTTP client
The SDK does not perform HTTP requests directly. Instead, it relies on HttpClientInterface, which you must implement or adapt.
You can choose between:
- Guzzle adapter (
GuzzleHttpAdapter) - Symfony HttpClient adapter (
SymfonyHttpAdapter) - Custom implementation of
HttpClientInterface
Guzzle adapter
use GuzzleHttp\Client as GuzzleClient;
use Imoli\EflLeasingSdk\Http\Adapter\GuzzleHttpAdapter;
$guzzle = new GuzzleClient([
'timeout' => 30,
'connect_timeout' => 10,
]);
$httpClient = new GuzzleHttpAdapter($guzzle);
Symfony HttpClient adapter
use Imoli\EflLeasingSdk\Http\Adapter\SymfonyHttpAdapter;
use Symfony\Component\HttpClient\HttpClient;
$symfonyClient = HttpClient::create();
$httpClient = new SymfonyHttpAdapter($symfonyClient);
Custom implementation
If you use a different HTTP library, implement HttpClientInterface yourself.
Your implementation is responsible for:
- Performing HTTP requests with the method, URL, headers and body provided.
- Returning a response compatible with the SDK’s
HttpResponseabstraction. - Throwing
HttpException(or subclasses ofEflLeasingException) for transport-level failures, if appropriate.
See the API → HTTP reference for details.
Instantiating EflClient
Once you have Config and an implementation of HttpClientInterface, create the main client:
use Imoli\EflLeasingSdk\EflClient;
$client = new EflClient($sandboxConfig, $httpClient);
You typically create a single instance of EflClient per environment and reuse it across your application.
Timeouts and reliability
Production systems should configure sensible timeouts at the HTTP client level:
- Overall request timeout (e.g. 15–30 seconds).
- Connection timeout (e.g. 5–10 seconds).
The SDK itself does not implement retries or circuit breakers. If you need these features, configure them in your HTTP client or in your application code.
Logging requests and responses
For debugging or auditing you can plug in a RequestLoggerInterface implementation.
The logger receives both request and response details and can be used to:
- Persist logs to files or structured log systems.
- Send errors to your monitoring service.
- Inspect raw responses when diagnosing issues.
Avoid logging sensitive data (such as full customer details) in production.
Switching between sandbox and production
A common pattern is to:
- Use sandbox configuration and credentials in non-production environments (local, staging).
- Use production configuration and credentials in the live environment.
You can encapsulate this in your own factory or configuration service.
Make sure you never use sandbox credentials or URLs in production.
Best practices
- Store API keys and partner identifiers in environment variables, not in source control.
- Configure sensible timeouts on your HTTP client (both overall request timeout and connection timeout).
- Use sandbox configuration and credentials only in non-production environments.
- Reuse a single
EflClientinstance per environment instead of creating a new one per request.
Related sections
- Getting started – for a minimal setup example.
- Quickstart – for an end‑to‑end flow.
- API → Clients – for all available methods on
EflClientand low-level API clients.