0.3.1 • Published 8 years ago

ideamart.js v0.3.1

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

ideamart.js

A simple node.js wrapper for the IdeaMart IDEA-PRO APIs

alt text

Installation

Download node at nodejs.org and install it, if you haven't already.

npm install ideamart.js --save

Usage

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'
});

APIs

SMS

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);

Location

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);
});

Subscription

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);

TODO

  • 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

Tests

No unit tests yet.

Dependencies

  • debug: small debugging utility
  • unirest: Simplified, lightweight HTTP client library

Dev Dependencies

None

Contributing

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.

License

ISC

0.3.1

8 years ago

0.3.0

8 years ago

0.1.0

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago