"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
require("dotenv/config");
const server_1 = __importDefault(require("./classes/server"));
let notificationServer = new server_1.default(process.env.LISTEN_PORT, process.env.VERIFY_TOKEN);
let app = notificationServer.start((rawData, processedPayload) => __awaiter(void 0, void 0, void 0, function* () {
    // NOTE: raw_data is the raw data you recieve from Whatsapp 
    // NOTE: processed_data is a object of ProcessPayload, 
    // NOTE: it contains both the data and helper functions
    // TIP FOR BEGINNERS: use processed_data
    if (processedPayload.type == "messages") {
        let messages = processedPayload.get_messages();
        for (const message of messages) {
            if (message.type == "text") {
                // console.log("Message Data: ", message)
                return message;
            }
            else if (message.type == "image") {
                // console.log("Image Message Data: ", message)
                return message;
            }
            else if (message.type == "sticker") {
                // console.log("Sticker Message Data: ", message)
                return message;
            }
            else if (message.type == "video") {
                // console.log("Video Message Data: ", message)
                return message;
            }
            else if (message.type == "audio") {
                // console.log("Audio Message Data: ", message)
                return message;
            }
            else if (message.type == "document") {
                // console.log("Document Message Data: ", message)
                return message;
            }
            else if (message.type == "location") {
                // console.log("Location Message Data: ", message)
                return message;
            }
            else if (message.type == "contacts") {
                // console.log("Contacts Message Data: ", message)
                return message;
            }
        }
    }
    // // console.log("Payload Type: ", processedPayload.type)
    // // console.log("Payload Data: ", processedPayload.data.entry[0].changes[0].value)
    return "Thanks, notification recieved!";
}));
exports.default = app;
