node-emarsys

1.2.0 • Public • Published

Emarsys API Wrapper

Promise-based wrapper for the Emarsys API in NodeJS. Emarsys API Documentation.

Installation

$ npm i node-emarsys
const Emarsys = require('node-emarsys');
 
const api = new Emarsys('username', 'password');

Passing your username and password will generate the WSSE header for your requests automatically.

Usage

This library will JSON stringify your data object and include the necessary headers. It will also prepend the standard https://api.emarsys.net/api/v2 uri so you only need to include the specific endpoint.

Making a Request

  • Request Type [method] - get, post, put
  • uri [string] - emarsys endpoint path AFTER /api/v2
  • data [object] - data to send to endpoint
  • @returns [promise] - returns a promise, rejecting if a request fails
api[request type](uri, data)
.then(function(res){
    //successful response
})
.catch(function(err){
    // failed response
})

Example

api.get('/contact/query/', {
    return: '4',
    '33941': '',
    excludeempty: true
}))
.then(function(res){
    // success
    console.log(res.data.result);
})
.catch(function(err){
    // failure
    console.log(err);
})

Readme

Keywords

none

Package Sidebar

Install

npm i node-emarsys

Weekly Downloads

34

Version

1.2.0

License

ISC

Unpacked Size

3.51 kB

Total Files

3

Last publish

Collaborators

  • adampatarino