A simple node.js wrapper for the IdeaMart IDEA-PRO APIs
Download node at nodejs.org and install it, if you haven't already.
npm install ideamart.js --save
var IdeaMart = require('ideamart.js');
// Replace SMS with relevant function
var SMS = new IdeaMart.SMS({
applicationID: 'APP_000001',
password: 'password',
url: 'http://localhost:7000/sms/send'
});
var IdeaMart = require('ideamart.js');
// Replace SMS with relevant function
var SMS = new IdeaMart.SMS({
applicationID: 'APP_000001',
password: 'password',
url: 'http://localhost:7000/sms/send',
webhook: '/mo-receiver' // Optional, defaults to '/mo-receiver'
});
SMS.sendTextMessage({
destination: "tel:94777484484",
message: 'Ladidadida.',
deliveryStatus: false // Optional, defaults to false
}, function(error, status) {
console.log(status);
});
// Is emitted when a text message is sent to the web application
SMS.on('message', function(message){
console.log(message);
});
// Create an http server and run a webhook to recieve messages
http.createServer(function(request, response){
SMS.messageHandler(request, response, function(error){
response.statusCode = 404;
response.end('Nope. You\'ve visited the wrong page, buddy.');
});
}).listen(5556);
var IdeaMart = require('ideamart.js');
var Location = new IdeaMart.Location({
applicationID: 'APP_000001',
password: 'password',
url: 'http://localhost:7000/lbs/locate'
});
Location.getLocation({
destination: "tel:94777484484"
}, function(error, status) {
console.log(status);
});
var Subscription = new IdeaMart.Subscription({
applicationID: 'APP_000001',
password: 'password',
url: 'http://localhost:7000/subscription/',
webhook: '/subscribe'
});
Subscription.subscribe({
subscriber: 'tel:94777484484',
subscriberStatus: true
}, function(error, status) {
console.log(status);
});
Subscription.getSubscriberStatus( 'tel:94777484484', function(error, status){
console.log(status);
});
// Is emitted when a text message is sent to the web application
Subscription.on('subscriber', function(message){
console.log(message);
});
// Create an http server and run a webhook to recieve messages
http.createServer(function(request, response){
Subscription.subscriptionHandler(request, response, function(error){
response.statusCode = 404;
response.end('Nope. You\'ve visited the wrong page, buddy.');
});
}).listen(5556);
- Implement proper error handling, based on the responses of the API.
- Implement SMS API
- Implement LBS API
- Implement USSD API
- Implement CaaS API
- Implement Subscription API
- Implement IVR API
No unit tests yet.
None
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
ISC