1.1.4 • Published 5 years ago

@evokegroup/activecampaign-v1 v1.1.4

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
5 years ago

@evokegroup/activecampaign-v1

Helper for ActiveCampaign API v1

Class: ActiveCampaign

Static Properties

ActiveCampaign.Properties

Maps aliases (id, email, firstName, lastName, etc.) to standard ActiveCampaign field names (id, email, first_name, last_name, etc.).

ActiveCampaign.PropertyAliases

Maps standard ActiveCampaign field names (id, email, first_name, last_name, etc.) to aliases (id, email, firstName, lastName, etc.).

ActiveCampaign.ListMap

Maps ActiveCampaign list field names to aliases.

ActiveCampaign.ListStatus

Maps ActiveCampaign list statuses to aliases.

ActiveCampaign.WebhookType

Webhook notification types.

Static Methods

ActiveCampaign.parseListStatus(status)

Parses a list status

ParameterTypeDefaultDescription
statusboolean, number, stringThe status to be parsed

Class: ActiveCampaign.Api

constructor(object)

ParameterTypeDefaultDescription
accountstringThe account
apiKeystringThe API key
fieldMapActiveCampaign.FieldMap, objectThe field mapping

Methods

editContact(contact, overwrite)

ParameterTypeDefaultDescription
contactActiveCampaign.ContactThe contact
overwritebooleanfalseIf true, overwrites the entire contact rather than just the fields provided

getContact(object)

Gets a contact by ID, email, or hash.

ParameterTypeDefaultDescription
idstringThe ID of the contact to locate
emailstringThe email of the contact to locate
hashstringThe hash of the contact to locate
fieldMapActiveCampaign.FieldMap, objectThe field mapping

syncContact(contact)

ParameterTypeDefaultDescription
contactActiveCampaign.ContactThe contact

Class: ActiveCampaign.Contact

constructor(object)

ParameterTypeDefaultDescription
dataobjectThe contact data
fieldMapActiveCampaign.FieldMap, objectThe field mapping

Methods

setListStatus(list, status)

ParameterTypeDefaultDescription
liststringThe list ID
statusstringThe list status

serialize()

Serializes the contact.

serializeApi()

Serializes the contact in a format suitable for sending via an API call.

Class: ActiveCampaign.ContactRecord

constructor(object)

ParameterTypeDefaultDescription
typestringThe webhook event type (see ActiveCampaign.WebhookType)
datestringThe date
liststringThe list
contactActiveCampaign.ContactThe contact

Properties

PropertyTypeDefaultDescription
typestringThe webhook event type (see ActiveCampaign.WebhookType)
datestringThe date
liststringThe list
contactActiveCampaign.ContactThe contact

Methods

serialize()

Serializes the record.

Static Methods

createWebhook(object) ⇒ ActiveCampaign.ContactRecord

ParameterTypeDefaultDescription
dataobjectThe data received from the webhook
fieldMapActiveCampaign.FieldMap, objectThe field mapping

Usage

const ActiveCampaign = require('@evokegroup/activecampaign-v1');

// The data received from the webhook
const webhookData = {
  "type": "subscribe",
  "date_time": "2020-07-27T20:58:50-05:00",
  "initiated_from": "api",
  "initiated_by": "api",
  "list": "1",
  "contact[id]": "1",
  "contact[email]": "charles.amodeo@evokegroup.com",
  "contact[first_name]": "CJ",
  "contact[last_name]": "Amodeo",
  "contact[phone]": "123-555-8971",
  "contact[ip]": "127.0.0.1",
  "contact[tags]": "tag1, tag2, tag3",
  "contact[fields][20]": "Something goes here",
  "contact[fields][21]": "Important stuff",
  "contact[customer_acct_name]": "",
  "contact[orgname]": "",
  "customer_acct_name": "",
  "orgname": "",
  "active_subscriptions[0]": "1"
};

const fieldMapData = {
  something: { 'SOMETHING': 20 },
  important: { 'IMPORTANT': 21 }
};

const contactRecord = ActiveCampaign.ContactRecord.createWebhook({
  data: webhookData,
  fieldMap: fieldMapData
});

// Expected result:
// {
//   type: 'subscribe',
//   date: '2020-07-27T20:58:50-05:00',
//   list: '1',
//   contact: {
//     id: '1',
//     email: 'charles.amodeo@evokegroup.com',
//     firstName: 'CJ',
//     lastName: 'Amodeo',
//     phone: '123-555-8971',
//     ip: '127.0.0.1',
//     something: 'Something goes here',
//     important: 'Important stuff',
//     tags: ['tag1', 'tag2', 'tag3']
//   }
// }

Class: ActiveCampaign.Field

constructor(object)

ParameterTypeDefaultDescription
aliasstringThe alias. This is what the field will be called in ActiveCampaign.Contact
idstringThe ActiveCampaign field ID
perstagstringThe ActiveCampaign personalization tag.

Class: ActiveCampaign.FieldMap

constructor(fields)

ParameterTypeDefaultDescription
fieldsArray<ActiveCampaign.Field>An array of ActiveCampaign.Field representing the mapping

Static Methods

create(fieldMapData)

Creates an instance of ActiveCampaign.FieldMap

ParameterTypeDefaultDescription
fieldMapDataobjectThe mapping data

Usage

const ActiveCampaign = require('@evokegroup/activecampaign-v1');

const fieldMap = ActiveCampaign.FieldMap.create({
  address1: 'ADDRESS_1',
  address2: 'ADDRESS_2',
  city: 'CITY',
  state: 'STATE',
  zip: 'ZIP'
});

const fieldMapWithIDs = ActiveCampaign.FieldMap.create({
  address1: { 'ADDRESS_1': 1 },
  address2: { 'ADDRESS_2': 2 },
  city: { 'CITY': 3 },
  state: { 'STATE': 4 },
  zip: { 'ZIP': 5 }
});
1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago