<?php

declare(strict_types=1);

namespace App\Framework\HttpClient;

final readonly class AuthConfig
{
    private function __construct(
        public AuthType $type,
        public array $credentials
    ) {
    }

    public static function basic(string $username, string $password): self
    {
        return new self(
            AuthType::Basic,
            ['username' => $username, 'password' => $password]
        );
    }

    public static function bearer(string $token): self
    {
        return new self(
            AuthType::Bearer,
            ['token' => $token]
        );
    }

    public static function oauth2(string $token): self
    {
        return new self(
            AuthType::OAuth2,
            ['token' => $token]
        );
    }

    public static function digest(string $username, string $password): self
    {
        return new self(
            AuthType::Digest,
            ['username' => $username, 'password' => $password]
        );
    }

    public static function custom(array $headers): self
    {
        return new self(
            AuthType::Custom,
            ['headers' => $headers]
        );
    }
}
