Skip to content

Commit 1725dec

Browse files
committed
Adjustments
1 parent e680eef commit 1725dec

File tree

2 files changed

+39
-32
lines changed

2 files changed

+39
-32
lines changed

components/the_magic_drip/actions/add_lead_to_campaign/add_lead_to_campaign.mjs

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import app from "../../the_magic_drip.app.mjs";
33
export default {
44
key: "the_magic_drip-add-lead-to-campaign",
55
name: "Add Lead to Campaign",
6-
description: "Adds a single lead to a campaign. [See the documentation]()",
6+
description: "Add a lead to a campaign. [See the documentation](https://docs.themagicdrip.com/api-reference/endpoint/post-v1campaignleads)",
77
version: "0.0.{{ts}}",
88
type: "action",
99
props: {
@@ -14,30 +14,52 @@ export default {
1414
"campaignId",
1515
],
1616
},
17+
firstName: {
18+
type: "string",
19+
label: "First Name",
20+
description: "First name of the lead",
21+
optional: true,
22+
},
23+
lastName: {
24+
type: "string",
25+
label: "Last Name",
26+
description: "Last name of the lead",
27+
},
28+
linkedInPublicUrl: {
29+
type: "string",
30+
label: "LinkedIn Public URL",
31+
description: "LinkedIn public URL of the lead",
32+
optional: true,
33+
},
1734
company: {
18-
propDefinition: [
19-
app,
20-
"company",
21-
],
35+
type: "string",
36+
label: "Company",
37+
description: "Company of the lead",
2238
optional: true,
2339
},
24-
linkedinUrl: {
25-
propDefinition: [
26-
app,
27-
"linkedinUrl",
28-
],
40+
companyLinkedInUrl: {
41+
type: "string",
42+
label: "Company LinkedIn URL",
43+
description: "LinkedIn URL of the company",
2944
optional: true,
3045
},
3146
},
3247
async run({ $ }) {
33-
const response = await this.app.addLeadToCampaign({
34-
campaignId: this.campaignId,
35-
company: this.company,
36-
linkedinUrl: this.linkedinUrl,
48+
const {
49+
app, campaignId, ...lead
50+
} = this;
51+
const response = await app.addLeadToCampaign({
52+
$,
53+
campaignId,
54+
data: {
55+
leadsWithCustomVariables: [
56+
lead,
57+
],
58+
},
3759
});
3860
$.export(
3961
"$summary",
40-
`Added ${response.totalLeadsAddedToWorkflow} lead(s) to campaign ${this.campaignId}`,
62+
`Successfully added lead "${lead.lastName}" to campaign ${campaignId}`,
4163
);
4264
return response;
4365
},

components/the_magic_drip/the_magic_drip.app.mjs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ export default {
1616
}));
1717
},
1818
},
19-
company: {
20-
type: "string",
21-
label: "Company",
22-
description: "The company of the lead",
23-
optional: true,
24-
},
2519
linkedinUrl: {
2620
type: "string",
2721
label: "LinkedIn URL",
@@ -57,20 +51,11 @@ export default {
5751
});
5852
},
5953
async addLeadToCampaign({
60-
campaignId, company, linkedinUrl,
61-
}, opts = {}) {
62-
const leadData = {};
63-
if (company) leadData.company = company;
64-
if (linkedinUrl) leadData.linkedinUrl = linkedinUrl;
65-
54+
campaignId, ...opts
55+
}) {
6656
return this._makeRequest({
6757
method: "POST",
6858
path: `/campaign/leads/${campaignId}`,
69-
data: {
70-
leadsWithCustomVariables: [
71-
leadData,
72-
],
73-
},
7459
...opts,
7560
});
7661
},

0 commit comments

Comments
 (0)