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

15625 bug update pipedrive components to latest sdk api version #15651

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
196 changes: 87 additions & 109 deletions components/pipedrive/actions/add-activity/add-activity.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { ConfigurationError } from "@pipedream/platform";
import constants from "../../common/constants.mjs";
import utils from "../../common/utils.mjs";
import { parseObject } from "../../common/utils.mjs";
import pipedriveApp from "../../pipedrive.app.mjs";

export default {
key: "pipedrive-add-activity",
name: "Add Activity",
description: "Adds a new activity. Includes `more_activities_scheduled_in_context` property in response's `additional_data` which indicates whether there are more undone activities scheduled with the same deal, person or organization (depending on the supplied data). See the Pipedrive API docs for Activities [here](https://developers.pipedrive.com/docs/api/v1/#!/Activities). For info on [adding an activity in Pipedrive](https://developers.pipedrive.com/docs/api/v1/Activities#addActivity)",
version: "0.1.6",
version: "0.1.7",
type: "action",
props: {
pipedriveApp,
Expand All @@ -15,22 +16,6 @@ export default {
label: "Subject",
description: "Subject of the activity",
},
done: {
type: "string",
label: "Done",
description: "Whether the activity is done or not. 0 = Not done, 1 = Done",
optional: true,
options: [
{
label: "Not done",
value: "0",
},
{
label: "Done",
value: "1",
},
],
},
type: {
type: "string",
label: "Type",
Expand All @@ -45,25 +30,7 @@ export default {
}));
},
},
dueDate: {
type: "string",
label: "Due Date",
description: "Due date of the activity. Format: `YYYY-MM-DD`",
optional: true,
},
dueTime: {
type: "string",
label: "Due Time",
description: "Due time of the activity in UTC. Format: `HH:MM`",
optional: true,
},
duration: {
type: "string",
label: "Duration",
description: "Duration of the activity. Format: `HH:MM`",
optional: true,
},
userId: {
ownerId: {
propDefinition: [
pipedriveApp,
"userId",
Expand All @@ -76,148 +43,159 @@ export default {
"dealId",
],
},
personId: {
leadId: {
propDefinition: [
pipedriveApp,
"personId",
"leadId",
],
description: "ID of the person this activity will be associated with",
},
participants: {
type: "string[]",
label: "Participants",
description: "List of multiple persons (participants) this activity will be associated with. If omitted, single participant from `person_id` field is used. It requires a structure as follows: `[{\"person_id\":1,\"primary_flag\":true}]`",
optional: true,
orgId: {
propDefinition: [
pipedriveApp,
"personId",
"organizationId",
],
description: "ID of the organization this activity will be associated with",
},
organizationId: {
projectId: {
propDefinition: [
pipedriveApp,
"organizationId",
"projectId",
],
description: "ID of the organization this activity will be associated with",
description: "ID of the project this activity will be associated with",
},
note: {
dueDate: {
type: "string",
label: "Note",
description: "Note of the activity (HTML format)",
label: "Due Date",
description: "Due date of the activity. Format: `YYYY-MM-DD`",
optional: true,
},
location: {
dueTime: {
type: "string",
label: "Location",
description: "The address of the activity. Pipedrive will automatically check if the location matches a geo-location on Google maps.",
label: "Due Time",
description: "Due time of the activity in UTC. Format: `HH:MM`",
optional: true,
},
publicDescription: {
duration: {
type: "string",
label: "Public Description",
description: "Additional details about the activity that will be synced to your external calendar. Unlike the note added to the activity, the description will be publicly visible to any guests added to the activity.",
label: "Duration",
description: "Duration of the activity. Format: `HH:MM`",
optional: true,
},
busyFlag: {
busy: {
type: "boolean",
label: "Busy Flag",
label: "Busy",
description: "Set the activity as 'Busy' or 'Free'. If the flag is set to true, your customers will not be able to book that time slot through any Scheduler links",
optional: true,
},
done: {
type: "boolean",
label: "Done",
description: "Whether the activity is done or not.",
optional: true,
},
location: {
type: "object",
label: "Location",
description: "The address of the activity. Pipedrive will automatically check if the location matches a geo-location on Google maps.",
optional: true,
},
participants: {
type: "string[]",
label: "Participants",
description: "List of multiple persons (participants) this activity will be associated with. If omitted, single participant from `person_id` field is used. It requires a structure as follows: `[{\"person_id\":1,\"primary\":true}]`",
optional: true,
propDefinition: [
pipedriveApp,
"personId",
],
},
attendees: {
type: "string[]",
label: "Attendees",
description: "Attendees of the activity. This can be either your existing Pipedrive contacts or an external email address. It requires a structure as follows: `[{\"email_address\":\"[email protected]\"}]` or `[{\"person_id\":1, \"email_address\":\"[email protected]\"}]`",
description: "Attendees of the activity. This can be either your existing Pipedrive contacts or an external email address. It requires a structure as follows: `[{\"email\":\"[email protected]\"}]`",
optional: true,
async options({ prevContext }) {
const {
moreItemsInCollection,
start,
} = prevContext;

if (moreItemsInCollection === false) {
if (prevContext?.cursor === false) {
return [];
}

const {
data: persons,
additional_data: additionalData,
} = await this.pipedriveApp.getPersons({
start,
cursor: prevContext.cursor,
limit: constants.DEFAULT_PAGE_LIMIT,
});

const options =
persons?.flatMap(({
name, email,
}) => email?.map(({ value }) => ({
return {
options: persons?.flatMap(({
name, emails,
}) => emails?.map(({ value }) => ({
label: name,
value,
})).filter((option) => option?.value));

return {
options,
})).filter((option) => option?.value)),
context: {
moreItemsInCollection: additionalData.pagination.more_items_in_collection,
start: additionalData.pagination.next_start,
cursor: additionalData.next_cursor,
},
};
},
},
publicDescription: {
type: "string",
label: "Public Description",
description: "Additional details about the activity that will be synced to your external calendar. Unlike the note added to the activity, the description will be publicly visible to any guests added to the activity.",
optional: true,
},
note: {
type: "string",
label: "Note",
description: "Note of the activity (HTML format)",
optional: true,
},
},
async run({ $ }) {
const {
subject,
type,
pipedriveApp,
dueDate,
dueTime,
duration,
userId,
ownerId,
dealId,
personId,
organizationId,
note,
leadId,
orgId,
projectId,
location,
participants,
attendees,
publicDescription,
busyFlag,
...data
} = this;

const participants = utils.parseOrUndefined(this.participants);
const attendees = utils.parseOrUndefined(this.attendees);
const done = utils.parseOrUndefined(this.done);

try {
const resp =
await this.pipedriveApp.addActivity({
subject,
done,
type,
await pipedriveApp.addActivity({
due_date: dueDate,
due_time: dueTime,
duration,
user_id: userId,
owner_id: ownerId,
deal_id: dealId,
person_id: personId,
participants: participants?.map((value, idx) => ({
lead_id: leadId,
participants: parseObject(participants)?.map((value, idx) => ({
person_id: value,
primary_flag: !idx,
primary: !idx,
})),
org_id: organizationId,
note,
location,
org_id: orgId,
project_id: projectId,
location: parseObject(location),
public_description: publicDescription,
busy_flag: busyFlag,
attendees: attendees?.map((value) => ({
email_address: value,
attendees: parseObject(attendees)?.map((value) => ({
email: value,
})),
...data,
});

$.export("$summary", "Successfully added activity");

return resp;
} catch (error) {
console.error(error.context?.body || error);
throw error.context?.body?.error || "Failed to add activity";
} catch ({ error }) {
throw new ConfigurationError(error);
}
},
};
Loading
Loading