<?php

namespace App\Services\Verification;

use App\Services\Verification\Contracts\VerificationProviderInterface;
use App\Services\Verification\Drivers\MockDriver;
use App\Services\Verification\Drivers\SurepassDriver;
use App\Services\Verification\Drivers\SandboxDriver;
use Illuminate\Support\Manager;

class VerificationManager extends Manager implements VerificationProviderInterface
{
    /**
     * Get the default driver name.
     */
    public function getDefaultDriver(): string
    {
        return $this->config->get('verification.default', 'mock');
    }

    /**
     * Create the Mock driver instance.
     */
    public function createMockDriver(): MockDriver
    {
        return new MockDriver();
    }

    /**
     * Create the Surepass driver instance.
     */
    public function createSurepassDriver(): SurepassDriver
    {
        $config = $this->config->get('verification.drivers.surepass', []);
        return new SurepassDriver($config);
    }

    /**
     * Create the Sandbox driver instance.
     */
    public function createSandboxDriver(): SandboxDriver
    {
        $config = $this->config->get('verification.drivers.sandbox', []);
        return new SandboxDriver($config);
    }

    /**
     * Delegate PAN verification to the resolved driver.
     */
    public function verifyPan(string $panNumber, ?string $fullName = null, ?string $dob = null): \App\Services\Verification\DTOs\PanVerificationResult
    {
        return $this->driver()->verifyPan($panNumber, $fullName, $dob);
    }

    /**
     * Delegate Aadhaar OTP generation to the resolved driver.
     */
    public function sendAadhaarOtp(string $aadhaarNumber): \App\Services\Verification\DTOs\AadhaarOtpResult
    {
        return $this->driver()->sendAadhaarOtp($aadhaarNumber);
    }

    /**
     * Delegate Aadhaar OTP verification to the resolved driver.
     */
    public function verifyAadhaarOtp(string $otp, string $clientId): \App\Services\Verification\DTOs\AadhaarVerificationResult
    {
        return $this->driver()->verifyAadhaarOtp($otp, $clientId);
    }

    /**
     * Delegate basic Aadhaar check to the resolved driver.
     */
    public function verifyAadhaarBasic(string $aadhaarNumber): \App\Services\Verification\DTOs\AadhaarBasicResult
    {
        return $this->driver()->verifyAadhaarBasic($aadhaarNumber);
    }

    /**
     * Delegate Aadhaar-PAN linkage check to the resolved driver.
     */
    public function checkAadhaarPanLink(string $aadhaarNumber, string $panNumber): \App\Services\Verification\DTOs\AadhaarPanLinkResult
    {
        return $this->driver()->checkAadhaarPanLink($aadhaarNumber, $panNumber);
    }

    /**
     * Delegate GST certificate verification to the resolved driver.
     */
    public function verifyGst(string $gstin): \App\Services\Verification\DTOs\GstVerificationResult
    {
        return $this->driver()->verifyGst($gstin);
    }

    /**
     * Delegate Bank account verification to the resolved driver.
     */
    public function verifyBank(string $accountNumber, string $ifsc): \App\Services\Verification\DTOs\BankVerificationResult
    {
        return $this->driver()->verifyBank($accountNumber, $ifsc);
    }
}
