@evokegroup/pulse
v3.2.1
Published
API for Pulse 3.0
Downloads
41
Keywords
Readme
@evokegroup/pulse
Helper library for interacting with the Pulse v3 API.
Requires NodeJS >18
Logging
Enable logging by configuring the API with a class/object that implements ILogger
.
import { configure } from '@evokegroup/pulse';
// create a basic logger
/** @type {import('@evokegroup/pulse/dist-types').ILogger} **/
const BasicLogger = {
info: (...msg) => {
msg.forEach((m) => {
console.log(m);
});
},
debug: (...msg) => {
BasicLogger.info.apply(null, msg);
},
warn: (...msg) => {
BasicLogger.info.apply(null, msg);
},
error: (...msg) => {
BasicLogger.info.apply(null, msg);
}
};
configure({ logger: BasicLogger });
Example
Register a contact.
import { upsertContact } from '@evokegroup/pulse'
upsertContact({
credentials: {
host: 'PULSE_HOST',
account: 'PULSE_ACCOUNT',
token: 'PULSE_API_TOKEN'
},
contact: {
isTest: true,
firstName: 'John',
lastName: 'Doe',
customFields: {
language: 'javascript'
},
emails: [{
emailAddress: '[email protected]'
}],
locations: [{
address1: '123 Main St',
address2: '',
city: 'Anytown',
state: 'NY',
postalCode: '12345'
}],
phones: [{
phone: '212-555-8923'
}]
}
})
.then((result) => {
/* {
status: 'CREATED or UPDATED',
contact: {...}
} */
})
.catch((err) => {
// Could be PulseApiError if any error was returned by the API
});