Skip to content

Commit 47fcad9

Browse files
committed
new components
1 parent 22d987d commit 47fcad9

File tree

8 files changed

+132
-249
lines changed

8 files changed

+132
-249
lines changed
Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
import nioleads from "../../nioleads.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "nioleads-find-email",
65
name: "Find Email",
7-
description: "Finds a business email address using a full name and a website domain.",
8-
version: "0.0.{{ts}}",
6+
description: "Finds a business email address using a full name and a website domain. [See the documentation](https://apidoc.nioleads.com/?_gl=1*1288vdg*_ga*MTY1NzE1MjMzOC4xNzI1OTM5Njk1*_ga_ZVT2YHDDZG*MTcyNTk0Mzk5NC4yLjAuMTcyNTk0NDAyMy4wLjAuMA..#email-finder)",
7+
version: "0.0.1",
98
type: "action",
109
props: {
1110
nioleads,
12-
fullName: {
13-
propDefinition: [
14-
nioleads,
15-
"fullName",
16-
],
11+
name: {
12+
type: "string",
13+
label: "Name",
14+
description: "Full name of the person",
1715
},
18-
websiteDomain: {
19-
propDefinition: [
20-
nioleads,
21-
"websiteDomain",
22-
],
16+
domain: {
17+
type: "string",
18+
label: "Domain",
19+
description: "The company domain name. (e.g. `example.com`)",
2320
},
2421
},
2522
async run({ $ }) {
26-
const response = await this.nioleads.findEmail(this.fullName, this.websiteDomain);
27-
$.export("$summary", `Found email: ${response.email}`);
23+
const response = await this.nioleads.findEmail({
24+
$,
25+
data: {
26+
name: this.name,
27+
domain: this.domain,
28+
},
29+
});
30+
if (response?.email) {
31+
$.export("$summary", `Found email: ${response.email}`);
32+
}
2833
return response;
2934
},
3035
};

components/nioleads/actions/verify-email/verify-email.mjs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@ import nioleads from "../../nioleads.app.mjs";
33
export default {
44
key: "nioleads-verify-email",
55
name: "Verify Email",
6-
description: "Checks the deliverability of a specified email address. [See the documentation](https://apidoc.nioleads.com)",
7-
version: "0.0.{{ts}}",
6+
description: "Checks the deliverability of a specified email address. [See the documentation](https://apidoc.nioleads.com/?_gl=1*1288vdg*_ga*MTY1NzE1MjMzOC4xNzI1OTM5Njk1*_ga_ZVT2YHDDZG*MTcyNTk0Mzk5NC4yLjAuMTcyNTk0NDAyMy4wLjAuMA..#email-verifier)",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
nioleads,
1111
email: {
12-
propDefinition: [
13-
nioleads,
14-
"email",
15-
],
12+
type: "string",
13+
label: "Email",
14+
description: "The email address to verify",
1615
},
1716
},
1817
async run({ $ }) {
19-
const response = await this.nioleads.verifyEmail(this.email);
18+
const response = await this.nioleads.verifyEmail({
19+
$,
20+
data: {
21+
email: this.email,
22+
},
23+
});
2024
$.export("$summary", `Verified email ${this.email}`);
2125
return response;
2226
},

components/nioleads/nioleads.app.mjs

Lines changed: 14 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,103 +3,48 @@ import { axios } from "@pipedream/platform";
33
export default {
44
type: "app",
55
app: "nioleads",
6-
propDefinitions: {
7-
email: {
8-
type: "string",
9-
label: "Email",
10-
description: "The email address of the contact",
11-
},
12-
firstName: {
13-
type: "string",
14-
label: "First Name",
15-
description: "The first name of the contact",
16-
optional: true,
17-
},
18-
lastName: {
19-
type: "string",
20-
label: "Last Name",
21-
description: "The last name of the contact",
22-
optional: true,
23-
},
24-
fullName: {
25-
type: "string",
26-
label: "Full Name",
27-
description: "The full name of the person",
28-
},
29-
websiteDomain: {
30-
type: "string",
31-
label: "Website Domain",
32-
description: "The domain of the website",
33-
},
34-
},
6+
propDefinitions: {},
357
methods: {
368
_baseUrl() {
379
return "https://api.nioleads.com/v1/openapi";
3810
},
39-
async _makeRequest(opts = {}) {
11+
_makeRequest(opts = {}) {
4012
const {
4113
$ = this,
42-
method = "GET",
4314
path,
44-
data,
4515
headers,
4616
...otherOpts
4717
} = opts;
4818
return axios($, {
4919
...otherOpts,
50-
method,
51-
url: this._baseUrl() + path,
52-
data,
20+
url: `${this._baseUrl()}${path}`,
5321
headers: {
5422
...headers,
55-
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
23+
"Authorization": `Bearer ${this.$auth.api_key}`,
5624
"Content-Type": "application/json",
5725
"Accept": "application/json",
5826
},
5927
});
6028
},
61-
async verifyEmail(email) {
29+
listContacts(opts = {}) {
30+
return this._makeRequest({
31+
path: "/new_contacts",
32+
...opts,
33+
});
34+
},
35+
verifyEmail(opts = {}) {
6236
return this._makeRequest({
6337
method: "POST",
6438
path: "/verify_email",
65-
data: {
66-
email,
67-
},
39+
...opts,
6840
});
6941
},
70-
async findEmail(fullName, websiteDomain) {
42+
findEmail(opts = {}) {
7143
return this._makeRequest({
7244
method: "POST",
7345
path: "/find_email",
74-
data: {
75-
name: fullName,
76-
domain: websiteDomain,
77-
},
46+
...opts,
7847
});
7948
},
80-
async emitNewContactData(email, firstName, lastName) {
81-
return this.$emit(
82-
{
83-
email,
84-
firstName,
85-
lastName,
86-
},
87-
{
88-
summary: `New contact data found for ${email}`,
89-
},
90-
);
91-
},
92-
async emitNewWatchedContact(email, firstName, lastName) {
93-
return this.$emit(
94-
{
95-
email,
96-
firstName,
97-
lastName,
98-
},
99-
{
100-
summary: `New contact is watched for ${email}`,
101-
},
102-
);
103-
},
10449
},
10550
};

components/nioleads/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/nioleads",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream NioLeads Components",
55
"main": "nioleads.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.1"
1417
}
1518
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import nioleads from "../../nioleads.app.mjs";
2+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3+
import sampleEmit from "./test-event.mjs";
4+
5+
export default {
6+
key: "nioleads-new-contact-added",
7+
name: "New Contact Added",
8+
description: "Emit new event when a new contact is added. [See the documentation](https://apidoc.nioleads.com/?_gl=1*1288vdg*_ga*MTY1NzE1MjMzOC4xNzI1OTM5Njk1*_ga_ZVT2YHDDZG*MTcyNTk0Mzk5NC4yLjAuMTcyNTk0NDAyMy4wLjAuMA..#contacts)",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
props: {
13+
nioleads,
14+
db: "$.service.db",
15+
timer: {
16+
type: "$.interface.timer",
17+
default: {
18+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
19+
},
20+
},
21+
},
22+
hooks: {
23+
async deploy() {
24+
await this.processEvent(25);
25+
},
26+
},
27+
methods: {
28+
_getLastId() {
29+
return this.db.get("lastId") || 0;
30+
},
31+
_setLastId(lastId) {
32+
this.db.set("lastId", lastId);
33+
},
34+
generateMeta(contact) {
35+
return {
36+
id: contact.id,
37+
summary: `New Contact: ${contact.name}`,
38+
ts: Date.now(),
39+
};
40+
},
41+
async processEvent(limit) {
42+
const lastId = this._getLastId();
43+
const contacts = await this.nioleads.listContacts();
44+
if (!contacts?.length) {
45+
return;
46+
}
47+
const newContacts = contacts.filter(({ id }) => id > lastId);
48+
if (limit && newContacts.length > limit) {
49+
newContacts.length = limit;
50+
}
51+
this._setLastId(newContacts[0].id);
52+
newContacts.reverse().forEach((contact) => {
53+
const meta = this.generateMeta(contact);
54+
this.$emit(contact, meta);
55+
});
56+
57+
},
58+
},
59+
async run() {
60+
await this.processEvent();
61+
},
62+
sampleEmit,
63+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export default {
2+
"id": 1,
3+
"name": "Tom ********",
4+
"company": "All We Have Is Now",
5+
"domain": "allwehaveisnow.co",
6+
"job_title": "Keynote Speaker",
7+
"email": "********@allwehaveisnow.co",
8+
"linkedin_url": "http://www.linkedin.com/in/tomfgoodwin",
9+
"first_name": "Tom",
10+
"last_name": "********",
11+
"city": "New York",
12+
"region": "New York",
13+
"country": "United States",
14+
"industry": "management consulting",
15+
"company_city": "New York",
16+
"company_region": "New York",
17+
"company_country": "United States",
18+
"company_linkedin_url": "http://www.linkedin.com/company/all-we-have-is-now",
19+
"list": "Default list"
20+
}

components/nioleads/sources/new-contact-watch/new-contact-watch.mjs

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)