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

New Components - nioleads #13934

Merged
merged 5 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions components/nioleads/actions/find-email/find-email.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import nioleads from "../../nioleads.app.mjs";

export default {
key: "nioleads-find-email",
name: "Find Email",
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)",
version: "0.0.1",
type: "action",
props: {
nioleads,
name: {
type: "string",
label: "Name",
description: "Full name of the person",
},
domain: {
type: "string",
label: "Domain",
description: "The company domain name. (e.g. `example.com`)",
},
},
async run({ $ }) {
const response = await this.nioleads.findEmail({
$,
data: {
name: this.name,
domain: this.domain,
},
});
if (response?.email) {
$.export("$summary", `Found email: ${response.email}`);
}
return response;
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
};
27 changes: 27 additions & 0 deletions components/nioleads/actions/verify-email/verify-email.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import nioleads from "../../nioleads.app.mjs";

export default {
key: "nioleads-verify-email",
name: "Verify Email",
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)",
version: "0.0.1",
type: "action",
props: {
nioleads,
email: {
type: "string",
label: "Email",
description: "The email address to verify",
},
},
async run({ $ }) {
const response = await this.nioleads.verifyEmail({
$,
data: {
email: this.email,
},
});
$.export("$summary", `Verified email ${this.email}`);
return response;
},
};
47 changes: 43 additions & 4 deletions components/nioleads/nioleads.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,50 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "nioleads",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.nioleads.com/v1/openapi";
},
_makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: `${this._baseUrl()}${path}`,
headers: {
...headers,
"Authorization": `Bearer ${this.$auth.api_key}`,
"Content-Type": "application/json",
"Accept": "application/json",
},
});
},
listContacts(opts = {}) {
return this._makeRequest({
path: "/new_contacts",
...opts,
});
},
verifyEmail(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/verify_email",
...opts,
});
},
findEmail(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/find_email",
...opts,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/nioleads/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/nioleads",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream NioLeads Components",
"main": "nioleads.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.1"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import nioleads from "../../nioleads.app.mjs";
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
import sampleEmit from "./test-event.mjs";

export default {
key: "nioleads-new-contact-added",
name: "New Contact Added",
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)",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
nioleads,
db: "$.service.db",
timer: {
type: "$.interface.timer",
default: {
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
},
},
},
hooks: {
async deploy() {
await this.processEvent(25);
},
},
methods: {
_getLastId() {
return this.db.get("lastId") || 0;
},
_setLastId(lastId) {
this.db.set("lastId", lastId);
},
generateMeta(contact) {
return {
id: contact.id,
summary: `New Contact: ${contact.name}`,
ts: Date.now(),
};
},
async processEvent(limit) {
const lastId = this._getLastId();
const contacts = await this.nioleads.listContacts();
if (!contacts?.length) {
return;
}
const newContacts = contacts.filter(({ id }) => id > lastId);
if (limit && newContacts.length > limit) {
newContacts.length = limit;
}
this._setLastId(newContacts[0].id);
newContacts.reverse().forEach((contact) => {
const meta = this.generateMeta(contact);
this.$emit(contact, meta);
});

},
},
async run() {
await this.processEvent();
},
sampleEmit,
};
20 changes: 20 additions & 0 deletions components/nioleads/sources/new-contact-added/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default {
"id": 1,
"name": "Tom ********",
"company": "All We Have Is Now",
"domain": "allwehaveisnow.co",
"job_title": "Keynote Speaker",
"email": "********@allwehaveisnow.co",
"linkedin_url": "http://www.linkedin.com/in/tomfgoodwin",
"first_name": "Tom",
"last_name": "********",
"city": "New York",
"region": "New York",
"country": "United States",
"industry": "management consulting",
"company_city": "New York",
"company_region": "New York",
"company_country": "United States",
"company_linkedin_url": "http://www.linkedin.com/company/all-we-have-is-now",
"list": "Default list"
}
107 changes: 55 additions & 52 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading