#!/bin/bash

# Zoho OAuth Setup Helper Script
set -e

# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

echo -e "${BLUE}=== Zoho OAuth Setup Helper ===${NC}"
echo
echo -e "${YELLOW}This script will guide you through the Zoho OAuth setup process.${NC}"
echo
echo -e "${GREEN}Step 1: Open Authorization URL${NC}"
echo "Open the following URL in your browser:"
echo
echo "https://accounts.zoho.com/oauth/v2/auth?scope=ZohoCRM.settings.all%2CZohoCRM.modules.all%2CZohoCRM.users.all%2CZohoCRM.org.all&client_id=1000.Z0HOF1VMMJ9W2QWSU57GVQYEAVUSKS&response_type=code&access_type=offline&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fcallback&prompt=consent"
echo
echo -e "${GREEN}Step 2: Authorize and Get Code${NC}"
echo "1. Log in to Zoho if prompted"
echo "2. Review and accept the permissions"
echo "3. You'll be redirected to: http://localhost:8080/callback?code=AUTH_CODE"
echo "4. Copy the 'code' parameter from the URL"
echo
echo -e "${GREEN}Step 3: Run Integration Test${NC}"
echo "Once you have the code, run:"
echo "cd /Users/ben/dev/upskill-event-manager/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/zoho"
echo "php test-integration.php"
echo
echo "Then paste the authorization code when prompted."
echo
echo -e "${BLUE}Note: The authorization code expires quickly, so complete the process promptly.${NC}"