<?php
/**
 * Yandex API Key Auth Manager
 *
 * Builds authorization headers for Yandex Cloud AI Studio API key authentication.
 *
 * @package SmartyPress_AI_Engine
 * @since 1.1.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Yandex Auth Manager class
 */
class SmartyPress_AI_Yandex_Auth_Manager {

	/**
	 * Service account API key.
	 *
	 * @var string
	 */
	private $api_key;

	/**
	 * Constructor
	 *
	 * @param string $api_key Yandex Cloud service account API key.
	 * @throws Exception If API key is empty.
	 */
	public function __construct( $api_key ) {
		if ( empty( $api_key ) ) {
			throw new Exception(
				esc_html__( 'Yandex API key cannot be empty.', 'smartypress-ai-engine' )
			);
		}

		$this->api_key = $api_key;
	}

	/**
	 * Get authorization header value.
	 *
	 * @return string Authorization header value.
	 */
	public function get_authorization_header() {
		return 'Api-Key ' . $this->api_key;
	}

	/**
	 * Clear cached credentials.
	 *
	 * Kept as a no-op for compatibility with provider auth error handling.
	 */
	public function clear_cache() {
		return;
	}
}
