<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Services\Integrations\IntegrationTester;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class IntegrationTestController extends Controller
{
    public function __construct(private IntegrationTester $tester) {}

    public function test(Request $request): JsonResponse
    {
        $data = $request->validate([
            'provider' => ['required', 'string', 'in:slack,telegram,pushover,meta_capi,tiktok,ga4,discord,teams,mixpanel,amplitude,posthog,firebase,segment'],
        ]);

        $result = $this->tester->test($data['provider']);

        return response()->json($result);
    }
}
