Giter Club home page Giter Club logo

createsend-node's Introduction

CreateSend API Wrapper

Build Status Dependency Status Coverage Status

Installation

npm install createsend-node

Authenticating

via API Key

var createsend = require('createsend-node');
var auth = { apiKey: 'your api key' };
var api = new createsend(auth);

via AccessToken (Oauth)

var createsend = require('createsend-node');
var auth = { accessToken: 'your access token' };
var api = new createsend(auth);

Basic classes

I've wrapped just about every request in some type of class to make life a lot easier when dealing with request from the Campaign Monitor API. Here are the classes that exist in createsend-node.

Client

{
    clientId: "This will be the Id from Campaign Monitor",
    name: "The name of the client",

    addPerson: function (details, callback) {
        /*
        "details" is simply the data that Campaign Monitor is looking for according to
        http://www.campaignmonitor.com/api/clients/#adding_a_person

        details: {
            "EmailAddress": "[email protected]",
            "Name": "Sally Sparrow",
            "AccessLevel": 23,
            "Password": "opensesame"
        }

        callback: function (err, person) {
            "person" is a single Person object
        }
        */
    },
    createList: function (details, callback) { },
    delete: function (callback) { },
    deletePerson: function (callback) { },
    getDetails: function (callback) { },
    getDraftCampaigns: function (callback) { },
    getLists: function (callback) { },
    getPeople: function (callback) { },
    getPersonDetails: function (emailAddress, callback) { },
    getPrimaryContact: function (callback) { },
    getListsForEmail: function (emailAddress, callback) { },
    getScheduledCampaigns: function (callback) { },
    getSegments: function (callback) { },
    getSentCampaigns: function (callback) { },
    getSuppressionList: function (filter, callback) { },
    getTemplates: function (callback) { },
    setDetails: function (details, callback) { },
    setMonthlyBilling: function (billingDetails, callback) { },
    setPaygBilling: function (billingDetails, callback) { },
    setPrimaryContact: function (emailAddress, callback) { },
    suppress: function (emailAddress, callback) { },
    transferCredits: function (details, callback) { },
    updatePerson: function (emailAddress, details, callback) { },
    unsuppress: function (emailAddress, callback) { }
}

Account based actions

Get the list of clients.

api.account.getClients(
  function (err, clientList) {

  }
);

Transaction based actions

Send a transactional email

var details = {
  smartEmailID: "string", // The ID of the transactional email
  to: "string",           // The email address to send it to
  data: data              // Any data fields required for the email
};

// Send the smart email(and provide a callback function that takes an error and a response parameter)
api.transactional.sendSmartEmail(details, (err, res) => {
  if (err)  console.log(err);
});

Subscribers based actions

Add a subscriber to a list

var listId = 'kajsbndkasjbkanf123j13nj21k3n2' // The ID of the list
var details = {
  EmailAddress: '[email protected]',
  Name: `John Smith`,
  CustomFields: [
    { Key: 'CustomKey', Value: 'Some Value' }
  ]
};

api.subscribers.addSubscriber(listId, details, (err, res) => {
  if (err) console.log(err);
});

Side Note: To get the ID of the list, in CM, go to Lists & Subscribers, choose the list you want and click on change name/type.

createsend-node's People

Contributors

nufyoot avatar logicalparadox avatar kellym avatar justindra avatar apmats avatar dallasread avatar homerjam avatar methodgrab avatar aschmid avatar apshoebkhan avatar

Watchers

Alex Wolfe avatar Chris Grayson avatar Tim Ray avatar James Cloos avatar  avatar Justin Winslow avatar Olajumoke Oladimeji avatar Jon Perkins avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.