0.1.3 • Published 6 years ago

ideamart-sms-sdk v0.1.3

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

ideamart-sms-sdk

A lightweight Node.js wrapper for IdeaMart IdeaPro SMS API.

alt text

Installation

In your command-line on Windows:

    c:\> npm i ideamart-sms-sdk --save

In your terminal on Mac OS X/Linux:

    $npm i ideamart-sms-sdk --save

How to use

In Node.js:

// Load full IdeaMart SMS SDK build
const IdeaMart = require('ideamart-sms-sdk');

// Load SMSReceiver and SMSSender Modules separately
const SMSReceiver = IdeaMart.SMSReceiver;
const SMSSender = IdeaMart.SMSSender;

// Define the mandatory data that are needed for the API to function
const SERVER_URL = 'http://localhost:7000/sms/send';
const APP_ID = 'APP_000001';
const APP_PASSWORD = 'password';

// Create new sender instance to send a SMS.
const sender = new SMSSender.SMS(SERVER_URL, APP_ID, APP_PASSWORD);

// Sample route to test if the request response is working correctly.
app.post('/send', (req, res) => {
  // Extract the request data from request body using SMSReceiver module.
  const receiver = new SMSReceiver.SMS(req.body); 
  
  //Extract address and message from request body.
  const address = receiver.getAddress();
  const message = receiver.getMessage();

  // Send the SMS to the sender
  sender.sendSMS(message, address);
  // Return status for testing purposes when testing using Postman
  res.status(200).send(req.body);
});

Dependencies

  • axios: Promise based HTTP client for the browser and node.js

License

ISC

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago