diff --git a/components/nioleads/actions/find-email/find-email.mjs b/components/nioleads/actions/find-email/find-email.mjs new file mode 100644 index 0000000000000..ca3bb6b2e3a0d --- /dev/null +++ b/components/nioleads/actions/find-email/find-email.mjs @@ -0,0 +1,36 @@ +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?.code) { + throw new Error(`${response.msg}`); + } + $.export("$summary", `Found email: ${response.email}`); + return response; + }, +}; diff --git a/components/nioleads/actions/verify-email/verify-email.mjs b/components/nioleads/actions/verify-email/verify-email.mjs new file mode 100644 index 0000000000000..fe8e7d95991fc --- /dev/null +++ b/components/nioleads/actions/verify-email/verify-email.mjs @@ -0,0 +1,30 @@ +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, + }, + }); + if (response?.code) { + throw new Error(`${response.msg}`); + } + $.export("$summary", `Verified email ${this.email}`); + return response; + }, +}; diff --git a/components/nioleads/nioleads.app.mjs b/components/nioleads/nioleads.app.mjs index 3f728a760cd4a..1cb59c5a80826 100644 --- a/components/nioleads/nioleads.app.mjs +++ b/components/nioleads/nioleads.app.mjs @@ -1,11 +1,48 @@ +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, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: `${this._baseUrl()}${path}`, + 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, + }); }, }, -}; \ No newline at end of file +}; diff --git a/components/nioleads/package.json b/components/nioleads/package.json index 3cb6f8a968aaf..6478ec2d01c2b 100644 --- a/components/nioleads/package.json +++ b/components/nioleads/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/nioleads", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream NioLeads Components", "main": "nioleads.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.1" } -} \ No newline at end of file +} diff --git a/components/nioleads/sources/new-contact-added/new-contact-added.mjs b/components/nioleads/sources/new-contact-added/new-contact-added.mjs new file mode 100644 index 0000000000000..d28de5f58d550 --- /dev/null +++ b/components/nioleads/sources/new-contact-added/new-contact-added.mjs @@ -0,0 +1,62 @@ +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, +}; diff --git a/components/nioleads/sources/new-contact-added/test-event.mjs b/components/nioleads/sources/new-contact-added/test-event.mjs new file mode 100644 index 0000000000000..be75f936ad620 --- /dev/null +++ b/components/nioleads/sources/new-contact-added/test-event.mjs @@ -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" +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c60247f5bfb99..1d2b39da77029 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6331,7 +6331,10 @@ importers: '@pipedream/platform': 1.5.1 components/nioleads: - specifiers: {} + specifiers: + '@pipedream/platform': ^3.0.1 + dependencies: + '@pipedream/platform': 3.0.1 components/nocodb: specifiers: @@ -12662,6 +12665,55 @@ packages: - aws-crt dev: false + /@aws-sdk/client-sso-oidc/3.600.0_tdq3komn4zwyd65w7klbptsu34: + resolution: {integrity: sha512-7+I8RWURGfzvChyNQSyj5/tKrqRbzRl7H+BnTOf/4Vsw1nFOi5ROhlhD4X/Y0QCTacxnaoNcIrqnY7uGGvVRzw==} + engines: {node: '>=16.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 5.2.0 + '@aws-crypto/sha256-js': 5.2.0 + '@aws-sdk/client-sts': 3.600.0 + '@aws-sdk/core': 3.598.0 + '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 + '@aws-sdk/middleware-host-header': 3.598.0 + '@aws-sdk/middleware-logger': 3.598.0 + '@aws-sdk/middleware-recursion-detection': 3.598.0 + '@aws-sdk/middleware-user-agent': 3.598.0 + '@aws-sdk/region-config-resolver': 3.598.0 + '@aws-sdk/types': 3.598.0 + '@aws-sdk/util-endpoints': 3.598.0 + '@aws-sdk/util-user-agent-browser': 3.598.0 + '@aws-sdk/util-user-agent-node': 3.598.0 + '@smithy/config-resolver': 3.0.3 + '@smithy/core': 2.2.3 + '@smithy/fetch-http-handler': 3.2.1 + '@smithy/hash-node': 3.0.2 + '@smithy/invalid-dependency': 3.0.2 + '@smithy/middleware-content-length': 3.0.2 + '@smithy/middleware-endpoint': 3.0.4 + '@smithy/middleware-retry': 3.0.6 + '@smithy/middleware-serde': 3.0.3 + '@smithy/middleware-stack': 3.0.3 + '@smithy/node-config-provider': 3.1.3 + '@smithy/node-http-handler': 3.1.2 + '@smithy/protocol-http': 4.0.3 + '@smithy/smithy-client': 3.1.6 + '@smithy/types': 3.3.0 + '@smithy/url-parser': 3.0.3 + '@smithy/util-base64': 3.0.0 + '@smithy/util-body-length-browser': 3.0.0 + '@smithy/util-body-length-node': 3.0.0 + '@smithy/util-defaults-mode-browser': 3.0.6 + '@smithy/util-defaults-mode-node': 3.0.6 + '@smithy/util-endpoints': 2.0.3 + '@smithy/util-middleware': 3.0.3 + '@smithy/util-retry': 3.0.2 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.3 + transitivePeerDependencies: + - '@aws-sdk/client-sts' + - aws-crt + dev: false + /@aws-sdk/client-sso/3.423.0: resolution: {integrity: sha512-znIufHkwhCIePgaYciIs3x/+BpzR57CZzbCKHR9+oOvGyufEPPpUT5bFLvbwTgfiVkTjuk6sG/ES3U5Bc+xtrA==} engines: {node: '>=14.0.0'} @@ -12897,7 +12949,7 @@ packages: dependencies: '@aws-crypto/sha256-browser': 5.2.0 '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0 + '@aws-sdk/client-sso-oidc': 3.600.0_tdq3komn4zwyd65w7klbptsu34 '@aws-sdk/core': 3.598.0 '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 '@aws-sdk/middleware-host-header': 3.598.0 @@ -12939,55 +12991,6 @@ packages: - aws-crt dev: false - /@aws-sdk/client-sts/3.600.0_dseaa2p5u2yk67qiepewcq3hkq: - resolution: {integrity: sha512-KQG97B7LvTtTiGmjlrG1LRAY8wUvCQzrmZVV5bjrJ/1oXAU7DITYwVbSJeX9NWg6hDuSk0VE3MFwIXS2SvfLIA==} - engines: {node: '>=16.0.0'} - dependencies: - '@aws-crypto/sha256-browser': 5.2.0 - '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0 - '@aws-sdk/core': 3.598.0 - '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 - '@aws-sdk/middleware-host-header': 3.598.0 - '@aws-sdk/middleware-logger': 3.598.0 - '@aws-sdk/middleware-recursion-detection': 3.598.0 - '@aws-sdk/middleware-user-agent': 3.598.0 - '@aws-sdk/region-config-resolver': 3.598.0 - '@aws-sdk/types': 3.598.0 - '@aws-sdk/util-endpoints': 3.598.0 - '@aws-sdk/util-user-agent-browser': 3.598.0 - '@aws-sdk/util-user-agent-node': 3.598.0 - '@smithy/config-resolver': 3.0.3 - '@smithy/core': 2.2.3 - '@smithy/fetch-http-handler': 3.2.1 - '@smithy/hash-node': 3.0.2 - '@smithy/invalid-dependency': 3.0.2 - '@smithy/middleware-content-length': 3.0.2 - '@smithy/middleware-endpoint': 3.0.4 - '@smithy/middleware-retry': 3.0.6 - '@smithy/middleware-serde': 3.0.3 - '@smithy/middleware-stack': 3.0.3 - '@smithy/node-config-provider': 3.1.3 - '@smithy/node-http-handler': 3.1.2 - '@smithy/protocol-http': 4.0.3 - '@smithy/smithy-client': 3.1.6 - '@smithy/types': 3.3.0 - '@smithy/url-parser': 3.0.3 - '@smithy/util-base64': 3.0.0 - '@smithy/util-body-length-browser': 3.0.0 - '@smithy/util-body-length-node': 3.0.0 - '@smithy/util-defaults-mode-browser': 3.0.6 - '@smithy/util-defaults-mode-node': 3.0.6 - '@smithy/util-endpoints': 2.0.3 - '@smithy/util-middleware': 3.0.3 - '@smithy/util-retry': 3.0.2 - '@smithy/util-utf8': 3.0.0 - tslib: 2.6.3 - transitivePeerDependencies: - - '@aws-sdk/client-sso-oidc' - - aws-crt - dev: false - /@aws-sdk/core/3.556.0: resolution: {integrity: sha512-vJaSaHw2kPQlo11j/Rzuz0gk1tEaKdz+2ser0f0qZ5vwFlANjt08m/frU17ctnVKC1s58bxpctO/1P894fHLrA==} engines: {node: '>=14.0.0'} @@ -17286,7 +17289,7 @@ packages: '@aws-sdk/client-sns': 3.423.0 '@aws-sdk/client-sqs': 3.423.0 '@aws-sdk/client-ssm': 3.423.0 - '@aws-sdk/client-sts': 3.600.0_dseaa2p5u2yk67qiepewcq3hkq + '@aws-sdk/client-sts': 3.600.0 '@aws-sdk/s3-request-presigner': 3.609.0 '@pipedream/helper_functions': 0.3.12 '@pipedream/platform': 1.6.6