#!/bin/bash
# Minimal test to see if we can reach the Trello API through environment

cd /opt/automator/cinik-writer-transtor/files

# Check for common credential patterns
if [ -f ~/.config/cinik-gdoc/token.json ]; then
    echo "✓ Found Google Drive OAuth token"
    ls -lh ~/.config/cinik-gdoc/token.json
fi

# Try to get Trello auth from any available source
if [ -n "$TRELLO_KEY" ] && [ -n "$TRELLO_TOKEN" ]; then
    echo "✓ Trello credentials available via env"
    python3 -c "
import os, requests, json
url = f\"https://api.trello.com/1/cards/6a1d694a15d59736cd9622ec\"
params = {
    'key': os.environ['TRELLO_KEY'],
    'token': os.environ['TRELLO_TOKEN'],
    'fields': 'id,name,idShort,desc'
}
r = requests.get(url, params=params)
if r.status_code == 200:
    data = r.json()
    print(json.dumps(data, indent=2))
else:
    print(f'Error: {r.status_code}', file=__import__('sys').stderr)
"
else
    echo "✗ No Trello credentials in environment"
    echo "  TRELLO_KEY: ${TRELLO_KEY:-not set}"
    echo "  TRELLO_TOKEN: ${TRELLO_TOKEN:-not set}"
fi
