npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@evokegroup/activecampaign-v1

v1.1.4

Published

Helper for ActiveCampaign API v1

Downloads

3

Readme

@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]": "[email protected]",
  "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: '[email protected]',
//     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 }
});