Comparing version 0.2.3 to 0.2.4
@@ -66,3 +66,3 @@ /* automatically generated by JSCoverage - do not edit */ | ||
_$jscoverage['smsSender.js'][41]++; | ||
sendMessageRetry("list:registered", message, callback, 1); | ||
sendMessageRetry("list:all_registered", message, callback, 1); | ||
}); | ||
@@ -167,2 +167,2 @@ _$jscoverage['smsSender.js'][45]++; | ||
} | ||
_$jscoverage['smsSender.js'].source = ["/**","","\tThe MIT License","\t","\tCopyright (c) 2011 Arunoda Susiripala","\t","\tPermission is hereby granted, free of charge, to any person obtaining a copy","\tof this software and associated documentation files (the \"Software\"), to deal","\tin the Software without restriction, including without limitation the rights","\tto use, copy, modify, merge, publish, distribute, sublicense, and/or sell","\tcopies of the Software, and to permit persons to whom the Software is","\tfurnished to do so, subject to the following conditions:","\t","\tThe above copyright notice and this permission notice shall be included in","\tall copies or substantial portions of the Software.","\t","\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR","\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,","\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE","\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER","\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,","\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN","\tTHE SOFTWARE.",""," */","","var rest = require(\"restler\");","var xml2js = require(\"xml2js-expat\");","","exports.load = function(url, appId, password, retryInterval, retryLimit) {","\treturn new SmsSender(url, appId, password, retryInterval, retryLimit);","};","","function SmsSender(url, appId, password, retryInterval, retryLimit) {","\t","\tthis.sendSms = function(address, message, callback) {","\t\tsendMessageRetry(\"tel:\" + address, message, callback, 1);","\t};","\t","\tthis.broadcastSms = function(message, callback) {","\t\tsendMessageRetry(\"list:registered\", message, callback, 1);","\t};","\t","\t//Retry code block (recursive)","\tvar sendMessageRetry = function(address, message, callback, count) {","\t\t","\t\tvar retryCodes = [\"SBL-SMS-MT-5000\", \"SBL-SMS-MT-5008\", \"SBL-SMS-MT-5001\",","\t\t \t\t\t\t\"SBL-SMS-MT-5004\", \"CORE-SMS-MT-4049\", \"CORE-SMS-MT-4030\", ","\t\t \t\t\t\t\"CORE-SMS-MT-4016\"];","\t\t","\t\tif(count> retryLimit) {","\t\t\tvar err = {","\t\t\t\terror: \"Maximum retry limit of \" + retryLimit + \" exceeded when sending the message\",","\t\t\t\taddress: address,","\t\t\t\tmessage: message","\t\t\t};","\t\t\t","\t\t\tif(callback) callback(err, null);","\t\t\tconsole.error(\"maximum retry limit exeeded when sending message to: \" + url + \" for:\" + address);","\t\t} else {","\t\t\tsendMessageLogic(address, message, function(status) {","\t\t\t\t","\t\t\t\tif(!status || retryCodes.contains(status.statusCode)) {","\t\t\t\t\tconsole.log(\"retrying for: \" + count + \" of message: \" + message + \" to address:\" + address);","\t\t\t\t\tsetTimeout(function() {","\t\t\t\t\t\tsendMessageRetry(address, message, callback, count + 1);","\t\t\t\t\t}, retryInterval);","\t\t\t\t} else {","\t\t\t\t\tif(callback) callback(null, status);","\t\t\t\t}","\t\t\t});","\t\t}","\t\t","\t};","\t","\t/*","\t * Logic behind sending the message","\t */","\tvar sendMessageLogic = function(address, message, callback) {","","\t\trest.post(url, {","\t\t\tusername: appId,","\t\t\tpassword: password,","\t\t\tdata: {","\t\t\t\tversion: \"1.0\",","\t\t\t\taddress: address,","\t\t\t\tmessage: message","\t\t\t}","\t\t}).on(\"complete\", function(data, response) {","\t\t\t","\t\t\tif(response.statusCode == 200) {","\t\t\t\tparseXML(data, function(status) {","\t\t\t\t\tif(callback) callback(status);","\t\t\t\t});","\t\t\t\tconsole.info(\"message send to address: \" + address);","\t\t\t} else {","\t\t\t\tconsole.error(\"Appzone Sending message failed with statusCode: \" + response.statusCode);","\t\t\t\tif(callback) callback(null);","\t\t\t}","\t\t}).on(\"error\", function(err, err2) {","\t\t\tconsole.error(\"Something wrong with the appzone host:\" + url);","\t\t\tconsole.error(err2);","\t\t\tif(callback) callback();","\t\t});","\t};","\t","\tvar parseXML = function(data, callback) {","\t\tvar p = new xml2js.Parser();","\t\tp.addListener(\"end\", function(obj) {","\t\t\tvar status = {};","\t\t\tstatus.statusCode = obj.status_code;","\t\t\tstatus.statusDescription = obj.status_message;","\t\t\tstatus.correlationId = obj.correlator;","\t\t\t","\t\t\tcallback(status);","\t\t});","\t\tp.parseString(data);","\t};","}"]; | ||
_$jscoverage['smsSender.js'].source = ["/**","","\tThe MIT License","\t","\tCopyright (c) 2011 Arunoda Susiripala","\t","\tPermission is hereby granted, free of charge, to any person obtaining a copy","\tof this software and associated documentation files (the \"Software\"), to deal","\tin the Software without restriction, including without limitation the rights","\tto use, copy, modify, merge, publish, distribute, sublicense, and/or sell","\tcopies of the Software, and to permit persons to whom the Software is","\tfurnished to do so, subject to the following conditions:","\t","\tThe above copyright notice and this permission notice shall be included in","\tall copies or substantial portions of the Software.","\t","\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR","\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,","\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE","\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER","\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,","\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN","\tTHE SOFTWARE.",""," */","","var rest = require(\"restler\");","var xml2js = require(\"xml2js-expat\");","","exports.load = function(url, appId, password, retryInterval, retryLimit) {","\treturn new SmsSender(url, appId, password, retryInterval, retryLimit);","};","","function SmsSender(url, appId, password, retryInterval, retryLimit) {","\t","\tthis.sendSms = function(address, message, callback) {","\t\tsendMessageRetry(\"tel:\" + address, message, callback, 1);","\t};","\t","\tthis.broadcastSms = function(message, callback) {","\t\tsendMessageRetry(\"list:all_registered\", message, callback, 1);","\t};","\t","\t//Retry code block (recursive)","\tvar sendMessageRetry = function(address, message, callback, count) {","\t\t","\t\tvar retryCodes = [\"SBL-SMS-MT-5000\", \"SBL-SMS-MT-5008\", \"SBL-SMS-MT-5001\",","\t\t \t\t\t\t\"SBL-SMS-MT-5004\", \"CORE-SMS-MT-4049\", \"CORE-SMS-MT-4030\", ","\t\t \t\t\t\t\"CORE-SMS-MT-4016\"];","\t\t","\t\tif(count> retryLimit) {","\t\t\tvar err = {","\t\t\t\terror: \"Maximum retry limit of \" + retryLimit + \" exceeded when sending the message\",","\t\t\t\taddress: address,","\t\t\t\tmessage: message","\t\t\t};","\t\t\t","\t\t\tif(callback) callback(err, null);","\t\t\tconsole.error(\"maximum retry limit exeeded when sending message to: \" + url + \" for:\" + address);","\t\t} else {","\t\t\tsendMessageLogic(address, message, function(status) {","\t\t\t\t","\t\t\t\tif(!status || retryCodes.contains(status.statusCode)) {","\t\t\t\t\tconsole.log(\"retrying for: \" + count + \" of message: \" + message + \" to address:\" + address);","\t\t\t\t\tsetTimeout(function() {","\t\t\t\t\t\tsendMessageRetry(address, message, callback, count + 1);","\t\t\t\t\t}, retryInterval);","\t\t\t\t} else {","\t\t\t\t\tif(callback) callback(null, status);","\t\t\t\t}","\t\t\t});","\t\t}","\t\t","\t};","\t","\t/*","\t * Logic behind sending the message","\t */","\tvar sendMessageLogic = function(address, message, callback) {","","\t\trest.post(url, {","\t\t\tusername: appId,","\t\t\tpassword: password,","\t\t\tdata: {","\t\t\t\tversion: \"1.0\",","\t\t\t\taddress: address,","\t\t\t\tmessage: message","\t\t\t}","\t\t}).on(\"complete\", function(data, response) {","\t\t\t","\t\t\tif(response.statusCode == 200) {","\t\t\t\tparseXML(data, function(status) {","\t\t\t\t\tif(callback) callback(status);","\t\t\t\t});","\t\t\t\tconsole.info(\"message send to address: \" + address);","\t\t\t} else {","\t\t\t\tconsole.error(\"Appzone Sending message failed with statusCode: \" + response.statusCode);","\t\t\t\tif(callback) callback(null);","\t\t\t}","\t\t}).on(\"error\", function(err, err2) {","\t\t\tconsole.error(\"Something wrong with the appzone host:\" + url);","\t\t\tconsole.error(err2);","\t\t\tif(callback) callback();","\t\t});","\t};","\t","\tvar parseXML = function(data, callback) {","\t\tvar p = new xml2js.Parser();","\t\tp.addListener(\"end\", function(obj) {","\t\t\tvar status = {};","\t\t\tstatus.statusCode = obj.status_code;","\t\t\tstatus.statusDescription = obj.status_message;","\t\t\tstatus.correlationId = obj.correlator;","\t\t\t","\t\t\tcallback(status);","\t\t});","\t\tp.parseString(data);","\t};","}"]; |
@@ -41,3 +41,3 @@ /** | ||
this.broadcastSms = function(message, callback) { | ||
sendMessageRetry("list:registered", message, callback, 1); | ||
sendMessageRetry("list:all_registered", message, callback, 1); | ||
}; | ||
@@ -120,2 +120,2 @@ | ||
}; | ||
} | ||
} |
{ | ||
"name": "appzone", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"directories": { | ||
@@ -5,0 +5,0 @@ "lib": "./lib" |
@@ -9,4 +9,4 @@ NodeJs Client for Appzone | ||
------------ | ||
NodeJS 0.4 + | ||
npm 0.3 + | ||
* NodeJS 0.4 + | ||
* npm 0.3 + | ||
@@ -17,4 +17,4 @@ Installation | ||
Not Just Dump API | ||
----------------- | ||
Not Just A Dump API | ||
------------------- | ||
Appzone for NodeJS is not a dump API which replicates the Appzone Core API but provides you a much cleaner interface to do what you wanted to do. | ||
@@ -21,0 +21,0 @@ Message retries will be happen behind the seen and avoid most of the tedious works from you. |
@@ -111,2 +111,2 @@ var menu = require('menu'); | ||
}; | ||
}; |
159295
2943