#!/bin/bash
# AIK Digital × EFU Life — Quick Setup Script (Linux/Mac)
# Run: bash setup.sh

set -e
echo "=== AIK Digital x EFU Life Setup ==="

echo "[1/5] Installing Composer dependencies..."
composer install

echo "[2/5] Setting up .env..."
[ ! -f .env ] && cp .env.example .env || echo "  .env already exists — skipped"

echo "[3/5] Generating application key..."
php artisan key:generate

echo "[4/5] Generating RSA keys..."
php generate-keys.php

echo "[5/5] Running database migrations..."
php artisan migrate --force

echo ""
echo "=== Setup Complete! ==="
echo ""
echo "NEXT STEPS:"
echo "  1. Edit .env and set AIK_CLIENT_ID, AIK_API_KEY, AIK_MERCHANT_ID"
echo "  2. Share storage/keys/efu_public.pem with AIK Digital"
echo "  3. Replace storage/keys/aik_public.pem with AIK Digital's real public key"
echo "  4. php artisan serve"
echo "  5. Import AIK_EFU_Integration.postman_collection.json into Postman"
echo ""
echo "Server: http://localhost:8000"
