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

[Components] wiza #11912 #11951

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
78 changes: 78 additions & 0 deletions components/wiza/actions/create-list/create-list.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import app from "../../wiza.app.mjs";

export default {
key: "wiza-create-list",
name: "Create List",
description: "Create a list of people to enrich. [See the documentation](https://wiza.co/api-docs#/paths/~1api~1lists/post)",
version: "0.0.1",
type: "action",
props: {
app,
name: {
propDefinition: [
app,
"name",
],
},
enrichmentLevel: {
propDefinition: [
app,
"enrichmentLevel",
],
},
acceptGeneric: {
propDefinition: [
app,
"acceptGeneric",
],
},
acceptPersonal: {
propDefinition: [
app,
"acceptPersonal",
],
},
acceptWork: {
propDefinition: [
app,
"acceptWork",
],
},
fullName: {
propDefinition: [
app,
"fullName",
],
},
company: {
propDefinition: [
app,
"company",
],
},
},
async run({ $ }) {
const response = await this.app.createList({
$,
data: {
name: this.description,
enrichmentLevel: this.enrichmentLevel,
email_options: {
accept_generic: this.acceptGeneric,
accept_personal: this.acceptPersonal,
accept_work: this.acceptWork,
},
items: [
{
full_name: this.fullName,
company: this.company,
},
],
},
});

$.export("$summary", `'${response.status.message}', your list's ID is '${response.data.id}'`);

return response;
},
};
37 changes: 37 additions & 0 deletions components/wiza/actions/get-contacts/get-contacts.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import app from "../../wiza.app.mjs";

export default {
key: "wiza-get-contacts",
name: "Get Contacts",
description: "Get contacts for a list. [See the documentation](https://wiza.co/api-docs#/paths/~1api~1lists~1%7Bid%7D/get)",
version: "0.0.1",
type: "action",
props: {
app,
id: {
propDefinition: [
app,
"id",
],
},
segment: {
propDefinition: [
app,
"segment",
],
},
},
async run({ $ }) {
const response = await this.app.getContacts({
$,
id: this.id,
params: {
segment: this.segment,
},
});

$.export("$summary", "Successfully retrieved the list's contacts");

return response;
},
};
28 changes: 28 additions & 0 deletions components/wiza/actions/get-list/get-list.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import app from "../../wiza.app.mjs";

export default {
key: "wiza-get-list",
name: "Get List",
description: "Get the list with the given id. [See the documentation](https://wiza.co/api-docs#/paths/~1api~1lists~1%7Bid%7D/get)",
version: "0.0.1",
type: "action",
props: {
app,
id: {
propDefinition: [
app,
"id",
],
},
},
async run({ $ }) {
const response = await this.app.getList({
$,
id: this.id,
});

$.export("$summary", `The status of your list is: '${response.data.status}'`);

return response;
},
};
11 changes: 11 additions & 0 deletions components/wiza/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
SEGMENTS: [
"people",
"valid",
"risky",
],
ENRICHMENT_LEVELS: [
"partial",
"full",
],
};
7 changes: 5 additions & 2 deletions components/wiza/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/wiza",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Wiza Components",
"main": "wiza.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.6.5"
}
}
}
97 changes: 93 additions & 4 deletions components/wiza/wiza.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,100 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "wiza",
propDefinitions: {},
propDefinitions: {
acceptWork: {
type: "boolean",
label: "Work Email",
description: "Accept professional email address? i.e. '[email protected]'",
},
acceptPersonal: {
type: "boolean",
label: "Personal Email",
description: "Accept personal email address? i.e. '[email protected]'",
},
acceptGeneric: {
type: "boolean",
label: "Generic Email",
description: "Accept generic email address? i.e. '[email protected]'",
},
enrichmentLevel: {
type: "string",
label: "Enrichment Level",
description: "Enrichment level of the list.",
options: constants.ENRICHMENT_LEVELS,
},
name: {
type: "string",
label: "Name",
description: "Name of the list",
},
fullName: {
type: "string",
label: "Full Name",
description: "Full name of the contact",
},
company: {
type: "string",
label: "Company",
description: "Name of the company",
},
id: {
type: "string",
label: "List ID",
description: "ID of the list",
},
segment: {
type: "string",
label: "Segment",
description: "Specify the segment of contacts to return",
options: constants.SEGMENTS,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://wiza.co/api";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
Authorization: `Bearer ${this.$auth.api_key}`,
},
});
},
async getList({
args, id,
}) {
return this._makeRequest({
path: `/lists/${id}`,
...args,
});
},
async getContacts({
id, ...args
}) {
return this._makeRequest({
path: `/lists/${id}/contacts`,
...args,
});
},
async createList(args = {}) {
return this._makeRequest({
method: "post",
path: "/lists",
...args,
});
},
},
};
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

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

Loading