@progtechbr/n8n-nodes-rdsme
Version:
Send events through API to RD Station Marketing para Ecommerce
33 lines • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.rdStationApiRequest = rdStationApiRequest;
const n8n_workflow_1 = require("n8n-workflow");
const GenericConstants_1 = require("./GenericConstants");
async function rdStationApiRequest(method, resource, body = {}, qs = {}, uri, optionOverrides = {}) {
const endpoint = (uri !== null && uri !== void 0 ? uri : `${GenericConstants_1.BASE_API_URL}/platform${resource}`);
let options = {
method,
uri: endpoint,
qs,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
json: true,
...optionOverrides,
};
if (Object.keys(body).length > 0) {
options.body = body;
}
const oAuth2Options = {
tokenType: 'Bearer',
includeCredentialsOnRefreshOnBody: true,
};
try {
return await this.helpers.requestOAuth2.call(this, 'rdsmEcommerceOAuth2Api', options, oAuth2Options);
}
catch (error) {
throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
}
}
//# sourceMappingURL=GenericFunctions.js.map