@poli-digital/n8n-nodes-poli
Version:
Nó para interagir com a API da Poli
96 lines • 3.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContactResource = exports.contactDescription = void 0;
const base_1 = require("./base");
exports.contactDescription = {
displayName: 'Contact',
name: 'contact',
value: 'contact',
operations: [
{
displayName: 'Create',
name: 'operation',
value: 'createContact',
description: 'Create a new contact',
action: 'Create a contact',
},
{
displayName: 'Get',
name: 'operation',
value: 'getContact',
description: 'Get a contact',
action: 'Get a contact',
},
{
displayName: 'Update',
name: 'operation',
value: 'updateContact',
description: 'Update a contact',
action: 'Update a contact',
},
{
displayName: 'Add Tag to Contact',
name: 'addTagToContact',
value: 'addTagToContact',
description: 'Adiciona uma tag a um contato',
action: 'Add a tag to a contact',
},
],
properties: [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: { show: { resource: ['contact'] } },
options: [
{
name: 'Create',
value: 'createContact',
},
{
name: 'Get',
value: 'getContact',
},
{
name: 'Update',
value: 'updateContact',
},
{
name: 'Add Tag to Contact',
value: 'addTagToContact',
},
],
default: 'createContact',
},
],
};
class ContactResource extends base_1.BaseResource {
static async create(executeFunctions, index) {
const body = {
applicationId: executeFunctions.getNodeParameter('applicationId', index),
name: executeFunctions.getNodeParameter('contactName', index),
phone: executeFunctions.getNodeParameter('phone', index),
email: executeFunctions.getNodeParameter('email', index),
};
return await this.makeRequest(executeFunctions, 'POST', '/contacts', body, index);
}
static async get(executeFunctions, index) {
const contactId = executeFunctions.getNodeParameter('contactId', index);
return await this.makeRequest(executeFunctions, 'GET', `/contacts/${contactId}`, {}, index);
}
static async update(executeFunctions, index) {
const contactId = executeFunctions.getNodeParameter('contactId', index);
const updateFields = executeFunctions.getNodeParameter('updateFields', index);
return await this.makeRequest(executeFunctions, 'PUT', `/contacts/${contactId}`, updateFields, index);
}
static async addTagToContact(executeFunctions, index) {
const contactUuid = executeFunctions.getNodeParameter('contactUuid', index);
const tagUuid = executeFunctions.getNodeParameter('tagUuid', index);
const body = {
tags: [tagUuid],
};
return await this.makeRequest(executeFunctions, 'POST', `/contacts/${contactUuid}/tags`, body, index);
}
}
exports.ContactResource = ContactResource;
//# sourceMappingURL=contact.js.map