Last active
December 9, 2015 17:30
Sample usage scripts for the Esendex Node.js SDK https://github.com/esendex/esendex-node-sdk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See: https://github.com/esendex/esendex-node-sdk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var esendex = require('esendex')({ | |
username: 'you@yourdomain.com', | |
password: 'secure password' | |
}); | |
esendex.accounts.get({ id: 'c4fb5929-0dcd-49a7-9562-b90a48caaa95' }, function (err, account) { | |
if (err) return console.log(err); | |
console.log(account); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var esendex = require('esendex')({ | |
username: 'you@yourdomain.com', | |
password: 'secure password' | |
}); | |
esendex.accounts.get(null, function (err, accounts) { | |
if (err) return console.log(err); | |
accounts.account.forEach(function (account) { | |
console.log(account); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var format = require('util').format, | |
esendex = require('esendex')({ | |
username: 'you@yourdomain.com', | |
password: 'secure password' | |
}); | |
esendex.batches.get({ count: 2 }, function (err, batches) { | |
if (err) return console.log(err); | |
batches.messagebatch.forEach(function (batch, index) { | |
console.log(batch); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var format = require('util').format, | |
esendex = require('esendex')({ | |
username: 'you@yourdomain.com', | |
password: 'secure password' | |
}); | |
esendex.batches.get({ count: 2, filterBy: 'account', filterValue: 'EX0000000' }, function (err, batches) { | |
if (err) return console.log(err); | |
batches.messagebatch.forEach(function (batch, index) { | |
console.log(batch); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var esendex = require('esendex')({ | |
username: 'you@yourdomain.com', | |
password: 'secure password' | |
}); | |
esendex.inbox.get({ count: 3 }, function (err, messages) { | |
if (err) return console.log(err); | |
messages.messageheader.forEach(function (msg) { | |
console.log(msg); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var esendex = require('esendex')({ | |
username: 'you@yourdomain.com', | |
password: 'secure password' | |
}); | |
esendex.inbox.get({ count: 3, accountreference: 'EX0000000' }, function (err, messages) { | |
if (err) return console.log(err); | |
messages.messageheader.forEach(function (msg) { | |
console.log(msg); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var esendex = require('esendex')({ | |
username: 'you@yourdomain.com', | |
password: 'secure password' | |
}); | |
esendex.messages.get({ count: 3 }, function (err, messages) { | |
if (err) return console.log(err); | |
messages.messageheader.forEach(function (msg) { | |
esendex.messages.getBody(msg.id, function (err, body) { | |
if (err) return console.log(err); | |
msg.body = body; | |
console.log(msg); | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var esendex = require('esendex')({ | |
username: 'you@yourdomain.com', | |
password: 'secure password' | |
}); | |
esendex.inbox.update({ id: '8a6cae14-9bce-4195-830b-bd55e1c1ffef', read: true }, function (err) { | |
if (err) return console.log(err); | |
console.log('Marked message as read!'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var esendex = require('esendex')({ | |
username: 'you@yourdomain.com', | |
password: 'secure password' | |
}); | |
esendex.inbox.update({ id: '8a6cae14-9bce-4195-830b-bd55e1c1ffef', read: false }, function (err) { | |
if (err) return console.log(err); | |
console.log('Marked message as unread!'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var esendex = require('esendex')({ | |
username: 'you@yourdomain.com', | |
password: 'secure password' | |
}); | |
var messages = { | |
accountreference: 'EX0000000', | |
sendat: new Date(2015, 10, 25, 18, 13).toISOString(), // 2015-11-25T18:13:00.000Z | |
message: [{ | |
to: '07987654321', | |
body: 'Every message matters!' | |
},{ | |
to: '07123456789', | |
body: 'Really, every message matters!' | |
}] | |
}; | |
esendex.messages.send(messages, function (err, response) { | |
if (err) return console.log('error: ', err); | |
console.log(response); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var esendex = require('esendex')({ | |
username: 'you@yourdomain.com', | |
password: 'secure password' | |
}); | |
var messages = { | |
accountreference: 'EX0000000', | |
message: [{ | |
to: '07987654321', | |
body: 'Every message matters!' | |
},{ | |
to: '07123456789', | |
body: 'Really, every message matters!' | |
}] | |
}; | |
esendex.messages.send(messages, function (err, response) { | |
if (err) return console.log('error: ', err); | |
console.log(response); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var esendex = require('esendex')({ | |
username: 'you@yourdomain.com', | |
password: 'secure password' | |
}); | |
var messages = { | |
accountreference: 'EX0000000', | |
type: 'Voice', | |
lang: 'en-GB', | |
message: [{ | |
to: '07987654321', | |
body: 'Every message matters!', | |
lang: 'es-ES' | |
},{ | |
to: '07123456789', | |
body: 'Really, every message matters!', | |
type: 'Voice' | |
}] | |
}; | |
esendex.messages.send(messages, function (err, response) { | |
if (err) return console.log('error: ', err); | |
console.log(response); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment