n8n-nodes-amocrm
Version:
n8n node for amocrm Api
33 lines • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.execute = void 0;
const clearNullableProps_1 = require("../../../helpers/clearNullableProps");
const transport_1 = require("../../../transport");
async function execute(index) {
const requestMethod = 'POST';
const endpoint = `catalogs`;
const jsonParams = (await this.getNodeParameter('json', 0));
if (jsonParams) {
const jsonString = (await this.getNodeParameter('jsonString', 0));
const responseData = await transport_1.apiRequest.call(this, requestMethod, endpoint, JSON.parse(jsonString));
return this.helpers.returnJsonArray(responseData);
}
const catalogsCollection = (await this.getNodeParameter('collection', 0));
const body = catalogsCollection.catalog
.map((catalog) => {
return {
...catalog,
name: String(catalog.name),
type: String(catalog.type),
sort: Number(catalog.sort) || undefined,
can_add_elements: Boolean(catalog.can_add_elements),
can_link_multiple: Boolean(catalog.can_link_multiple),
request_id: !!catalog.request_id ? String(catalog.request_id) : undefined,
};
})
.map(clearNullableProps_1.clearNullableProps);
const responseData = await transport_1.apiRequest.call(this, requestMethod, endpoint, body);
return this.helpers.returnJsonArray(responseData);
}
exports.execute = execute;
//# sourceMappingURL=execute.js.map