<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class CampaignController extends Controller
{
    /**
     * GET /api/v1/campaigns?token=
     */
    public function index(Request $request)
    {
        $user = $request->user();

        // campaigns table not yet built — return stub
        return response()->json([
            'success' => true,
            'data'    => [],
            'total'   => 0,
            'message' => 'Campaigns module coming soon.',
        ]);
    }

    /**
     * POST /api/v1/campaigns?token=
     *
     * Body: { "name": "Promo Oct", "template": "promo_template", "contacts": ["9198..."] }
     */
    public function store(Request $request)
    {
        $request->validate([
            'name'     => ['required', 'string', 'max:255'],
            'template' => ['required', 'string'],
            'contacts' => ['required', 'array'],
        ]);

        $user = $request->user();

        // campaigns table not yet built — return stub
        return response()->json([
            'success' => true,
            'data'    => [
                'name'      => $request->name,
                'template'  => $request->template,
                'contacts'  => count($request->contacts),
                'status'    => 'queued',
            ],
            'message' => 'Campaigns module coming soon. Campaign not persisted yet.',
        ], 201);
    }
}
