import CodeSnippet from '../CodeSnippet.js';
export default class jQuerySnippet extends CodeSnippet {
    lang = 'javascript';
    computeCommand(url, method, headers, payload) {
        if (!url || !method) {
            return '';
        }
        const settings = {
            async: true,
            crossDomain: true,
            url,
            method,
        };
        if (headers) {
            settings.headers = {};
            const map = settings.headers;
            for (const [name, value] of headers) {
                map[name] = value;
            }
        }
        if (payload) {
            settings.processData = false;
            settings.data = payload;
        }
        let result = 'const settings = ';
        result += JSON.stringify(settings, null, 2);
        result += '\n\n';
        result += '$.ajax(settings).done((response) => {\n';
        result += '  console.log(response);\n';
        result += '});\n';
        return result;
    }
}
//# sourceMappingURL=jQuerySnippet.js.map