easynexmo
Advanced tools
Comparing version 0.6.6 to 0.7.0
var nexmo = require('./lib/nexmo'); | ||
nexmo.initialize("0056f4c3","nexmoapi","https",true); | ||
//nexmo.sendTextMessage("17208403400","17208403400",'acknowldge receipt by whatsapp - prabhu',consolelog); | ||
//nexmo.sendMessage({from:19853020714,to:17208403400,text:'acknowldge receipt by whatsapp - prabhu'},consolelog); | ||
//nexmo.sendMessage({from:19853020714,to:17208403400,text:'second message'},consolelog); | ||
nexmo.sendTextMessage("17208403400","17208403400",'acknowldge receipt by whatsapp - prabhu',consolelog); | ||
nexmo.sendMessage({from:19853020714,to:17208403400,text:'acknowldge receipt by whatsapp - prabhu'},consolelog); | ||
nexmo.sendMessage({from:19853020714,to:17208403400,text:'second message'},consolelog); | ||
function consolelog (err,messageResponse) { | ||
@@ -13,5 +13,5 @@ if (err) { | ||
} | ||
//nexmo.checkBalance(consolelog); | ||
//nexmo.getPricing('US',consolelog); | ||
//nexmo.getNumbers(consolelog); | ||
nexmo.checkBalance(consolelog); | ||
nexmo.getPricing('US',consolelog); | ||
nexmo.getNumbers(consolelog); | ||
//nexmo.searchNumbers('US',consolelog); | ||
@@ -22,11 +22,11 @@ //nexmo.searchNumbers('US',303,consolelog); | ||
//nexmo.sendTTSMessage ('123456','testing',{},consolelog); | ||
//nexmo.sendTTSMessage ('17208403400','testing',{},consolelog); | ||
//nexmo.sendTTSPromptWithCapture('17208403400','testing',6,'Goodbye',{},consolelog); | ||
//nexmo.sendTTSPromptWithConfirm('17208403400','Enter your pin',6,'123456','Goodbye','Wrong pin',{},consolelog); | ||
//nexmo.call('7208403400','http://nexin.herokuapp.com/voice/8ed90e10-e33c-11e4-b9ca-6fc84273567d',{error_url:"http://nexin.herokuapp.com/incoming/8ed90e10-e33c-11e4-b9ca-6fc84273567d"},consolelog); | ||
nexmo.call('7208403400','https://vxml.herokuapp.com/dialogue',{error_url:"http://nexin.herokuapp.com/incoming/8ed90e10-e33c-11e4-b9ca-6fc84273567d"},consolelog); | ||
//nexmo.call('7208403400','https://vxml.herokuapp.com/dialogue',{error_url:"http://nexin.herokuapp.com/incoming/8ed90e10-e33c-11e4-b9ca-6fc84273567d"},consolelog); | ||
//nexmo.verifyNumber({number:'17208403400',brand:'nexmotest'},consolelog); | ||
//nexmo.checkVerifyRequest({request_id:'5a604b0a1fb04b7f9d8ab57a1bdf132a',code:'7101'},consolelog); | ||
/*nexmo.searchVerifyRequest(['5a604b0a1fb04b7f9d8ab57a1bdf132a','5a604b0a1fb04b7f9d8ab57a1bdf132a'],consolelog); | ||
//nexmo.numberInsight({number:'17208403400',callback:'http://54.88.118.244:7777/'},consolelog);*/ | ||
//nexmo.checkVerifyRequest({request_id:'50b4da192568493fa1a681e7bbba9d12',code:'3849'},consolelog); | ||
//nexmo.searchVerifyRequest(['5a604b0a1fb04b7f9d8ab57a1bdf132a','5a604b0a1fb04b7f9d8ab57a1bdf132a'],consolelog); | ||
//nexmo.numberInsight({number:'17208403400',callback:'http://54.88.118.244:7777/'},consolelog); |
@@ -13,4 +13,6 @@ /* | ||
*/ | ||
'use strict'; | ||
var https = require('https'); | ||
var http = require('http'); | ||
var querystring = require('querystring'); | ||
@@ -36,3 +38,2 @@ | ||
var up = {}; | ||
var useHttps = false; | ||
var debugOn = false; | ||
@@ -64,4 +65,4 @@ | ||
// protocol and debugon are optional | ||
exports.initialize = function(pkey, psecret, protocol, debugon) { | ||
// debugon is optional | ||
exports.initialize = function(pkey, psecret, debugon) { | ||
if (!pkey || !psecret) { | ||
@@ -76,3 +77,2 @@ throw 'key and secret cannot be empty, set valid values'; | ||
} | ||
useHttps = protocol && protocol == 'https'; // default to http | ||
debugOn = !debugon ? false : (String(debugon) === "false" ? false : true); | ||
@@ -207,3 +207,3 @@ initialized = true; | ||
headers['Content-Length'] = 0; // Fix broken due ot 411 Content-Length error now sent by Nexmo API | ||
options = { | ||
var options = { | ||
host: endpoint.host?endpoint.host:'rest.nexmo.com', | ||
@@ -219,8 +219,4 @@ port: 80, | ||
if (true) { // set to false to verify the request without sending the actual request | ||
if (useHttps) { | ||
options.port = 443; | ||
request = https.request(options); | ||
} else { | ||
request = http.request(options); | ||
} | ||
options.port = 443; | ||
request = https.request(options); | ||
request.end(); | ||
@@ -227,0 +223,0 @@ var responseReturn = ''; |
{ | ||
"name": "easynexmo", | ||
"author": "Prabhu Velayutham", | ||
"version": "0.6.6", | ||
"version": "0.7.0", | ||
"main": "lib/nexmo", | ||
@@ -21,4 +21,5 @@ "keywords": [ | ||
"justinfreitag", | ||
"ecwyne" | ||
"ecwyne", | ||
"https://github.com/backhand" | ||
] | ||
} |
@@ -6,10 +6,12 @@ [![build status](https://secure.travis-ci.org/pvela/nexmo.png)](http://travis-ci.org/pvela/nexmo) | ||
Installation Instructions : | ||
Installation Instructions : | ||
=========================== | ||
Download and Install lib/nexmo.js in your lib | ||
Download and Install lib/nexmo.js in your lib | ||
or | ||
or use | ||
use "npm install easynexmo -g" | ||
``` | ||
npm install easynexmo | ||
``` | ||
@@ -19,5 +21,7 @@ Usage : | ||
```js | ||
var nexmo = require('easynexmo'); | ||
nexmo.initialize(KEY,SECRET,API_PROTOCOL,DEBUG); | ||
nexmo.initialize(KEY, SECRET, DEBUG); | ||
``` | ||
@@ -28,4 +32,2 @@ KEY - API Key from Nexmo | ||
API_PROTOCOL - http or https | ||
DEBUG - set this to true to debug library calls | ||
@@ -53,3 +55,3 @@ | ||
###Check Account Balance | ||
###Check Account Balance | ||
nexmo.checkBalance(callback); | ||
@@ -100,6 +102,6 @@ | ||
###Send TTS Message | ||
nexmo.sendTTSMessage = function(<TO_NUMBER>,message,options,callback); | ||
###Send TTS Prompt With Capture | ||
###Send TTS Prompt With Capture | ||
@@ -158,2 +160,23 @@ nexmo.sendTTSPromptWithCapture(<TO_NUMBER>,message,<MAX_DIGITS>, <BYE_TEXT>,options,callback); | ||
Testing | ||
======= | ||
There is a basic test suite which will test the functionality. It uses environment variables for settings for the tests. The environment variables are: | ||
* KEY = The API key provided by Nexmo for your account | ||
* SECRET = The secret provided by NExmo for your account | ||
* FROM_NUMBER = The phone number to send messages and make calls from. | ||
* TO_NUMBER = The phone number to send messages and make calls to. | ||
* MAX_DIGITS = The maximum number of digits for the pin code. | ||
* ANSWER_URL = The URL which has the VoiceXML file to control the call functionality | ||
* PIN_CODE = The digits you must enter to confirm the message | ||
You run the test suite using: | ||
``` | ||
KEY=<your key> SECRET=<your secret> FROM_NUMBER=<from number> TO_NUMBER=<to number> MAX_DIGITS=<max digits> ANSWER_URL=<your answer url> PIN_CODE=<your pin code> node test/nexmo_test.js | ||
``` | ||
Please remeber to substitute the values! | ||
The MIT License (MIT) | ||
@@ -160,0 +183,0 @@ ===================== |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
29243
538
186
1
7