Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import salespype from "../../salespype.app.mjs";

export default {
key: "salespype-add-contact-to-campaign",
name: "Add Contact to Campaign",
description: "Adds a contact to a campaign. [See the documentation](https://documenter.getpostman.com/view/5101444/2s93Y3u1Eb#4b2f8b3e-155d-4485-9a25-4f7d98d04b53)",
version: "0.0.1",
type: "action",
props: {
salespype,
campaignId: {
propDefinition: [
salespype,
"campaignId",
],
},
contactId: {
propDefinition: [
salespype,
"contactId",
],
},
},
async run({ $ }) {
const response = await this.salespype.addContactToCampaign({
$,
campaignId: this.campaignId,
contactId: this.contactId,
});
$.export("$summary", `Added contact ${this.contactId} to campaign ${this.campaignId}`);
return response;
},
};
88 changes: 88 additions & 0 deletions components/salespype/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import salespype from "../../salespype.app.mjs";

export default {
key: "salespype-create-contact",
name: "Create Contact",
description: "Creates a new contact in Salespype. [See the documentation](https://documenter.getpostman.com/view/5101444/2s93Y3u1Eb#0a9f8441-c7fa-48dc-b02b-0117037d86ab)",
version: "0.0.1",
type: "action",
props: {
salespype,
firstName: {
type: "string",
label: "First Name",
description: "The first name of the contact",
},
lastName: {
type: "string",
label: "Last Name",
description: "The last name of the contact",
},
email: {
type: "string",
label: "Email",
description: "The email address of the contact",
},
address: {
type: "string",
label: "Address",
description: "The address of the contact",
optional: true,
},
city: {
type: "string",
label: "City",
description: "The city of the contact",
optional: true,
},
state: {
type: "string",
label: "State",
description: "The state of the contact",
optional: true,
},
zip: {
type: "string",
label: "ZIP Code",
description: "The ZIP code of the contact",
optional: true,
},
country: {
type: "string",
label: "Country",
description: "The country of the contact",
optional: true,
},
companyName: {
type: "string",
label: "Company Name",
description: "The company name of the contact",
optional: true,
},
birthDate: {
type: "string",
label: "Birthdate",
description: "The birthdate of the contact",
optional: true,
},
},
async run({ $ }) {
const contact = await this.salespype.createContact({
$,
data: {
firstName: this.firstName,
lastName: this.lastName,
email: this.email,
address: this.address,
city: this.city,
state: this.state,
zip: this.zip,
country: this.country,
companyName: this.companyName,
birthDate: this.birthDate,
},
});
$.export("$summary", `Created contact ${this.firstName} ${this.lastName} (${this.email})`);
return contact;
},
};
72 changes: 72 additions & 0 deletions components/salespype/actions/create-task/create-task.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import salespype from "../../salespype.app.mjs";

export default {
key: "salespype-create-task",
name: "Create Task",
description: "Creates a new task in Salespype. [See the documentation](https://documenter.getpostman.com/view/5101444/2s93Y3u1Eb#a9c6449a-b844-465c-a342-deea01e52c3f)",
version: "0.0.1",
type: "action",
props: {
salespype,
contactId: {
propDefinition: [
salespype,
"contactId",
],
},
task: {
type: "string",
label: "Task",
description: "The task description",
},
taskTypeId: {
propDefinition: [
salespype,
"taskTypeId",
],
},
date: {
type: "string",
label: "Date",
description: "The date for the task. E.g. `2021-02-20`",
},
time: {
type: "string",
label: "Time",
description: "The time for the task. E.g. `34:00:34`",
},
duration: {
type: "string",
label: "Duration",
description: "The duration of the task. E.g. `34:00:34`",
},
note: {
type: "string",
label: "Note",
description: "Additional notes for the task",
},
},
async run({ $ }) {
const {
task, message,
} = await this.salespype.createTask({
$,
contactId: this.contactId,
data: {
task: this.task,
taskTypeId: this.taskTypeId,
date: this.date,
time: this.time,
duration: this.duration,
note: this.note,
},
});

if (message) {
throw new Error(`${message}`);
}

$.export("$summary", `Created task '${this.task}' with ID ${task.id}`);
return task;
},
};
8 changes: 6 additions & 2 deletions components/salespype/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/salespype",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Salespype Components",
"main": "salespype.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,9 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3",
"md5": "^2.3.0"
}
}
}
139 changes: 135 additions & 4 deletions components/salespype/salespype.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,142 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "salespype",
propDefinitions: {},
propDefinitions: {
contactId: {
type: "string",
label: "Contact ID",
description: "The unique identifier of the contact",
async options({ page }) {
const { contacts } = await this.listContacts({
params: {
page: page + 1,
},
});
return contacts?.map(({
id: value, fullName: label,
}) => ({
value,
label,
})) || [];
},
},
campaignId: {
type: "string",
label: "Campaign ID",
description: "The unique identifier of the campaign",
async options({ page }) {
const { campaigns } = await this.listCampaigns({
params: {
page: page + 1,
},
});
return campaigns?.map(({
id: value, title: label,
}) => ({
value,
label,
})) || [];
},
},
taskTypeId: {
type: "string",
label: "Task Type ID",
description: "The unique identifier of the task type",
async options() {
const { taskTypes } = await this.listTaskTypes();
return taskTypes?.map(({
id: value, task: label,
}) => ({
value,
label,
})) || [];
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.pypepro.io/crm/v1";
},
_makeRequest({
$ = this,
path,
...otherOpts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: {
apikey: this.$auth.api_token,
},
...otherOpts,
});
},
listContacts(opts = {}) {
return this._makeRequest({
path: "/contacts/list",
...opts,
});
},
listCampaigns(opts = {}) {
return this._makeRequest({
path: "/campaigns",
...opts,
});
},
listTaskTypes(opts = {}) {
return this._makeRequest({
path: "/tasks/types",
...opts,
});
},
createContact(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/contacts",
...opts,
});
},
addContactToCampaign({
campaignId, contactId, ...opts
}) {
return this._makeRequest({
method: "POST",
path: `/campaigns/${campaignId}/contacts/${contactId}`,
...opts,
});
},
createTask({
contactId, ...opts
}) {
return this._makeRequest({
method: "POST",
path: `/tasks/contacts/${contactId}`,
...opts,
});
},
async *paginate({
fn, params, resourceKey, max,
}) {
params = {
...params,
page: 0,
};
let totalPages, count = 0;
do {
params.page++;
const results = await fn({
params,
});
const items = results[resourceKey];
for (const item of items) {
yield item;
if (max && ++count >= max) {
return;
}
}
totalPages = results.totalPages;
} while (params.page < totalPages);
},
},
};
Loading
Loading