#!/bin/bash

# Test script for Collection Agent Endpoints
# Using token from login response

BASE_URL="http://192.168.1.3:3000"
# Use the auth_token from login response
AUTH_TOKEN="2001d73f696e4136212bbad7050d64301c3dae6655ced2ad568e29b8730382c8"

echo "=========================================="
echo "Testing Collection Details Endpoint"
echo "=========================================="
curl -X GET "${BASE_URL}/collection_details" \
  -H "Accept: application/json" \
  -H "Accept-Encoding: gzip, deflate" \
  -H "Accept-Language: en-GB,en-US;q=0.9,en;q=0.8" \
  -H "Authorization: Bearer ${AUTH_TOKEN}" \
  -H "Content-Type: application/json" \
  -H "Origin: http://localhost:54908" \
  -H "Referer: http://localhost:54908/" \
  -H "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1" \
  -w "\n\nHTTP Status: %{http_code}\n" \
  -s | jq '.' || echo "Response received (jq not available for formatting)"

echo ""
echo "=========================================="
echo "Testing Collection Agent Endpoint"
echo "=========================================="
curl -X GET "${BASE_URL}/collection_agent" \
  -H "Accept: application/json" \
  -H "Accept-Encoding: gzip, deflate" \
  -H "Accept-Language: en-GB,en-US;q=0.9,en;q=0.8" \
  -H "Authorization: Bearer ${AUTH_TOKEN}" \
  -H "Content-Type: application/json" \
  -H "Origin: http://localhost:54908" \
  -H "Referer: http://localhost:54908/" \
  -H "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1" \
  -w "\n\nHTTP Status: %{http_code}\n" \
  -s | jq '.' || echo "Response received (jq not available for formatting)"

echo ""
echo "=========================================="
echo "Test Complete"
echo "=========================================="

