UNPKG

n8n-nodes-gohighlevel

Version:
76 lines 2.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ApiCall = void 0; const pretty_log_1 = require("./pretty-log"); class ApiCall { constructor(executeFunction, baseURL) { this.n8n = executeFunction; this.baseURL = baseURL; } async httpRequestWithAuthentication({ method, path, body, params, verbose = false }) { const url = path.startsWith('/') ? `${this.baseURL}${path}` : path; const options = { method, body, headers: { 'Content-Type': 'application/json', 'Version': '2021-07-28', }, qs: params, url: url, returnFullResponse: true }; if (verbose) { console.log(`curl -X ${method} ${url}\n${body ? ` -d '${JSON.stringify(body, null, 2)}'` : ''}`); (0, pretty_log_1.prettyLog)(options); } const response = (await this.n8n.helpers.httpRequestWithAuthentication.call(this.n8n, 'goHighLevelOAuth2Api', options)); if (verbose) { (0, pretty_log_1.prettyLog)({ infos: { statusCode: response.statusCode, statusMessage: response.statusMessage, }, body: response.body, }); } return response; } async get(path, options) { const response = await this.httpRequestWithAuthentication({ method: 'GET', path, ...options, verbose: false }); return response.body; } async post(path, options) { const response = await this.httpRequestWithAuthentication({ method: 'POST', path, ...options, }); return response.body; } async put(path, options) { const response = await this.httpRequestWithAuthentication({ method: 'PUT', path, ...options, verbose: true, }); return response.body; } async delete(path, options) { const response = await this.httpRequestWithAuthentication({ method: 'DELETE', path, ...options, }); return response.body; } } exports.ApiCall = ApiCall; exports.default = ApiCall; //# sourceMappingURL=api.js.map