#!/bin/bash
# 1. Login
echo "Logging in..."
LOGIN_RES=$(curl -s -X POST http://localhost:3000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"admin@contentgen.ai","password":"Admin123!"}')

TOKEN=$(echo $LOGIN_RES | grep -o '"accessToken":"[^"]*' | cut -d'"' -f4)
if [ -z "$TOKEN" ]; then
  echo "Login failed! Response: $LOGIN_RES"
  exit 1
fi
echo "Got token."

# 2. Create project
echo "Creating project..."
curl -s -X POST http://localhost:3000/api/projects/from-tweet \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"tweetUrl":"https://x.com/elonmusk/status/1893456789012345678","language":"tr","videoStyle":"CINEMATIC","aspectRatio":"PORTRAIT_9_16"}' > proj_res.json

echo "Raw Server Response:"
cat proj_res.json
