@vulture916/activepieces-piece-lemlist
Version:
Lemlist integration for ActivePieces - Email outreach and sales engagement platform
88 lines (84 loc) • 2.75 kB
JavaScript
const { createAction, Property } = require('@activepieces/pieces-framework');
const { HttpMethod } = require('@activepieces/pieces-common');
const { lemlistAuth } = require('../../common/auth');
const { lemlistClient } = require('../../common/client');
exports.updateCampaign = createAction({
auth: lemlistAuth,
name: 'update_campaign',
displayName: 'Update Campaign',
description: 'Update settings of a campaign',
props: {
campaignId: Property.ShortText({
displayName: 'Campaign ID',
description: 'The ID of the campaign to update',
required: true,
}),
name: Property.ShortText({
displayName: 'Campaign Name',
description: 'New name for the campaign',
required: false,
}),
senderId: Property.ShortText({
displayName: 'Sender ID',
description: 'New sender ID for this campaign',
required: false,
}),
scheduleId: Property.ShortText({
displayName: 'Schedule ID',
description: 'New schedule ID for this campaign',
required: false,
}),
trackOpen: Property.Checkbox({
displayName: 'Track Opens',
description: 'Track when emails are opened',
required: false,
}),
trackClick: Property.Checkbox({
displayName: 'Track Clicks',
description: 'Track when links are clicked',
required: false,
}),
trackBounce: Property.Checkbox({
displayName: 'Track Bounces',
description: 'Track email bounces',
required: false,
}),
domainDeductEmail: Property.Checkbox({
displayName: 'Deduce Email from Domain',
description: 'Automatically deduce email addresses from domains',
required: false,
}),
},
async run(context) {
const body = {};
// Only add fields that are provided
if (context.propsValue.name) {
body.name = context.propsValue.name;
}
if (context.propsValue.senderId) {
body.senderId = context.propsValue.senderId;
}
if (context.propsValue.scheduleId) {
body.scheduleId = context.propsValue.scheduleId;
}
if (context.propsValue.trackOpen !== undefined) {
body.trackOpen = context.propsValue.trackOpen;
}
if (context.propsValue.trackClick !== undefined) {
body.trackClick = context.propsValue.trackClick;
}
if (context.propsValue.trackBounce !== undefined) {
body.trackBounce = context.propsValue.trackBounce;
}
if (context.propsValue.domainDeductEmail !== undefined) {
body.domainDeductEmail = context.propsValue.domainDeductEmail;
}
const campaign = await lemlistClient.makeRequest(
context.auth,
HttpMethod.PATCH,
`/campaigns/${context.propsValue.campaignId}`,
body
);
return campaign;
},
});