0.2.0 • Published 3 years ago

createsend-js v0.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

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: ['alex@alexzissis.tech'],
    CC: ['alex+cc@alexzissis.tech'],
    BCC: ['alex+bcc@alexzissis.tech'],
    ConsentToTrack: 'Yes',
    Data: {
        firstName: 'Alex',
    }
}).then(response => console.log(response)); //{ Status: 'Accepted', MessageId: 'a1a1a1', Recipient: 'alex@alexzissis.tech'}