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

Activecampaign (patch) #341

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions src/appmixer/activecampaign/ActiveCampaign.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const axios = require('axios');
class ActiveCampaign {

constructor(url, apiKey) {

this.url = `${url}/api/3`;
const removedTrailingSlash = url.replace(/\/$/, '');
this.url = `${removedTrailingSlash}/api/3`;
this.apiKey = apiKey;
}

Expand Down
2 changes: 1 addition & 1 deletion src/appmixer/activecampaign/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
url: {
type: 'text',
name: 'URL',
tooltip: 'Your ActiveCampaign URL. You can find it in your account inside Settings > Developer'
tooltip: 'Your ActiveCampaign URL. You can find it in your account inside Settings > Developer. Example: https://dummyurl12345.api-us1.com'
},
apiKey: {
type: 'text',
Expand Down
5 changes: 4 additions & 1 deletion src/appmixer/activecampaign/bundle.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "appmixer.activecampaign",
"version": "1.0.3",
"version": "1.0.4",
"changelog": {
"1.0.0": [
"Initial version"
Expand All @@ -10,6 +10,9 @@
"CreateTask: Contact/Deal is now required.",
"UpdateDeal: should no longer require value (Deal amount) to run.",
"Small fixes to UpdateContact."
],
"1.0.4": [
"CreateDeal, CreateContact, CreateTask: output now returns all possible properties."
]
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
const moment = require('moment');
const { trimUndefined } = require('../../helpers');
const ActiveCampaign = require('../../ActiveCampaign');

Expand Down Expand Up @@ -46,14 +45,15 @@ module.exports = {
return acc;
}, {});

return context.sendJson({
id: contact.id,
email: contact.email,
firstName: contact.firstName,
lastName: contact.lastName,
phone: contact.phone,
createdDate: moment(contact.cdate).toISOString(),
const contactResponseModified = {
...contact,
createdDate: new Date(contact.cdate).toISOString(),
...customFieldsPayload
}, 'contact');
};

delete contactResponseModified.cdate;
delete contactResponseModified.links;

return context.sendJson(contactResponseModified, 'contact');
}
};
22 changes: 10 additions & 12 deletions src/appmixer/activecampaign/deals/CreateDeal/CreateDeal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
const moment = require('moment');
const ActiveCampaign = require('../../ActiveCampaign');
const { trimUndefined } = require('../../helpers');

Expand Down Expand Up @@ -47,25 +46,24 @@ module.exports = {
}

const { data } = await ac.call('post', 'deals', payload);

const { deal } = data;

const customFieldsPayload = fieldValues.reduce((acc, field) => {
acc[`customField_${field.customFieldId}`] = field.fieldValue;
return acc;
}, {});

return context.sendJson({
id: deal.id,
contactId: deal.contact,
title: deal.title,
description: deal.description,
currency: deal.currency,
const dealResponseModified = {
...deal,
value: deal.value / 100,
owner: deal.owner,
stage: deal.stage,
status: deal.status,
createdDate: moment(data.deal.cdate).toISOString(),
createdDate: new Date(deal.cdate).toISOString(),
...customFieldsPayload
}, 'deal');
};

delete dealResponseModified.cdate;
delete dealResponseModified.links;

return context.sendJson(dealResponseModified, 'deal');
}
};
20 changes: 10 additions & 10 deletions src/appmixer/activecampaign/tasks/CreateTask/CreateTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ module.exports = {

const { dealTask } = data;

return context.sendJson({
id: dealTask.id,
relationship: dealTask.owner.type,
const taskResponseModified = {
...dealTask,
contactId: dealTask.owner.type === 'contact' ? dealTask.relid : undefined,
dealId: dealTask.owner.type === 'deal' ? dealTask.relid : undefined,
title: dealTask.title,
note: dealTask.note,
taskType: dealTask.dealTasktype,
assignee: dealTask.assignee,
due: moment(dealTask.duedate).toISOString(),
edate: moment(dealTask.edate).toISOString()
}, 'newTask');
due: new Date(dealTask.duedate).toISOString(),
edate: new Date(dealTask.edate).toISOString()
};

delete taskResponseModified.duedate;
delete taskResponseModified.links;

return context.sendJson(taskResponseModified, 'newTask');
}
};
Loading