Refactor switch statement

This commit is contained in:
Valentina Lilova 2022-05-31 23:20:52 +03:00
commit 9573fe070d
2 changed files with 21 additions and 17 deletions

View file

@ -140,10 +140,9 @@ export class FriendGrid implements INodeType {
// ---------------------------------- // ----------------------------------
// contact:create // contact:create
// ---------------------------------- // ----------------------------------
// https://docs.sendgrid.com/api-reference/contacts/add-or-update-a-contact // https://docs.sendgrid.com/api-reference/contacts/add-or-update-a-contact
endpoint = ''; endpoint = '/marketing/contacts';
method = 'POST'; method = 'PUT';
const email = this.getNodeParameter('email', i) as string; const email = this.getNodeParameter('email', i) as string;
additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const data: IDataObject = { email }; const data: IDataObject = { email };
@ -151,11 +150,22 @@ export class FriendGrid implements INodeType {
body.contacts = [ data ]; body.contacts = [ data ];
break; break;
case 'directContractInsert': case 'get':
// ---------------------------------- // ----------------------------------
// contract:directContractInsert // contact:get
// ---------------------------------- // ----------------------------------
const contactId = this.getNodeParameter('contactId', i) as string;
endpoint = `/marketing/contacts/${contactId}`;
method = 'GET';
// .........
break;
case 'getAll':
// ----------------------------------
// contact:getAll
// ----------------------------------
endpoint = '/marketing/contacts';
method = 'GET';
// ......... // .........
break; break;
@ -165,20 +175,14 @@ export class FriendGrid implements INodeType {
} }
break; break;
case 'contractProducts': case 'mail':
switch (operation) { switch (operation) {
case 'createDirectInvoice': case 'send':
// ---------------------------------- // ----------------------------------
// contractProducts:createDirectInvoice // mail:send
// ---------------------------------- // ----------------------------------
endpoint = '/mail/send';
// ......... method = 'POST';
break;
case 'getDirectInvoice':
// ----------------------------------
// contractProducts:getDirectInvoice
// ----------------------------------
// ......... // .........
break; break;

View file

@ -1,2 +1,2 @@
// Generated by genversion. // Generated by genversion.
export const version = '0.1.1'; export const version = '0.1.0';