<?php

namespace App\Http\Controllers\Testing;

use App\Http\Controllers\Controller;
use App\Testing\Mailbox;
use Illuminate\Http\JsonResponse;

class TestMailboxController extends Controller
{
    public function index(): JsonResponse
    {
        abort_unless(config('e2e.testing_enabled'), 404);

        return response()->json([
            'data' => Mailbox::all(),
        ]);
    }

    public function destroy(): JsonResponse
    {
        abort_unless(config('e2e.testing_enabled'), 404);

        Mailbox::flush();

        return response()->json([
            'status' => 'ok',
        ]);
    }
}
