"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const dotenv_1 = __importDefault(require("dotenv"));
const path_1 = __importDefault(require("path"));
dotenv_1.default.config({ path: path_1.default.resolve(__dirname, '../../.env') });
const TOKEN = process.env.WHATSAPP_ACCESS_TOKEN;
const PHONE_ID = process.env.WHATSAPP_PHONE_NUMBER_ID;
async function testWhatsAppCTA() {
    console.log("--- WhatsApp Interactive CTA Test ---");
    const url = `https://graph.facebook.com/v22.0/${PHONE_ID}/messages`;
    const body = {
        messaging_product: "whatsapp",
        to: "9779843804086",
        type: "template",
        template: {
            name: "jaspers_market_image_cta_v1",
            language: { code: "en_US" },
            components: [{
                    type: "header",
                    parameters: [{
                            type: "image",
                            image: {
                                link: "https://scontent.xx.fbcdn.net/mci_ab/uap/asset_manager/id/?ab_b=e&ab_page=AssetManagerID&ab_entry=1530053877871776"
                            }
                        }]
                }]
        }
    };
    try {
        const response = await fetch(url, {
            method: "POST",
            headers: {
                "Authorization": `Bearer ${TOKEN}`,
                "Content-Type": "application/json",
            },
            body: JSON.stringify(body),
        });
        const data = await response.json();
        console.log("Status:", response.status);
        console.log("Response:", JSON.stringify(data, null, 2));
    }
    catch (error) {
        console.error("Error:", error);
    }
}
testWhatsAppCTA();
