createsend-js
v0.2.0
Published
A modern wrapper for the CreateSend API in Node.JS
Downloads
4
Readme
CreateSend JS
A modern wrapper for the CreateSend API in Node.JS.
NB: This is still in early alpha and not recommended for use
Installation
yarn add createsend-js
OR
npm i createsend-js
Usage
Initialisation
import {CreateSend} from 'createsend-js'; // or const {CreateSend} = require('createsend-js')
const cs = new CreateSend(<apiKey>);
Account
cs.account.getClients().then((clients) => console.log(clients)); // [ {Name: "Example", ClientID: 'a1a1a1a1a1a1a1' } ]
Clients
cs.clients.getSubscriberLists(<clientId>).then(); // [ {Name: "Example List", ListId: 'a1a1a1a1a1a1a1' } ]
Transactional
cs.transactional.getSmartEmailListing({clientId: <clientId>}).then(emails => console.log(emails)) // [{ ID: 'a1a1a1a1a1a1a1', Name: 'txemail', CreatedAt: '2020-02-05T02:02:02', Status: 'Active' }]
cs.transactional.sendSmartEmail(<smartEmailId>, {
To: ['[email protected]'],
CC: ['[email protected]'],
BCC: ['[email protected]'],
ConsentToTrack: 'Yes',
Data: {
firstName: 'Alex',
}
}).then(response => console.log(response)); //{ Status: 'Accepted', MessageId: 'a1a1a1', Recipient: '[email protected]'}