<?php

declare(strict_types=1);

namespace App\Infrastructure\Api\RapidMail;

use App\Framework\DI\Container;
use App\Framework\DI\Initializer;
use App\Framework\HttpClient\CurlHttpClient;

final readonly class RapidMailClientInitializer
{
    #[Initializer]
    public function __invoke(Container $container): RapidMailClient
    {
        $config = $container->get(\App\Framework\Config\External\ExternalApiConfig::class);

        return new RapidMailClient(
            new RapidMailConfig(
                username: $config->rapidMail->username,
                password: $config->rapidMail->password,
                testMode: $config->rapidMail->testMode,
            ),
            new CurlHttpClient()
        );
    }
}
