Skip to content

Commit f3ce0b8

Browse files
committed
new actions
1 parent fb7e822 commit f3ce0b8

File tree

7 files changed

+324
-13
lines changed

7 files changed

+324
-13
lines changed

components/zendesk_sell/actions/create-contact/create-contact.mjs

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,87 @@ export default {
55
name: "Create Contact",
66
description: "Creates a new contact. [See the documentation](https://developer.zendesk.com/api-reference/sales-crm/resources/contacts/#create-a-contact).",
77
type: "action",
8-
version: "0.0.{{ts}}",
8+
version: "0.0.1",
99
props: {
1010
zendeskSell,
11+
isOrganization: {
12+
propDefinition: [
13+
zendeskSell,
14+
"isOrganization",
15+
],
16+
reloadProps: true,
17+
},
18+
status: {
19+
propDefinition: [
20+
zendeskSell,
21+
"status",
22+
],
23+
},
24+
title: {
25+
propDefinition: [
26+
zendeskSell,
27+
"title",
28+
],
29+
},
30+
description: {
31+
propDefinition: [
32+
zendeskSell,
33+
"description",
34+
],
35+
},
36+
email: {
37+
propDefinition: [
38+
zendeskSell,
39+
"email",
40+
],
41+
},
42+
phone: {
43+
propDefinition: [
44+
zendeskSell,
45+
"phone",
46+
],
47+
},
1148
},
12-
async run() {
13-
49+
async additionalProps() {
50+
const props = {};
51+
if (this.isOrganization) {
52+
props.name = {
53+
type: "string",
54+
label: "Name",
55+
description: "Name of the contact",
56+
};
57+
} else {
58+
props.firstName = {
59+
type: "string",
60+
label: "First Name",
61+
description: "First name of the contact",
62+
};
63+
props.lastName = {
64+
type: "string",
65+
label: "Last Name",
66+
description: "Last name of the contact",
67+
};
68+
}
69+
return props;
70+
},
71+
async run({ $ }) {
72+
const response = await this.zendeskSell.createContact({
73+
$,
74+
data: {
75+
data: {
76+
is_organization: this.isOrganization,
77+
name: this.name,
78+
first_name: this.firstName,
79+
last_name: this.lastName,
80+
customer_status: this.status,
81+
title: this.title,
82+
description: this.description,
83+
email: this.email,
84+
phone: this.phone,
85+
},
86+
},
87+
});
88+
$.export("$summary", `Successfully created contact with ID ${response.data.id}`);
89+
return response;
1490
},
1591
};

components/zendesk_sell/actions/create-lead/create-lead.mjs

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,92 @@ export default {
55
name: "Create Lead",
66
description: "Creates a new lead. [See the documentation](https://developer.zendesk.com/api-reference/sales-crm/resources/leads/#create-a-lead).",
77
type: "action",
8-
version: "0.0.{{ts}}",
8+
version: "0.0.1",
99
props: {
1010
zendeskSell,
11+
isOrganization: {
12+
propDefinition: [
13+
zendeskSell,
14+
"isOrganization",
15+
],
16+
description: "Indicator of whether or not this lead refers to an organization or an individual",
17+
reloadProps: true,
18+
},
19+
status: {
20+
propDefinition: [
21+
zendeskSell,
22+
"status",
23+
],
24+
description: "The status of the lead",
25+
},
26+
title: {
27+
propDefinition: [
28+
zendeskSell,
29+
"title",
30+
],
31+
description: "The lead’s job title",
32+
},
33+
description: {
34+
propDefinition: [
35+
zendeskSell,
36+
"description",
37+
],
38+
description: "The lead’s description",
39+
},
40+
email: {
41+
propDefinition: [
42+
zendeskSell,
43+
"email",
44+
],
45+
description: "The lead’s email address",
46+
},
47+
phone: {
48+
propDefinition: [
49+
zendeskSell,
50+
"phone",
51+
],
52+
description: "The lead’s phone number",
53+
},
1154
},
12-
async run() {
13-
55+
async additionalProps() {
56+
const props = {};
57+
if (this.isOrganization) {
58+
props.name = {
59+
type: "string",
60+
label: "Name",
61+
description: "Name of the lead",
62+
};
63+
} else {
64+
props.firstName = {
65+
type: "string",
66+
label: "First Name",
67+
description: "First name of the lead",
68+
};
69+
props.lastName = {
70+
type: "string",
71+
label: "Last Name",
72+
description: "Last name of the lead",
73+
};
74+
}
75+
return props;
76+
},
77+
async run({ $ }) {
78+
const response = await this.zendeskSell.createLead({
79+
$,
80+
data: {
81+
data: {
82+
first_name: this.firstName,
83+
last_name: this.lastName,
84+
organization_name: this.name,
85+
status: this.status,
86+
title: this.title,
87+
description: this.description,
88+
email: this.email,
89+
phone: this.phone,
90+
},
91+
},
92+
});
93+
$.export("$summary", `Successfully created lead with ID ${response.data.id}`);
94+
return response;
1495
},
1596
};

components/zendesk_sell/actions/create-task/create-task.mjs

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,82 @@ export default {
55
name: "Create Task",
66
description: "Creates a new task. [See the documentation](https://developer.zendesk.com/api-reference/sales-crm/resources/tasks/#create-a-task).",
77
type: "action",
8-
version: "0.0.{{ts}}",
8+
version: "0.0.1",
99
props: {
1010
zendeskSell,
11+
resourceType: {
12+
type: "string",
13+
label: "Resource Type",
14+
description: "Name of the resource type the task is attached to",
15+
options: [
16+
"contact",
17+
"lead",
18+
"deal",
19+
],
20+
reloadProps: true,
21+
},
22+
contactId: {
23+
propDefinition: [
24+
zendeskSell,
25+
"contactId",
26+
],
27+
hidden: true,
28+
},
29+
leadId: {
30+
propDefinition: [
31+
zendeskSell,
32+
"leadId",
33+
],
34+
hidden: true,
35+
},
36+
dealId: {
37+
propDefinition: [
38+
zendeskSell,
39+
"dealId",
40+
],
41+
hidden: true,
42+
},
43+
content: {
44+
type: "string",
45+
label: "Content",
46+
description: "Content of the task",
47+
},
48+
completed: {
49+
type: "boolean",
50+
label: "Completed",
51+
description: "Indicator of whether the task is completed or not",
52+
optional: true,
53+
},
54+
dueDate: {
55+
type: "string",
56+
label: "Due Date",
57+
description: "Date and time the task is due in UTC (ISO8601 format)",
58+
optional: true,
59+
},
1160
},
12-
async run() {
13-
61+
async additionalProps(props) {
62+
props.contactId.hidden = this.resourceType !== "contact";
63+
props.leadId.hidden = this.resourceType !== "lead";
64+
props.dealId.hidden = this.resourceType !== "deal";
65+
return {};
66+
},
67+
async run({ $ }) {
68+
const response = await this.zendeskSell.createTask({
69+
$,
70+
data: {
71+
data: {
72+
resource_type: this.resourceType,
73+
resource_id: this.resourceType === "contact"
74+
? this.contactId
75+
: this.resourceType === "lead"
76+
? this.leadId
77+
: this.dealId,
78+
content: this.content,
79+
completed: this.completed,
80+
due_date: this.dueDate,
81+
},
82+
},
83+
});
84+
return response;
1485
},
1586
};

components/zendesk_sell/sources/new-contact-created/new-contact-created.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
name: "New Contact Created",
77
description: "Emit new event when a new contact is created in Zendesk Sell.",
88
type: "source",
9-
version: "0.0.{{ts}}",
9+
version: "0.0.1",
1010
dedupe: "unique",
1111
methods: {
1212
...common.methods,

components/zendesk_sell/sources/new-deal-created/new-deal-created.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
name: "New Deal Created",
77
description: "Emit new event when a new deal is created in Zendesk Sell.",
88
type: "source",
9-
version: "0.0.{{ts}}",
9+
version: "0.0.1",
1010
dedupe: "unique",
1111
methods: {
1212
...common.methods,

components/zendesk_sell/sources/new-lead-created/new-lead-created.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
name: "New Lead Created",
77
description: "Emit new event when a new lead is created in Zendesk Sell.",
88
type: "source",
9-
version: "0.0.{{ts}}",
9+
version: "0.0.1",
1010
dedupe: "unique",
1111
methods: {
1212
...common.methods,

components/zendesk_sell/zendesk_sell.app.mjs

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,90 @@ import { axios } from "@pipedream/platform";
33
export default {
44
type: "app",
55
app: "zendesk_sell",
6-
propDefinitions: {},
6+
propDefinitions: {
7+
contactId: {
8+
type: "string",
9+
label: "Contact ID",
10+
description: "Identifier of a contact",
11+
async options({ page }) {
12+
const { items } = await this.listContacts({
13+
page: page + 1,
14+
});
15+
return items?.map(({ data }) => ({
16+
value: data.id,
17+
label: data.name || (`${data.first_name} ${data.last_name}`).trim(),
18+
})) || [];
19+
},
20+
},
21+
leadId: {
22+
type: "string",
23+
label: "Lead ID",
24+
description: "Identifier of a lead",
25+
async options({ page }) {
26+
const { items } = await this.listLeads({
27+
page: page + 1,
28+
});
29+
return items?.map(({ data }) => ({
30+
value: data.id,
31+
label: data.organization_name || (`${data.first_name} ${data.last_name}`).trim(),
32+
})) || [];
33+
},
34+
},
35+
dealId: {
36+
type: "string",
37+
label: "Deal ID",
38+
description: "Identifier of a deal",
39+
async options({ page }) {
40+
const { items } = await this.listDeals({
41+
page: page + 1,
42+
});
43+
return items?.map(({ data }) => ({
44+
value: data.id,
45+
label: data.name,
46+
})) || [];
47+
},
48+
},
49+
isOrganization: {
50+
type: "boolean",
51+
label: "Is Organization",
52+
description: "Indicator of whether or not this contact refers to an organization or an individual",
53+
},
54+
status: {
55+
type: "string",
56+
label: "Status",
57+
description: "The customer status of the contact",
58+
options: [
59+
"none",
60+
"current",
61+
"past",
62+
],
63+
optional: true,
64+
},
65+
title: {
66+
type: "string",
67+
label: "Title",
68+
description: "The contact’s job title",
69+
optional: true,
70+
},
71+
description: {
72+
type: "string",
73+
label: "Description",
74+
description: "The contact’s description",
75+
optional: true,
76+
},
77+
email: {
78+
type: "string",
79+
label: "Email",
80+
description: "The contact’s email address",
81+
optional: true,
82+
},
83+
phone: {
84+
type: "string",
85+
label: "Phone",
86+
description: "The contact’s phone number",
87+
optional: true,
88+
},
89+
},
790
methods: {
891
_baseUrl() {
992
return "https://api.getbase.com/v2";

0 commit comments

Comments
 (0)