Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customer.io Trigger Node #44

Closed
wants to merge 10 commits into from
Closed

Customer.io Trigger Node #44

wants to merge 10 commits into from

Conversation

Shraddha2104
Copy link
Member

@Shraddha2104 Shraddha2104 commented Jul 1, 2020

Hi,
✨ Added a Customer.io trigger node.

  • Implemented the following trigger events:
    • Customer
    • Email
    • Push
    • Slack

Let me know if it can be refactored anywhere!

@Shraddha2104 Shraddha2104 changed the title Customer.io Customer.io Trigger Node Jul 1, 2020
Copy link
Member

@erin2722 erin2722 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I am having trouble w tests but here is some initial feedback

@@ -19,8 +19,8 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
const endpoint = `${service}.${credentials.region}.amazonaws.com`;

// Sign AWS API request with the user credentials
const signOpts = {headers: headers || {}, host: endpoint, method, path, body};
sign(signOpts, {accessKeyId: `${credentials.accessKeyId}`, secretAccessKey: `${credentials.secretAccessKey}`});
const signOpts = { headers: headers || {}, host: endpoint, method, path, body };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure not to change other files in your PRs!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ya I'll make sure to remove it

import { OptionsWithUri } from 'request';
import { IDataObject } from 'n8n-workflow';

export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query?: IDataObject): Promise<any> { // tslint:disable-line:no-any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to go w codebase conventions, name this customerIoApiRequest

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya, I'll make the changes

},
method,
body,
qs: query,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name the param qs so that you can write qs,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!

@@ -1,19 +1,19 @@
import {
IHookFunctions,
IWebhookFunctions,
} from 'n8n-core';
} from 'n8n-core';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also make sure to leave out this file!

@erin2722 erin2722 self-assigned this Jul 2, 2020
Copy link
Member

@ivov ivov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Shraddha2104! Small details.

Linter errors:

ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts:242:9 - Identifier 'events_list' is never reassigned; use 'const' instead of 'var'.
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts:242:9 - variable name must be in lowerCamelCase or UPPER_CASE
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts:242:39 - Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type.
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts:244:6 - Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts:244:10 - Identifier 'obj' is never reassigned; use 'const' instead of 'var'.
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts:245:6 - Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts:245:10 - Identifier 'key' is never reassigned; use 'const' instead of 'var'.
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts:246:6 - Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts:246:10 - Identifier 'val' is never reassigned; use 'const' instead of 'var'.
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts:249:7 - Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts:249:11 - Identifier 'value' is never reassigned; use 'const' instead of 'var'.
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts:253:7 - Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts:253:11 - Identifier 'obj1' is never reassigned; use 'const' instead of 'var'.
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts:19:8 - Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type.
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts:23:12 - Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type.
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts:68:8 - Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type.
ERROR: C:/Users/IvanOv/Desktop/third/n8n/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts:70:12 - Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type.

Comment on lines 228 to 232
} catch (err) {
if (err.statusCode === 404) {
return false;
}
throw new Error(`Customer.io Error: ${err}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errerror

const webhookUrl = this.getNodeWebhookUrl('default');
const events = this.getNodeParameter('events', []) as string[];
const endpoint = '/reporting_webhooks';
var events_list: { [key: string]: any } = {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let or const

Comment on lines 244 to 255
var obj = event.split('.'); //push.attempted
var key = obj[0]; //push
var val = obj[1]; //attempted

if (events_list.hasOwnProperty(key)) {
var value = events_list[key];
value[val] = true;
}
else {
var obj1: { [val: string]: boolean; } = { [val]: true }; //{'attempted':true}
events_list[key] = obj1;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to rename obj, key and val using the API names pushAttempted, push and attempted?

Comment on lines 265 to 267
} catch (e) {
throw e;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eerror

const endpoint = `/reporting_webhooks/${webhookData.webhookId}`;
try {
await customerIoApiRequest.call(this, 'DELETE', endpoint, {}, {});
} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eerror

Comment on lines 7 to 8
import { OptionsWithUri } from 'request';
import { IDataObject } from 'n8n-workflow';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Staggered lines and trailing commas.

@Shraddha2104
Copy link
Member Author

Submitted to maintainers here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants