@evokegroup/activecampaign-v1

1.1.4 • Public • Published

@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

Parameter Type Default Description
status boolean, number, string The status to be parsed

Class: ActiveCampaign.Api

constructor(object)

Parameter Type Default Description
account string The account
apiKey string The API key
fieldMap ActiveCampaign.FieldMap, object The field mapping

Methods

editContact(contact, overwrite)

Parameter Type Default Description
contact ActiveCampaign.Contact The contact
overwrite boolean false If true, overwrites the entire contact rather than just the fields provided

getContact(object)

Gets a contact by ID, email, or hash.

Parameter Type Default Description
id string The ID of the contact to locate
email string The email of the contact to locate
hash string The hash of the contact to locate
fieldMap ActiveCampaign.FieldMap, object The field mapping

syncContact(contact)

Parameter Type Default Description
contact ActiveCampaign.Contact The contact

Class: ActiveCampaign.Contact

constructor(object)

Parameter Type Default Description
data object The contact data
fieldMap ActiveCampaign.FieldMap, object The field mapping

Methods

setListStatus(list, status)

Parameter Type Default Description
list string The list ID
status string The 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)

Parameter Type Default Description
type string The webhook event type (see ActiveCampaign.WebhookType)
date string The date
list string The list
contact ActiveCampaign.Contact The contact

Properties

Property Type Default Description
type string The webhook event type (see ActiveCampaign.WebhookType)
date string The date
list string The list
contact ActiveCampaign.Contact The contact

Methods

serialize()

Serializes the record.

Static Methods

createWebhook(object) ⇒ ActiveCampaign.ContactRecord

Parameter Type Default Description
data object The data received from the webhook
fieldMap ActiveCampaign.FieldMap, object The 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)

Parameter Type Default Description
alias string The alias. This is what the field will be called in ActiveCampaign.Contact
id string The ActiveCampaign field ID
perstag string The ActiveCampaign personalization tag.

Class: ActiveCampaign.FieldMap

constructor(fields)

Parameter Type Default Description
fields Array<ActiveCampaign.Field> An array of ActiveCampaign.Field representing the mapping

Static Methods

create(fieldMapData)

Creates an instance of ActiveCampaign.FieldMap

Parameter Type Default Description
fieldMapData object The 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 }
});

Readme

Keywords

none

Package Sidebar

Install

npm i @evokegroup/activecampaign-v1

Weekly Downloads

1

Version

1.1.4

License

ISC

Unpacked Size

25.8 kB

Total Files

3

Last publish

Collaborators

  • ybevoke
  • jtsuyuki
  • evokejames
  • evoke-cjamodeo