Skip to content
The Releans NodeJS SDK allow you to get up an running with Releans API quickly in your project. # What you can do with Releans Services? 1- Send emails 2- On-time SMS 3- Automation for reminders and appointments
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
LICENSE
README.md
package.json

README.md

Getting started

The Releans SDK enables developers to use Releans Services in their code. You can get started in minutes.

How to Build

The generated SDK relies on Node Package Manager (NPM) being available to resolve dependencies. If you don't already have NPM installed, please go ahead and follow instructions to install NPM from here. The SDK also requires Node to be installed. If Node isn't already installed, please install it from here

NPM is installed by default when Node is installed

To check if node and npm have been successfully installed, write the following commands in command prompt:

  • node --version
  • npm -version

Version Check

Now use npm to resolve all dependencies by running the following command in the root directory (of the SDK folder):

npm install

Resolve Dependencies

Resolve Dependencies

This will install all dependencies in the node_modules folder.

Once dependencies are resolved, you will need to move the folder ReleansAPILib in to your node_modules folder.

How to Use

The following section explains how to use the library in a new project.

1. Open Project Folder

Open an IDE/Text Editor for JavaScript like Sublime Text. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.

Click on File and select Open Folder.

Open Folder

Select the folder of your SDK and click on Select Folder to open it up in Sublime Text. The folder will become visible in the bar on the left.

Open Project

2. Creating a Test File

Now right click on the folder name and select the New File option to create a new test file. Save it as index.js Now import the generated NodeJS library using the following lines of code:

var lib = require('lib');

Save changes.

Create new file

Save new file

3. Running The Test File

To run the index.js file, open up the command prompt and navigate to the Path where the SDK folder resides. Type the following command to run the file:

node index.js

Run file

How to Test

These tests use Mocha framework for testing, coupled with Chai for assertions. These dependencies need to be installed for tests to run. Tests can be run in a number of ways:

Method 1 (Run all tests)

  1. Navigate to the root directory of the SDK folder from command prompt.
  2. Type mocha --recursive to run all the tests.

Method 2 (Run all tests)

  1. Navigate to the ../test/Controllers/ directory from command prompt.
  2. Type mocha * to run all the tests.

Method 3 (Run specific controller's tests)

  1. Navigate to the ../test/Controllers/ directory from command prompt.
  2. Type mocha Releans APIController to run all the tests in that controller file.

To increase mocha's default timeout, you can change the TEST_TIMEOUT parameter's value in TestBootstrap.js.

Run Tests

Initialization

Authentication

In order to setup authentication in the API client, you need the following information.

Parameter Description
oAuthAccessToken OAuth 2.0 Access Token

API client can be initialized as following:

const lib = require('lib');

// Configuration parameters and credentials
lib.Configuration.oAuthAccessToken = "oAuthAccessToken"; // OAuth 2.0 Access Token

Class Reference

List of Controllers

Class: MessageController

Get singleton instance

The singleton instance of the MessageController class can be accessed from the API Client.

var controller = lib.MessageController;

Method: getAllMessages

List all messages sent by the account.

function getAllMessages(accept, callback)

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description

Example Usage

    var accept = '*/*';

    controller.getAllMessages(accept, function(error, response, context) {

    
    });

Method: getViewMessage

Return the details of the message.

function getViewMessage(id, accept, callback)

Parameters

Parameter Tags Description
id Required TODO: Add a parameter description
accept Required TODO: Add a parameter description

Example Usage

    var id = 'id';
    var accept = '*/*';

    controller.getViewMessage(id, accept, function(error, response, context) {

    
    });

Method: createSendSMSMessage

Send a single message.

function createSendSMSMessage(accept, senderId, mobileNumber, message, callback)

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description
senderId Required Sender id to send the message from.
mobileNumber Required The mobile number supposed to receive the message.
message Required Message text.

Example Usage

    var accept = 'Accept';
    var senderId = 'senderId';
    var mobileNumber = 'mobileNumber';
    var message = 'message';

    controller.createSendSMSMessage(accept, senderId, mobileNumber, message, function(error, response, context) {

    
    });

Back to List of Controllers

Class: SenderController

Get singleton instance

The singleton instance of the SenderController class can be accessed from the API Client.

var controller = lib.SenderController;

Method: getSenderNameDetails

Return the details of the sender name.

function getSenderNameDetails(id, accept, callback)

Parameters

Parameter Tags Description
id Required TODO: Add a parameter description
accept Required TODO: Add a parameter description

Example Usage

    var id = 'sender-id';
    var accept = '*/*';

    controller.getSenderNameDetails(id, accept, function(error, response, context) {

    
    });

Method: createSenderName

Create a new sender id to send messages using it

function createSenderName(accept, contentType, body, callback)

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description
contentType Required TODO: Add a parameter description
body Required TODO: Add a parameter description

Example Usage

    var accept = 'text/plain';
    var contentType = 'text/plain';
    var body = 'Your sender name';

    controller.createSenderName(accept, contentType, body, function(error, response, context) {

    
    });

Method: getAllSenders

List all senders names associated with the account

function getAllSenders(accept, callback)

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description

Example Usage

    var accept = '*/*';

    controller.getAllSenders(accept, function(error, response, context) {

    
    });

Back to List of Controllers

Class: BalanceController

Get singleton instance

The singleton instance of the BalanceController class can be accessed from the API Client.

var controller = lib.BalanceController;

Method: getBalance

Get your available balance

function getBalance(accept, callback)

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description

Example Usage

    var accept = 'text/plain';

    controller.getBalance(accept, function(error, response, context) {

    
    });

Back to List of Controllers

You can’t perform that action at this time.