Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unifonic-next-gen-lib

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unifonic-next-gen-lib

## Introduction Send SMS messages using Unifonic Messaging API. Get your dedicated Universal number, and start sending messages today. Unifonic NextGen Restful and HTTP **API's** uses The basic Authentication protocol. All request and response bodies ar

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

WARNING: This is NOT the official Unifonic SDK, at the time of this writing, Unifonic's suggested method is that a user should download the SDK from their website and extract it in their repository which makes it difficult for people to find whether there is a new version of this package that can potentially includea security fix.

I'll publish this as a package, I'll try to keep the dependencies up-to-date until Unifonic publish their own official package.

Getting started

Introduction

Send SMS messages using Unifonic Messaging API. Get your dedicated Universal number, and start sending messages today.

Unifonic NextGen Restful and HTTP API's uses The basic Authentication protocol. All request and response bodies are formatted in JSON.

Get an account

To start using the API you need to send an email to Unifonic to create Appsid for you.

Base URL

All URLs referenced in the documentation have the following base:

basic.unifonic.com

Security

To ensure privacy we recommend you to use HTTPS for all Unifonic API requests. you can download our HTTPS certificate.

[Download] (https://api.unifonic.com/udm/https.zip)

Formats

Unifonic API only supports JSON format. All request must use the Content-type header set to application/json.

Support

We’re here to help! Get in touch with support at support@unifonic.com and we’ll get back to you as soon as we can or you can contact us throw live chat on our [website] (www.unifonic.com).

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 UnifonicNextGenLib 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 Unifonic NextGenController 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.

ParameterDescription
basicAuthUserNameThe username to use with basic authentication
basicAuthPasswordThe password to use with basic authentication

API client can be initialized as following:

const lib = require('lib');

// Configuration parameters and credentials
lib.Configuration.basicAuthUserName = "basicAuthUserName"; // The username to use with basic authentication
lib.Configuration.basicAuthPassword = "basicAuthPassword"; // The password to use with basic authentication

Class Reference

List of Controllers

Class: WrapperController

Get singleton instance

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

var controller = lib.WrapperController;

Method: createGetMsgQuery

Unifonic Get message query API allows you to get details of specified message.

function createGetMsgQuery(appsid, msgid, to, callback)
Parameters
ParameterTagsDescription
appsidRequiredA character string that uniquely identifies your app
msgidRequiredA unique ID that identifies a message
toOptionalDestination mobile number, mobile numbers must be in international format without 00 or + Example: (4452023498)
Example Usage

    var appsid = '6v253153s1g7831s5';
    var msgid = 3200017891630;
    var to = 966505980169;

    controller.createGetMsgQuery(appsid, msgid, to, function(error, response, context) {

    
    });
Errors
Error CodeError Description
401Authentication failed
402Missing parameter AppSid
432MessageId must be numeric
452User must specify either messageId or recipient parameter

Method: createSendMessage

Unifonic Send Wrapper API allows you to send text messages to multiple users at the same time

function createSendMessage(appsid, msg, to, sender, baseEncode, encoding, callback)
Parameters
ParameterTagsDescription
appsidRequiredA character string that uniquely identifies your app
msgRequiredMessage body supports both English and unicodes characters, concatenated messages is supported
toRequiredDestination mobile number, mobile numbers must be in international format without 00 or + Example: (4452023498)
senderRequiredThe SenderID to send from, App default SenderID is used unless else stated
baseEncodeOptional DefaultValueBinary-to-text encoding schemes that represent binary data in an ASCII string format
encodingOptional DefaultValueConverts information from a source into symbols for communication or storage, GSM7 for English and UCS2 for Arabic
Example Usage

    var appsid = '6v253153s1g7831s5';
    var msg = 'Test';
    var to = 966505980169;
    var sender = 'sender';
    var baseEncode = true;
    var encoding = 'encoding';

    controller.createSendMessage(appsid, msg, to, sender, baseEncode, encoding, function(error, response, context) {

    
    });
Errors
Error CodeError Description
401Authentication failed
402Missing parameter AppSid
459Authentication parameters are incorrectly base64 encoded

Back to List of Controllers

Class: RestController

Get singleton instance

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

var controller = lib.RestController;

Method: createSendScheduledMessages

Unifonic Send Scheduled API allows you to schedule text messages to users around the globe through simple RESTful API to be sent in future.

function createSendScheduledMessages(appSid, senderID, recipient, body, timeScheduled, responseType, correlationID, baseEncode, callback)
Parameters
ParameterTagsDescription
appSidRequiredA character string that uniquely identifies your app
senderIDRequiredThe SenderID to send from, App default SenderID is used unless else stated
recipientRequiredDestination mobile number, mobile numbers must be in international format without 00 or + Example: (4452023498)
bodyRequiredMessage body supports both English and unicodes characters, concatenated messages is supported
timeScheduledRequiredSchedule send messages, in the following format yyyy-mm-dd HH:mm:ss
responseTypeOptionalSupport json format only
correlationIDOptionalIs a unique identifier value that is attached to requests and messages
baseEncodeOptionalBinary-to-text encoding schemes that represent binary data in an ASCII string format
Example Usage

    var appSid = '6v253153s1g7831s5';
    var senderID = 'sender';
    var recipient = 966505980169;
    var body = 'Test';
    var timeScheduled = "2020-04-12 11:50:00";
    var responseType = 'responseType';
    var correlationID = 'CorrelationID';
    var baseEncode = true;

    controller.createSendScheduledMessages(appSid, senderID, recipient, body, timeScheduled, responseType, correlationID, baseEncode, function(error, response, context) {

    
    });
Errors
Error CodeError Description
401Authentication failed
406Wrong parameter format
449Message body is empty
451TimeScheduled parameter must indicate time in the future
480This user cannot use specified SenderID
482Invalid dest num

Method: createSendMessage

Unifonic Send API allows you to send text messages to users around the globe through simple RESTful APIs

function createSendMessage(appSid, senderID, body, recipient, responseType, correlationID, baseEncode, statusCallback, async, callback)
Parameters
ParameterTagsDescription
appSidRequiredA character string that uniquely identifies your app
senderIDRequiredThe SenderID to send from, App default SenderID is used unless else stated
bodyRequiredMessage body supports both English and unicodes characters, concatenated messages is supported
recipientRequiredDestination mobile number, mobile numbers must be in international format without 00 or + Example: (4452023498)
responseTypeOptionalSupport json format only
correlationIDOptionalIs a unique identifier value that is attached to requests and messages
baseEncodeOptionalBinary-to-text encoding schemes that represent binary data in an ASCII string format
statusCallbackOptionalFilter messages report according to a specific message status, "Sent", "Queued", "Rejected" or "Failed
asyncOptional DefaultValueIt specifies that the request will be executed asynchronously as soon as it is sent
Example Usage

    var appSid = '6v253153s1g7831s5';
    var senderID = 'sender';
    var body = 'Test';
    var recipient = 966505980169;
    var responseType = 'responseType';
    var correlationID = 'CorrelationID';
    var baseEncode = true;
    var statusCallback = 'statusCallback';
    var async = true;

    controller.createSendMessage(appSid, senderID, body, recipient, responseType, correlationID, baseEncode, statusCallback, async, function(error, response, context) {

    
    });
Errors
Error CodeError Description
401Authentication failed
449Message body is empty
480This user cannot use specified SenderID
482Invalid dest num

Method: getScheduledMessageDetails

Unifonic Scheduled message details allows you to get details of scheduled messages through simple RESTful APIs

function getScheduledMessageDetails(appSid, callback)
Parameters
ParameterTagsDescription
appSidRequiredA character string that uniquely identifies your app
Example Usage

    var appSid = '6v253153s1g7831s5';

    controller.getScheduledMessageDetails(appSid, function(error, response, context) {

    
    });
Errors
Error CodeError Description
401Authentication failed

Method: deleteStopScheduledMessages

Unifonic Stop scheduled messages API allows you to Delete (Stops) scheduled message,If MessageID is specified only one message is stopped, Otherwise all messages are stopped through simple RESTful APIs.

function deleteStopScheduledMessages(appSid, messageID, responseFormat, baseEncode, callback)
Parameters
ParameterTagsDescription
appSidRequiredA character string that uniquely identifies your app
messageIDOptionalA unique ID that identifies a message
responseFormatOptionalsupport json format only
baseEncodeOptionalBinary-to-text encoding schemes that represent binary data in an ASCII string format
Example Usage

    var appSid = '6v253153s1g7831s5';
    var messageID = 3200017889502;
    var responseFormat = '';
    var baseEncode = true;

    controller.deleteStopScheduledMessages(appSid, messageID, responseFormat, baseEncode, function(error, response, context) {

    
    });
Errors
Error CodeError Description
401Authentication failed
455Scheduled message not found for this User

Method: createGetMessageDetails

Unifonic Get message details API allows you to get details of messages with optional filters,returns paginated messages, next page or previous page through simple RESTful APIs

function createGetMessageDetails(appSid, messageID, senderID, recipient, dateFrom, dateTo, correlationID, limit, baseEncode, callback)
Parameters
ParameterTagsDescription
appSidRequiredA character string that uniquely identifies your app
messageIDOptionalA unique ID that identifies a message
senderIDOptionalThe SenderID to send from, App default SenderID is used unless else stated
recipientOptionalDestination mobile number, mobile numbers must be in international format without 00 or + Example: (4452023498)
dateFromOptionalThe start date for the report time interval, date format should be yyyy-mm-dd
dateToOptionalThe end date for the report time interval, date format should be yyyy-mm-dd
correlationIDOptionalIs a unique identifier value that is attached to requests and messages
limitOptionalThe maximum number of messages details
baseEncodeOptionalBinary-to-text encoding schemes that represent binary data in an ASCII string format
Example Usage

    var appSid = '6v253153s1g7831s5';
    var messageID = 2000000172800;
    var senderID = 'sender';
    var recipient = 966505980169;
    var dateFrom = "2018-04-12";
    var dateTo = "2018-09-12";
    var correlationID = 'CorrelationID';
    var limit = 20;
    var baseEncode = true;

    controller.createGetMessageDetails(appSid, messageID, senderID, recipient, dateFrom, dateTo, correlationID, limit, baseEncode, function(error, response, context) {

    
    });
Errors
Error CodeError Description
401Authentication failed
432MessageId must be numeric
599Request failed

Back to List of Controllers

FAQs

Package last updated on 18 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc