src/graphApi/validateBotApi.js
function validateBotApi (botFactory, postBackTest, textTest, acl) {
    /** @deprecated way to validate bot */
    if (postBackTest && typeof postBackTest === 'object') {

        // @ts-ignore
        return validate(botFactory, postBackTest, textTest, acl)
            .then((res) => {
                if (!res.ok) {
                    throw new Error(res.error);
                }
            });
    }

    return {
        async validateBot (args, ctx) {
            if (!apiAuthorizer(args, ctx, acl)) {
                return null;
            }

            const validationRequestBody = args.bot;

            const bot = botFactory();

            return validate(bot, validationRequestBody, postBackTest, textTest);
        }
    };
}
function validateBotApi (botFactory, postBackTest, textTest, acl) {
    /** @deprecated way to validate bot */
    if (postBackTest && typeof postBackTest === 'object') {

        // @ts-ignore
        return validate(botFactory, postBackTest, textTest, acl)
            .then((res) => {
                if (!res.ok) {
                    throw new Error(res.error);
                }
            });
    }

    return {
        async validateBot (args, ctx) {
            if (!apiAuthorizer(args, ctx, acl)) {
                return null;
            }

            const validationRequestBody = args.bot;

            const bot = botFactory();

            return validate(bot, validationRequestBody, postBackTest, textTest);
        }
    };
}
function validateBotApi ( botFactory , postBackTest , textTest , acl ) { /** @deprecated way to validate bot */ if ( postBackTest && typeof postBackTest === 'object' ) { // @ts-ignore return validate ( botFactory , postBackTest , textTest , acl ) . then ( ( res ) => { if ( ! res . ok ) { throw new Error ( res . error ) ; } } ) ; } return { async validateBot ( args , ctx ) { if ( ! apiAuthorizer ( args , ctx , acl ) ) { return null ; } const validationRequestBody = args . bot ; const bot = botFactory ( ) ; return validate ( bot , validationRequestBody , postBackTest , textTest ) ; } } ; }
Test the bot configuration

@param {Function} botFactory - function, which returns a bot
@param {string|null} [postBackTest] - postback action to test
@param {string|null} [textTest] - random text to test
@param {string[]|Function} [acl] - limit api to array of groups or use auth function
@returns {ValidateBotAPI}
@example
const { GraphApi, validateBotApi } = require('wingbot');

const api = new GraphApi([
validateBotApi(botFactory, 'start', 'hello')
], {
token: 'wingbot-token'
})
Test the bot configuration