diff --git a/globeconnect/certs/globe.crt b/certs/globe.crt similarity index 100% rename from globeconnect/certs/globe.crt rename to certs/globe.crt diff --git a/globeconnect/README.md b/globeconnect/README.md deleted file mode 100644 index 3984eea..0000000 --- a/globeconnect/README.md +++ /dev/null @@ -1,185 +0,0 @@ -# Globe Connect for Node.JS - -## Introduction -Globe Connect for Node.JS platform provides an implementation of Globe APIs e.g Authentication, Amax, -Sms etc. that is easy to use and can be integrated in your existing Node.JS application. Below shows -some samples on how to use the API depending on the functionality that you need to integrate in your -application. - -## Basic Usage - -###### Figure 1. Authentication - -```javascript -globe = require('globe-connect'); - -oauth = globe.Oauth('[app_key]', '[app_secret]'); - -// get redirect url -url = oauth.getRedirectUrl(); -console.log(url); - -// get access token -oauth.getAccessToken('[code]', function(resCode, body) { - // some code here - console.log(resCode); - console.log(body) -}); -``` - -###### Figure 2. Amax - - -```javascript -globe = require('globe-connect'); -amax = globe.Amax('[app_id]', '[app_secret]'); -amax.setToken('[token]'); -amax.setAddress('[address]'); -amax.setPromo('[promo]'); -amax.sendReward(function(resCode, body) { - // some code here - console.log(resCode); - console.log(body); -}); -``` - -###### Figure 3. Binary SMS - -```javascript -globe = require('globe-connect'); -var sms = globe.Sms('[shortcode]', '[token]'); - -sms.setUserDataHeader('06050423F423F4'); -sms.setDataEncodingScheme(1) -sms.setReceiverAddress('+639065272450') -sms.setMessage('samplebinarymessage') -sms.sendBinaryMessage(function(resCode, body) { - // some code here - console.log(resCode); - console.log(body); -}) -``` - -###### Figure 4. Location - -```javascript -globe = require('globe-connect'); -var amax = globe.Location('[token]'); -amax.setAddress('[address]'); -amax.setRequestedAccuracy('[accuracy]'); -amax.getLocation(function(resCode, body) { - // some code here - console.log(resCode); - console.log(body); -}); -``` - -###### Figure 5. Payment (Send Payment Request) - - -```javascript -globe = require('globe-connect'); -payment = globe.Payment('[token]'); -payment.setAmount('[amount]'); -payment.setDescription('[desciption]'); -payment.setEndUserId('[number]'); -payment.setReferenceCode('[referenceCode]'); -payment.setTransactionOperationStatus('[status]'); -payment.sendPaymentRequest(function(resCode, body) { - // some code here - console.log(resCode); - console.log(body); -}) -``` - -###### Figure 6. Payment (Get Last Reference ID) -```javascript - -globe = require('globe-connect'); -payment = globe.Payment('[token]'); -payment.setAppKey('[app_key]'); -payment.setAppSecret('[app_secret]'); -payment.getLastReferenceCode(function(resCode, body) { - // some code here - console.log(resCode); - console.log(body); -}) -``` - -###### Figure 7. Sms - -```javascript -globe = require('globe-connect'); -var sms = globe.Sms('[shortcode]', '[token]'); - -/* SEND MESSAGE */ -sms.setReceiverAddress('[address]'); -sms.setMessage('[message]') -sms.sendMessage(function(resCode, body){ - // some code here - console.log(resCode); - console.log(body); -}); -``` - - -###### Figure 8. Subscriber (Get Balance) - - -```javsacript -globe = require('globe-connect'); -subscriber = globe.Subscriber('[token]'); -subscriber.setAddres('[address]'); -subscriber.getSubscriberBalance(function(resCode, body) { - // some code here - console.log(resCode); - console.log(body); -}); -``` - -###### Figure 9. Subscriber (Get Reload Amount) - -```javascript -globe = require('globe-connect'); -subscriber = globe.Subscriber('[token]'); -subscriber.setAddres('[address]'); -subscriber.getReloadAmount(function(resCode, body) { - // some code here - console.log(resCode); - console.log(body); -}); - -``` - -###### Figure 10. USSD (Send) - -```javascript -globe = require('globe-connect'); -ussd = globe.Ussd('[token]', '[shortcode]'); - -ussd.setAddress('[address]'); -ussd.setUssdMessage('[message]'); -ussd.setFlash('[flash]'); -ussd.sendUssdRequest(function(resCode, body) { - // some code here - console.log(resCode); - console.log(body); -}); -``` - -###### Figure 11. USSD (Reply) - -```javascript -globe = require('globe-connect'); -ussd = globe.Ussd('[token]', '[shortcode]'); - -ussd.setAddress('[address]'); -ussd.setUssdMessage('[message]'); -ussd.setFlash('[flash]'); -ussd.setSessionId('[session_id]') -ussd.replyUssdRequest(function(resCode, body) { - // some code here - console.log(resCode); - console.log(body); -}); -``` diff --git a/globeconnect/lib/voice.js b/globeconnect/lib/voice.js deleted file mode 100644 index 4fcdf18..0000000 --- a/globeconnect/lib/voice.js +++ /dev/null @@ -1,151 +0,0 @@ -var Voice = function() { - this.obj = {}; - this.ask = require(__dirname + '/voice/ask.js'); - this.addAsk = function(obj) { - addAbstract.call(this, 'ask', obj); - return this; - } - - this.call = require(__dirname + '/voice/call.js'); - this.addCall = function(obj) { - addAbstract.call(this, 'call', obj); - return this; - } - - this.choices = require(__dirname + '/voice/choices.js'); - this.addChoices = function(obj) { - addAbstract.call(this, 'choices', obj); - return this; - } - - this.conference = require(__dirname + '/voice/conference.js'); - this.addConference = function(obj) { - addAbstract.call(this, 'conference', obj); - return this; - } - - this.joinPrompt = require(__dirname + '/voice/joinprompt.js'); - this.addJoinPrompt = function(obj) { - addAbstract.call(this, 'joinPrompt', obj); - return this; - } - - this.leavePrompt = require(__dirname + '/voice/leaveprompt.js'); - this.addLeavePrompt = function(obj) { - addAbstract.call(this, 'leavePrompt', obj); - return this; - } - - this.machineDetection = require(__dirname + '/voice/machinedetection.js'); - this.addMachineDetection = function(obj) { - addAbstract.call(this, 'machineDetection', obj); - return this; - } - - this.message = require(__dirname + '/voice/message.js'); - this.addMessage = function(obj) { - addAbstract.call(this, 'message', obj); - return this; - } - - this.on = require(__dirname + '/voice/on.js'); - this.addOn = function(obj) { - addAbstract.call(this, 'on', obj); - return this; - } - - this.record = require(__dirname + '/voice/record.js'); - this.addRecord = function(obj) { - addAbstract.call(this, 'record', obj); - return this; - } - - this.redirect = require(__dirname + '/voice/redirect.js'); - this.addRedirect = function(obj) { - addAbstract.call(this, 'redirect', obj); - return this; - } - - this.result = require(__dirname + '/voice/result.js'); - this.addResult = function(obj) { - addAbstract.call(this, 'result', obj); - return this; - } - - this.say = require(__dirname + '/voice/say.js'); - this.addSay = function(obj) { - addAbstract.call(this, 'say', obj); - return this; - } - - this.session = require(__dirname + '/voice/session.js'); - this.addSession = function(obj) { - addAbstract.call(this, 'session', obj); - return this; - } - - this.startRecording = require(__dirname + '/voice/startrecording.js'); - this.addStartRecording = function(obj) { - addAbstract.call(this, 'startRecording', obj); - return this; - } - - this.transcription = require(__dirname + '/voice/tanscription.js'); - this.addTranscription = function(obj) { - addAbstract.call(this, 'transcription', obj); - return this; - } - - this.transfer = require(__dirname + '/voice/transfer.js'); - this.addTransfer = function(obj) { - addAbstract.call(this, 'transfer', obj); - return this; - } - - this.wait = require(__dirname + '/voice/wait.js'); - this.addWait = function(obj) { - addAbstract.call(this, 'wait', obj); - return this; - } - - this.addHangup = function() { - addAbstract.call(this, 'hangup', {}); - } - - this.addReject = function() { - addAbstract.call(this, 'reject', {}); - } - - addAbstract = function(key, obj) { - if(typeof obj == 'object' && typeof obj.getObject == 'function') { - obj = obj.getObject(); - } - - addToTropo.call(this, key, obj); - } - - initTropo = function() { - if(typeof this.obj.tropo == 'undefined') { - this.obj.tropo = []; - } - }; - - addToTropo = function(key, obj) { - initTropo.call(this); - var i = this.obj.tropo.length; - - this.obj.tropo[i] = {}; - this.obj.tropo[i][key] = {}; - this.obj.tropo[i][key] = obj; - } - - this.getObject = function() { - return this.obj; - } - - return this; -} - -module.exports = function() { - return new Voice(); -} diff --git a/globeconnect/lib/voice/ask.js b/globeconnect/lib/voice/ask.js deleted file mode 100644 index 9d63aad..0000000 --- a/globeconnect/lib/voice/ask.js +++ /dev/null @@ -1,98 +0,0 @@ -var Ask = function(say) { - var obj = {}; - this.say = say; - - this.setChoices = function(choices) { - this.choices = choices; - return this; - }; - - this.setMaxAttempt = function(attempt) { - obj.attempt = attempt; - return this; - }; - - this.setBargein = function(bargein) { - obj.bargein = bargein; - return this; - } - - this.setMinConfidence = function(confidence) { - obj.confidence = confidence; - return this; - }; - - this.setName = function(name) { - obj.name = name; - return this; - }; - - this.setRecognizer = function(recognizer) { - obj.recognizer = recognizer; - return this; - }; - - this.setTimeout = function(timeout) { - obj.timeout = timeout; - return this; - }; - - this.setVoice = function(voice) { - obj.voice = voice; - return this; - }; - - this.setInterdigitTimeout = function(idTimeout) { - obj.interdigitTimeout = idTimeout; - return this; - }; - - this.setSensitivity = function(sensitivity) { - obj.sensitivity = sensitivity; - return this; - }; - - this.setSpeechCompleteTimeout = function(scTimeout) { - obj.speechCompleteTimeout = scTimeout; - return this; - }; - - this.setSpeechIncompleteTimeout = function(siTimeout) { - obj.speechIncompleteTimeout = siTimeout; - return this; - }; - - this.getObject = function() { - if(typeof this.choices === 'undefined') { - throw new Error('Choices is required.'); - } - - if(typeof this.say === 'undefined') { - throw new Error('Say is required.'); - } - - obj.choices = this.say.event == null ? this.choices : JSON.stringify(this.choices, rmNull); - obj.say = this.say.event == null ? this.say : JSON.stringify(this.say, rmNull); - - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - }; - - rmNull = function(key, value) { - if (value === null) { - return undefined; - } - - return value; - }; - -} - -module.exports = function(say) { - return new Ask(say); -} diff --git a/globeconnect/lib/voice/call.js b/globeconnect/lib/voice/call.js deleted file mode 100644 index 3e58444..0000000 --- a/globeconnect/lib/voice/call.js +++ /dev/null @@ -1,85 +0,0 @@ -var Call = function(to) { - var obj = {}; - - this.to = to; - - this.setName = function(name) { - obj.name = name; - return this; - } - - this.setAnswerToMedia = function(ansMedia) { - obj.answerToMedia = ansMedia; - return this; - }; - - this.setChannel = function(channel) { - obj.channel = channel; - return this; - }; - - this.from = function(from) { - obj.from = from; - return this; - }; - - this.setHeaders = function(headers) { - obj.headers = header; - return this; - }; - - this.setRecording = function(recodring) { - obj.recording = recording; - return this; - }; - - this.required = function(required) { - obj.required = required; - return this; - }; - - this.setTimeout = function(timeout) { - obj.timeout = timeout; - return this; - }; - - this.allSignals = function(signal) { - obj.allowSignals = signal; - return this; - }; - - this.setMachineDetection = function(mDetection) { - obj.machineDetection = mDetection; - return this; - }; - - this.getObject = function() { - if(typeof this.to == 'undefined') { - throw new Error('to is required'); - } - - obj.to = this.to; - - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - }; - - rmNull = function(key, value) { - if (value === null) { - return undefined; - } - - return value; - }; - - return this; -}; - -module.exports = function(to) { - return new Call(to); -} diff --git a/globeconnect/lib/voice/choices.js b/globeconnect/lib/voice/choices.js deleted file mode 100644 index 54c27d1..0000000 --- a/globeconnect/lib/voice/choices.js +++ /dev/null @@ -1,41 +0,0 @@ -var Choices = function(value) { - var obj = {}; - - if(typeof this.value != 'undefined') { - this.value = value; - } - - this.setMode = function(mode) { - obj.mode = mode; - return this; - }; - - this.setTerminator = function(terminator) { - obj.terminator = terminator; - return this; - }; - - this.getObject = function() { - if(typeof this.value == 'undefined') { - throw new Error('Choices value is required'); - } - - if(typeof this.value != 'undefined') { - obj.value = this.value; - } - - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - } - - return this; -}; - -module.exports = function(value) { - return new Choices(value); -} diff --git a/globeconnect/lib/voice/conference.js b/globeconnect/lib/voice/conference.js deleted file mode 100644 index d52578b..0000000 --- a/globeconnect/lib/voice/conference.js +++ /dev/null @@ -1,76 +0,0 @@ -var Conference = function(id) { - var obj = {}; - this.id = id; - - this.mute = function(mute) { - obj.mute = mute; - return this; - }; - - this.setName = function(name) { - this.name = name; - return this; - }; - - this.setPlayTones = function(playTones) { - obj.playTones = playTones; - return this; - }; - - this.required = function(required) { - obj.required = required; - return this; - }; - - this.setTerminator = function(terminator) { - obj.terminator = terminator; - return this; - }; - - this.allowSignals = function(allowSignals) { - obj.allowSignals = allowSignals; - return this; - }; - - this.setInterdigitTimeout = function(idTimeout) { - obj.interdigitTimeout = idTimeout; - return this; - }; - - this.setJoinPrompt = function(jPrompt) { - obj.jPrompt; - return this; - }; - - this.setLeavePrompt = function(lPrompt) { - obj.leavePrompt = lPrompt; - return this; - }; - - this.getObject = function() { - if(typeof this.id == 'undefined') { - throw new Error('Conference id is required.'); - } - - if(typeof this.name == 'undefined') { - throw new Error('Conference name is required.'); - } - - obj.id = this.id; - obj.name = this.name; - - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - }; - - return this; -}; - -module.exports = function(id) { - return new Conference(id); -} diff --git a/globeconnect/lib/voice/joinprompt.js b/globeconnect/lib/voice/joinprompt.js deleted file mode 100644 index 2aa1262..0000000 --- a/globeconnect/lib/voice/joinprompt.js +++ /dev/null @@ -1,31 +0,0 @@ -var JoinPrompt = function(value) { - var obj = {}; - this.value = value; - - this.setVoice = function(voice) { - obj.voice = voice; - return this; - }; - - this.getObject = function() { - if(typeof this.value == 'undefined') { - throw new Error('Join Prompt is required.'); - } - - obj.value = this.value; - - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - }; - - return this; -}; - -module.exports = function(value) { - return new JoinPrompt(value); -} diff --git a/globeconnect/lib/voice/leaveprompt.js b/globeconnect/lib/voice/leaveprompt.js deleted file mode 100644 index 46b053c..0000000 --- a/globeconnect/lib/voice/leaveprompt.js +++ /dev/null @@ -1,30 +0,0 @@ -var LeavePrompt = function(value) { - var obj = {}; - this.value = value; - - this.setVoice = function(voice) { - obj.voice = voice; - return this; - }; - - this.getObject = function() { - if(typeof this.value == 'undefined') { - throw new Error('Leave Prompt is required.'); - } - - obj.value = this.value; - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - }; - - return this; -}; - -module.exports = function(value) { - return new LeavePrompt(value); -} diff --git a/globeconnect/lib/voice/machinedetection.js b/globeconnect/lib/voice/machinedetection.js deleted file mode 100644 index f93646a..0000000 --- a/globeconnect/lib/voice/machinedetection.js +++ /dev/null @@ -1,28 +0,0 @@ -var machineDetection = function() { - var obj = {}; - this.setIntroduction = function(introduction) { - obj.introduction = introduction; - return this; - }; - - this.setVoice = function(voice) { - obj.voice = voice; - return this; - }; - - this.getObject = function() { - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - } - - return this; -}; - -module.exports = function() { - return new machineDetection(); -} diff --git a/globeconnect/lib/voice/on.js b/globeconnect/lib/voice/on.js deleted file mode 100644 index e4b62cf..0000000 --- a/globeconnect/lib/voice/on.js +++ /dev/null @@ -1,67 +0,0 @@ -var On = function(e) { - var obj = {}; - this.event = e; - - this.setSay = function(say) { - this.say = say; - return this; - }; - - this.setName = function(name) { - this.name = name; - return this; - }; - - this.next = function(next) { - obj.next = next; - return this; - }; - - this.required = function(required) { - obj.required = required; - return this; - }; - - this.ask = function(ask) { - obj.ask = ask; - return this; - }; - - this.setMessage = function(message) { - obj.message = message; - return this; - }; - - this.wait = function(wait) { - obj.wait = wait; - return this; - }; - - this.getObject = function() { - if(typeof this.event == 'undefined') { - throw new Error('Event is required'); - } - - if(typeof this.say == 'undefined') { - throw new Error('Say is required'); - } - - obj.event = this.event; - obj.name = this.name; - obj.say = typeof this.say == 'object' ? JSON.stringify(this.say) : this.say; - - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - }; - - return this; -}; - -module.exports = function(e, say) { - return new On(e, say); -} diff --git a/globeconnect/lib/voice/record.js b/globeconnect/lib/voice/record.js deleted file mode 100644 index 27a98f3..0000000 --- a/globeconnect/lib/voice/record.js +++ /dev/null @@ -1,129 +0,0 @@ -var Record = function(name, url) { - var obj = {}; - - this.name = name; - this.url = url; - - this.setAttempts = function(attempts) { - obj.attempts = attempts; - return this; - }; - - this.setBargein = function(bargein) { - obj.bargein = bargein; - return this; - }; - - this.setBeep = function(beep) { - obj.beep = beep; - return this; - }; - - this.setChoices = function(choices) { - obj.choices = choices; - return this; - }; - - this.setFormat = function(format) { - obj.format = format; - return this; - }; - - this.setMaxSilence = function(silence) { - obj.maxSilence = silence; - return this; - }; - - this.setMaxTime = function(maxTime) { - obj.maxTime = maxTime; - return this; - }; - - this.setMethod = function(method) { - obj.method = method; - return this; - }; - - this.setMinConfidence = function(minConfidence) { - obj.minConfidence = minConfidence; - return this; - }; - - this.required = function(required) { - obj.required = required; - return this; - }; - - this.say = function(say) { - obj.say = say; - return this; - }; - - this.setTimeout = function(timeout) { - obj.timeout = timeout; - return this; - }; - - this.setTranscription = function(transcription) { - this.transcription = transcription; - return this; - }; - - - this.setPassword = function(password) { - obj.password = password; - return this; - }; - - this.setUsername = function(username) { - obj.username = username; - return this; - }; - - this.setVoice = function(voice) { - obj.voice = voice; - return this; - }; - - this.allowSignals = function(allowSignals) { - obj.allowSignals = allowSignals; - return this; - }; - - this.setInterdigitTimeout = function(idTimeout) { - obj.interdigitTimeout = idTimeout; - return this; - }; - - this.getObject = function() { - if(typeof this.name == 'undefined') { - throw new Error('Name is required.'); - } - - if(typeof this.url == 'undefined') { - throw new Error('Url is required.'); - } - - if(typeof this.transcription != 'undefined') { - obj.transcription = typeof this.transcription == 'object' ? JSON.stringify(this.transcription) : this.transcription; - } - - obj.name = this.name; - obj.url = this.url; - - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - }; - - return this; - -}; - -module.exports = function(name, url) { - return new Record(name, url); -} diff --git a/globeconnect/lib/voice/redirect.js b/globeconnect/lib/voice/redirect.js deleted file mode 100644 index fcf6c73..0000000 --- a/globeconnect/lib/voice/redirect.js +++ /dev/null @@ -1,41 +0,0 @@ -var Redirect = function(to) { - var obj = {}; - this.to = to; - - this.setName = function(name) { - this.name = name; - return this; - }; - - this.required = function(required) { - obj.required = required; - return this; - }; - - this.getObject = function() { - if(typeof this.to == 'undefined') { - throw new Error('To is required.'); - } - - if(typeof this.name == 'undefined') { - throw new Error('Name is required.'); - } - - obj.to = this.to; - obj.name = this.name; - - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - }; - - return this; -}; - -module.exports = function(to) { - return new Redirect(to); -} diff --git a/globeconnect/lib/voice/say.js b/globeconnect/lib/voice/say.js deleted file mode 100644 index 1dbebb4..0000000 --- a/globeconnect/lib/voice/say.js +++ /dev/null @@ -1,71 +0,0 @@ -var Say = function(value) { - var obj = {}; - this.value = value; - - this.setAs = function(as) { - obj.as = as; - return this; - }; - - this.setEvent = function(e) { - obj.event = e; - return this; - }; - - this.required = function(required) { - obj.required = required; - return this; - }; - - this.setVoice = function(voice) { - obj.voice = voice; - return this; - }; - - this.allowSignals = function(allow) { - obj.allowSignals = allow; - return this; - }; - - this.setName = function(name) { - obj.name = name; - return this; - }; - - this.getObject = function() { - if(typeof this.value == 'undefined') { - throw new Error('Value is required.'); - } - - if(typeof obj.event != 'array') { - obj.value = this.value; - - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject(); - } - - } - - return obj; - } - - var say = []; - for(var i = 0; i < obj.event.length; i++) { - if(typeof obj.event[i] == 'object' && obj.event[i].getObject == 'function') { - say[i] = obj.event[i].getObject(); - continue; - } - - say[i] = obj.event[i]; - } - - say[obj.event.length] = { value : this.value }; - return say; - } - -}; - -module.exports = function(value) { - return new Say(value); -} diff --git a/globeconnect/lib/voice/session.js b/globeconnect/lib/voice/session.js deleted file mode 100644 index fa9d554..0000000 --- a/globeconnect/lib/voice/session.js +++ /dev/null @@ -1,27 +0,0 @@ -var Session = function(json) { - var obj = {}; - - this.json = json; - - this.getObject = function() { - if(typeof this.json.session == 'undefined') { - throw new Error('Invalid json data'); - } - - for(key in this.json.session) { - obj[key] = this.json.session[key]; - } - - obj.to; - obj.from; - obj.headers; - obj.parameters; - - return obj; - } - -}; - -module.exports = function(json) { - return new Session(json); -} diff --git a/globeconnect/lib/voice/startrecording.js b/globeconnect/lib/voice/startrecording.js deleted file mode 100644 index ee6f432..0000000 --- a/globeconnect/lib/voice/startrecording.js +++ /dev/null @@ -1,59 +0,0 @@ -var StartRecording = function(url) { - var obj = {}; - this.url = url; - - this.setFormat = function(format) { - obj.format = format; - return this; - }; - - this.setMethod = function(method) { - obj.method = method; - return this; - }; - - this.setUsername = function(username) { - obj.username = username; - return this; - }; - - this.setPassword = function(password) { - obj.password = password; - return this; - }; - - this.setTranscriptionId = function(transId) { - obj.transcriptionID = transId; - return this; - }; - - this.setTranscriptionEmailFormat = function(transFormat) { - obj.transriptionEmailFormat = transFormat; - return this; - }; - - this.setTranscriptionOutUri = function(transUri) { - obj.transcriptionOutURI = transUri; - return this; - }; - - this.getObject = function() { - if(typeof this.url == 'undefined') { - throw new Error('Url is requried.'); - } - - obj.url = this.url; - - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - } -}; - -module.exports = function(url) { - return new StartRecording(url); -} diff --git a/globeconnect/lib/voice/transcription.js b/globeconnect/lib/voice/transcription.js deleted file mode 100644 index 3ad7be2..0000000 --- a/globeconnect/lib/voice/transcription.js +++ /dev/null @@ -1,29 +0,0 @@ -var Transcription = function(id) { - var obj = {}; - - this.id = id; - - this.setUrl = function(url) { - obj.url = url; - return this; - }; - - this.getObject = function() { - if(typeof this.url == 'undefined') { - throw new Error('Url is reqiored'); - } - - obj.id = this.id; - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - }; -}; - -module.exports = function(id) { - return new Wait(id); -} diff --git a/globeconnect/lib/voice/transfer.js b/globeconnect/lib/voice/transfer.js deleted file mode 100644 index d9be249..0000000 --- a/globeconnect/lib/voice/transfer.js +++ /dev/null @@ -1,106 +0,0 @@ -var Transfer = function(to) { - var obj = {}; - - this.to = to; - - this.setName = function(name) { - obj.name = name; - return this; - } - - this.setAnswerOnMedia = function(ans) { - obj.setAnswerOnMedia = ans; - return this; - }; - - this.setChoices = function(choices) { - this.choices = choices; - return this; - }; - - this.setFrom = function(from) { - obj.from = from; - return this; - }; - - this.setHeaders = function(headers) { - this.headers = headers; - return this; - }; - - this.on = function(on) { - obj.on = on; - return this; - }; - - this.required = function(required) { - obj.required = required; - return this; - }; - - this.setTerminator = function(terminator) { - obj.terminator = terminator; - return this; - }; - - this.setTimeout = function(timeout) { - obj.timeout = timeout; - return this; - }; - - this.allowSignals = function(allow) { - obj.allowSignals = allow; - return this; - }; - - this.setInterdigitTimeout = function(idtimeout) { - obj.interdigitTimeout = idtimeout; - return this; - }; - - this.ringRepeat = function(ringrepeat) { - obj.ringRepeat = ringrepeat; - return this; - }; - - this.setMachineDetection = function(mdetection) { - obj.machineDetection = mdetection; - return this; - }; - - this.getObject = function() { - if(typeof this.to == 'undefined') { - throw new Error('To is requried'); - } - - if(typeof obj.choices != 'undefined') { - obj.choices = JSON.stringify(this.choices); - } - - if(typeof obj.headers != 'undefined') { - obj.headers = JSON.stringify(this.headers); - } - - if(typeof obj.on == 'array') { - obj.on = obj.on.join(','); - } else { - if(typeof obj.on != 'undefined') { - obj.on = typeof obj.on == 'object' ? JSON.stringify(obj.on) : obj.on; - } - } - - obj.to = this.to; - - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - } -} - -module.exports = function(to, name) { - return new Transfer(to, name); -} diff --git a/globeconnect/lib/voice/wait.js b/globeconnect/lib/voice/wait.js deleted file mode 100644 index 015e563..0000000 --- a/globeconnect/lib/voice/wait.js +++ /dev/null @@ -1,29 +0,0 @@ -var Wait = function(milliseconds) { - var obj = {}; - - this.milliseconds = milliseconds; - - this.allowSignals = function(allow) { - obj.allowSignals = allow; - return this; - }; - - this.getObject = function() { - if(typeof this.milliseconds == 'undefined') { - throw new Error('Milliseconds is reqiored'); - } - - obj.milliseconds = this.milliseconds; - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() - } - } - - return obj; - }; -}; - -module.exports = function(milliseconds) { - return new Wait(milliseconds); -} diff --git a/globeconnect/tests/amax.js b/globeconnect/tests/amax.js deleted file mode 100644 index 0b53ba3..0000000 --- a/globeconnect/tests/amax.js +++ /dev/null @@ -1,4 +0,0 @@ -globe = require('../index.js'); -var amax = globe.Amax('5ozgSgeRyeHzacXo55TR65HnqoAESbAz', '3dbcd598f268268e13550c87134f8de0ec4ac1100cf0a68a2936d07fc9e2459e'); - - diff --git a/globeconnect/tests/location.js b/globeconnect/tests/location.js deleted file mode 100644 index f02e082..0000000 --- a/globeconnect/tests/location.js +++ /dev/null @@ -1,10 +0,0 @@ -globe = require('../index.js'); -var amax = globe.Location('Ppf01xq2CfCKsfu716QxoNOuiaDXaQF3n3vtLfFAfKs'); -amax.setAddress('9063389509'); -amax.setRequestedAccuracy(100); -amax.getLocation(function(resCode, body) { - console.log(resCode); - console.log(body); - console.log('DONE!'); -}); - diff --git a/globeconnect/tests/oauth.js b/globeconnect/tests/oauth.js deleted file mode 100644 index 751ea0b..0000000 --- a/globeconnect/tests/oauth.js +++ /dev/null @@ -1,5 +0,0 @@ -globe = require('../index.js'); -oauth = globe.Oauth('5ozgSgeRyeHzacXo55TR65HnqoAESbAz', '3dbcd598f268268e13550c87134f8de0ec4ac1100cf0a68a2936d07fc9e2459e'); -oauth.getAccessToken('bqsgejoAsgG7yLfEMMMksro57yCazb8oUq4AgkF7x9LdHyGp79IEydLMuAMbnGua4qBdhdnMqRsbRLbpCLXBxzC6KrA9sE4nonFzBBK6tkbkX4syBeM8tXnBEoC7kTRK77LTB8GCdXeELtAEkkMsj5Bpgtajn7oFAEr5gsyRBz7CRGLjGC6dMqLsGoqpKh5Eb5ruBRd69uLapLxIXy9KnHdpAaXFrLb5qUbj5orCzgMMBsLr7rAf6BjxRsBeLo5s', function(resCode, body) { - console.log(body); -}); diff --git a/globeconnect/tests/payment.js b/globeconnect/tests/payment.js deleted file mode 100644 index 190687e..0000000 --- a/globeconnect/tests/payment.js +++ /dev/null @@ -1,11 +0,0 @@ -globe = require('../index.js'); -payment = globe.Payment('Ppf01xq2CfCKsfu716QxoNOuiaDXaQF3n3vtLfFAfKs'); -payment.setAmount([amount]); -payment.setDescription([desciption]); -payment.setEndUserId([number]); -payment.setReferenceCode([referenceCOde]); -payment.setTransactionOperationStatus([status]); -payment.sendPaymentRequest(function(resCode, body) { - console.log(body); -}) - diff --git a/globeconnect/tests/sms.js b/globeconnect/tests/sms.js deleted file mode 100644 index 02c8790..0000000 --- a/globeconnect/tests/sms.js +++ /dev/null @@ -1,22 +0,0 @@ -globe = require('../index.js'); -var sms = globe.Sms('21584130', 'JO3SpcC-AFiC461wgOxUPDmsOTc5YiMayoK1GnQcduc'); - - -/* SEND MESSAGE */ -sms.setReceiverAddress('+639065272450'); -sms.setMessage('chawse') -sms.sendMessage(function(resCode, body){ - console.log(resCode); - console.log(body); -}); - -/* SEND BINARY MESSAGE */ -sms.setUserDataHeader('06050423F423F4'); -sms.setDataEncodingScheme(1) -sms.setReceiverAddress('+639065272450') -sms.setMessage('samplebinarymessage') -sms.sendBinaryMessage(function(resCode, body) { - console.log(resCode); - console.log(body); - console.log('DONE!'); -}) diff --git a/globeconnect/tests/subscriber.js b/globeconnect/tests/subscriber.js deleted file mode 100644 index d48df70..0000000 --- a/globeconnect/tests/subscriber.js +++ /dev/null @@ -1,6 +0,0 @@ -globe = require('../index.js'); -subscriber = globe.Subscriber('[token]'); -subscriber.setAddres('[address]'); -subscriber.getSubscriberBalance(function(resCode, body) { - console.log(body); -}); diff --git a/globeconnect/tests/ussd.js b/globeconnect/tests/ussd.js deleted file mode 100644 index e69de29..0000000 diff --git a/globeconnect/tests/voice.js b/globeconnect/tests/voice.js deleted file mode 100644 index 75ae47b..0000000 --- a/globeconnect/tests/voice.js +++ /dev/null @@ -1,85 +0,0 @@ -var globe = require(__dirname + '/../index.js'); - -// ask -var ask = globe.Voice().ask({'test' : 'test'}); -ask.setChoices({test : 'test'}); -console.log(ask.getObject()); - -// call -var call = globe.Voice().call('to'); -call.setName('name'); -console.log(call.getObject()); - -// choices -var choices = globe.Voice().choices('[5 DIGITS]'); -console.log(choices.getObject()); - -// conference -var conference = globe.Voice().conference('[id]'); -conference.setName('[name]'); -console.log(conference.getObject()); - -// join prompt -var joinPrompt = globe.Voice().joinPrompt('[value]'); -joinPrompt.setVoice('[voice]'); -console.log(joinPrompt.getObject()); - -// leave prompt -var leavePrompt = globe.Voice().leavePrompt('[value]'); -leavePrompt.setVoice('[voice]'); -console.log(leavePrompt.getObject()); - -// machine detection -var machineDetection = globe.Voice().machineDetection(); -machineDetection.setIntroduction('intro'); -machineDetection.setVoice('[voice]'); -console.log(machineDetection.getObject()); - -// message -var message = globe.Voice().message('say', 'to'); -message.setName('[name]'); -console.log(message.getObject()); - -// on -var on = globe.Voice().on('event', 'say'); -on.setName('on name') -console.log(on.getObject()); - -// record -var record = globe.Voice().record('[recordName]', '[recordUrl]'); -console.log(record.getObject()); - -// redirect -var redirect = globe.Voice().redirect('[redirect to]'); -redirect.setName('[redirect name]'); -console.log(redirect.getObject()); - - -// result -var result = globe.Voice().result({ result : {test : 'hest', foo : 'bar'}}); -console.log(result.getObject()); - -// say -var say = globe.Voice().say('[sayName]', '[sayValue]'); -say.setAs('[sayAs]'); -say.required(true); -say.setVoice('[sayVoice]'); -say.allowSignals(true); -console.log(say.getObject()); - -// session -var session = globe.Voice().session({ session : { id : '[sessionid]', etc : 'sessionetc'}}); -console.log(session.getObject()); - -// start recording -var startRecording = globe.Voice().startRecording('[recordingurl]'); -console.log(startRecording.getObject()); - -// transfer -var transfer = globe.Voice().transfer('[transferto]', '[transfername]'); -console.log(transfer.getObject()); - -// wait -var wait = globe.Voice().wait('[waitmilliseconds]'); -wait.allowSignals(true); -console.log(wait.getObject()); diff --git a/globeconnect/voiceSamples/call.js b/globeconnect/voiceSamples/call.js deleted file mode 100644 index 595226a..0000000 --- a/globeconnect/voiceSamples/call.js +++ /dev/null @@ -1,12 +0,0 @@ -var globe = require (__dirname + '/../index.js'); - -var voice = globe.Voice(); -var call = voice.call('sip:9065272450@tropo.net'); -call.from('9065272450'); - -var say = voice.say('Hellow chawse'); - -voice.addCall(call); -voice.addSay(say); -tropo = voice.getObject(); -console.log(JSON.stringify(tropo)); diff --git a/globeconnect/index.js b/index.js similarity index 99% rename from globeconnect/index.js rename to index.js index e231255..9a42b0b 100644 --- a/globeconnect/index.js +++ b/index.js @@ -7,4 +7,4 @@ module.exports = { Subscriber : require('./lib/subscriber.js'), Ussd : require('./lib/ussd.js'), Voice : require('./lib/voice.js') -} +}; diff --git a/globeconnect/lib/amax.js b/lib/amax.js similarity index 95% rename from globeconnect/lib/amax.js rename to lib/amax.js index a5d140d..5b91ace 100644 --- a/globeconnect/lib/amax.js +++ b/lib/amax.js @@ -38,7 +38,7 @@ var Amax = function(key, secret) { // store token to this this.token = token; return this; - } + }; /* * promo setter @@ -50,7 +50,7 @@ var Amax = function(key, secret) { // store promo to this this.promo = promo; return this; - } + }; /* * send reward @@ -69,7 +69,7 @@ var Amax = function(key, secret) { "app_secret" : this.secret, "rewards_token" : this.token, "address" : this.address, - "promo" : this.promo } } + "promo" : this.promo } }; // initialize curl var curl = new Curl(); @@ -78,9 +78,9 @@ var Amax = function(key, secret) { // set request as post curl.setOpt(Curl.option.POST, true); // set json header request - curl.setOpt(Curl.option.HTTPHEADER, ['Content-type: application/json']) + curl.setOpt(Curl.option.HTTPHEADER, ['Content-type: application/json']); // set request payload - curl.setOpt(Curl.option.POSTFIELDS, JSON.stringify(payload)) + curl.setOpt(Curl.option.POSTFIELDS, JSON.stringify(payload)); // perform curl curl.perform(); @@ -91,14 +91,14 @@ var Amax = function(key, secret) { // call callback function callback(resCode, body); }); - } + }; // return Amax Object return this; -} +}; // module export module.exports = function(key, secret) { // return Amax Object - return new Amax(key, secret) -} + return new Amax(key, secret); +}; diff --git a/globeconnect/lib/location.js b/lib/location.js similarity index 85% rename from globeconnect/lib/location.js rename to lib/location.js index 77ca75c..72e0bf6 100644 --- a/globeconnect/lib/location.js +++ b/lib/location.js @@ -1,6 +1,6 @@ var Curl = require('node-libcurl').Curl; -var LOC_URL = 'https://devapi.globelabs.com.ph/location/v1/queries/location?access_token=[token]&address=[address]&requestedAccuracy=[acc]' +var LOC_URL = 'https://devapi.globelabs.com.ph/location/v1/queries/location?access_token=[token]&address=[address]&requestedAccuracy=[acc]'; var Location = function(token) { this.token = token; @@ -12,15 +12,15 @@ var Location = function(token) { return this; }; - this.setRequestedAccuracy = function(acc) { - this.acc = acc; + this.setRequestedAccuracy = function(accuracy) { + this.acc = accuracy; return this; }; this.getLocation = function(callback) { url = LOC_URL.replace('[token]', this.token) .replace('[address]', this.address) - .replace('[acc]', this.acc) + .replace('[acc]', this.acc); var curl = new Curl(); curl.setOpt(Curl.option.URL, url); @@ -33,8 +33,8 @@ var Location = function(token) { }; return this; -} +}; module.exports = function(token) { return new Location(token); -} +}; diff --git a/globeconnect/lib/oauth.js b/lib/oauth.js similarity index 94% rename from globeconnect/lib/oauth.js rename to lib/oauth.js index 45cfd7b..d69619c 100644 --- a/globeconnect/lib/oauth.js +++ b/lib/oauth.js @@ -11,7 +11,7 @@ var Oauth = function(key, secret) { this.key = key; // store secret to this this.secret = secret; - // intialize variables + // initialize variables this.code = null; /* @@ -20,7 +20,7 @@ var Oauth = function(key, secret) { * @return string url auth url */ this.getRedirectUrl = function() { - // reutrn url + // return url return SUBS_URL.replace('[key]', this.key); }; @@ -42,7 +42,7 @@ var Oauth = function(key, secret) { curl.setOpt(Curl.option.URL, url); // set request as post curl.setOpt(Curl.option.POST, true); - // dont verify ssl certificate + // don't verify ssl certificate curl.setOpt(Curl.option.SSL_VERIFYPEER, false); curl.setOpt(Curl.option.SSL_VERIFYHOST, false); // perform curl @@ -56,14 +56,14 @@ var Oauth = function(key, secret) { callback(resCode, body); }); - } + }; // return Oauth Object return this; -} +}; // module export module.exports = function(key, secret) { // return Oauth Object return new Oauth(key, secret); -} +}; diff --git a/globeconnect/lib/payment.js b/lib/payment.js similarity index 96% rename from globeconnect/lib/payment.js rename to lib/payment.js index aa91c91..a435554 100644 --- a/globeconnect/lib/payment.js +++ b/lib/payment.js @@ -30,7 +30,7 @@ var Payment = function(token) { // store address to this this.address = address; return this; - } + }; /* * amount setter @@ -42,7 +42,7 @@ var Payment = function(token) { // store amount to this this.amount = amount; return this; - } + }; /* * description setter @@ -54,7 +54,7 @@ var Payment = function(token) { // store desc to this this.desc = desc; return this; - } + }; /* * reference code setter @@ -66,7 +66,7 @@ var Payment = function(token) { // store refCode to this this.refCode = refCode; return this; - } + }; /* * status setter @@ -78,7 +78,7 @@ var Payment = function(token) { // store status to this this.status = status; return this; - } + }; /* * app key setter @@ -90,7 +90,7 @@ var Payment = function(token) { // store appKey to this this.key = appKey; return this; - } + }; /* * app secret setter @@ -100,9 +100,9 @@ var Payment = function(token) { */ this.setAppSecret = function(secret) { // store secret to this - this.secret; + this.secret = secret; return this; - } + }; /* * get last reference code @@ -129,7 +129,7 @@ var Payment = function(token) { // call callback function callback(resCode, body); }); - } + }; /* * send payment request @@ -151,7 +151,7 @@ var Payment = function(token) { // http_build_query payload = qs.toString(payload); - // intialize curl + // initialize curl var curl = new Curl(); // set request url curl.setOpt(curl.option.URL, url); @@ -168,16 +168,16 @@ var Payment = function(token) { this.close(); // call callback function callback(resCode, body); - }) - } + }); + }; // return Object Payment return this; -} +}; // module exports module.exports = function(token) { // return Payment Object return new Payment(token); -} +}; diff --git a/globeconnect/lib/sms.js b/lib/sms.js similarity index 97% rename from globeconnect/lib/sms.js rename to lib/sms.js index e235a22..3447183 100644 --- a/globeconnect/lib/sms.js +++ b/lib/sms.js @@ -70,7 +70,7 @@ var Sms = function(sender, token) { /* * encoding setter * - * @param string endcoding data encoding scheme + * @param string encoding data encoding scheme * @return object this */ this.setDataEncodingScheme = function(encoding) { @@ -104,9 +104,9 @@ var Sms = function(sender, token) { // set request as post curl.setOpt(Curl.option.POST, true); // set json request header - curl.setOpt(Curl.option.HTTPHEADER, ['Content-type: application/json']) + curl.setOpt(Curl.option.HTTPHEADER, ['Content-type: application/json']); // set payload - curl.setOpt(Curl.option.POSTFIELDS, JSON.stringify(payload)) + curl.setOpt(Curl.option.POSTFIELDS, JSON.stringify(payload)); // perform curl curl.perform(); @@ -149,9 +149,9 @@ var Sms = function(sender, token) { // set request as post curl.setOpt(Curl.option.POST, true); // set json request header - curl.setOpt(Curl.option.HTTPHEADER, ['Content-type: application/json']) + curl.setOpt(Curl.option.HTTPHEADER, ['Content-type: application/json']); // set request payload - curl.setOpt(Curl.option.POSTFIELDS, JSON.stringify(payload)) + curl.setOpt(Curl.option.POSTFIELDS, JSON.stringify(payload)); // perform curl curl.perform(); @@ -167,10 +167,10 @@ var Sms = function(sender, token) { // return Sms object return this; -} +}; // module export module.exports = function(sender, token) { // export Sms object - return new Sms(sender, token) -} + return new Sms(sender, token); +}; diff --git a/globeconnect/lib/subscriber.js b/lib/subscriber.js similarity index 100% rename from globeconnect/lib/subscriber.js rename to lib/subscriber.js diff --git a/globeconnect/lib/ussd.js b/lib/ussd.js similarity index 93% rename from globeconnect/lib/ussd.js rename to lib/ussd.js index e10f4b9..b3ef719 100644 --- a/globeconnect/lib/ussd.js +++ b/lib/ussd.js @@ -12,7 +12,7 @@ var Ussd = function(token, shortCode) { // store shortCode to this this.shortCode = shortCode; - // intialize variables + // initialize variables this.address = null; this.flash = false; this.msg = null; @@ -74,7 +74,7 @@ var Ussd = function(token, shortCode) { */ this.sendUssdRequest = function(callback) { // prepare request url - var url = SEND_USSD.replace('[shortcode]', this.shortCode) + var url = SEND_USSD.replace('[shortCode]', this.shortCode) .replace('[token]', this.token); // prepare request payload @@ -84,10 +84,10 @@ var Ussd = function(token, shortCode) { message : this.msg }, address : this.address, - senderAddress : this.shortcode, + senderAddress : this.shortCode, flash : this.flash }}; - // intialize curl + // initialize curl var curl = new Curl(); // set request url curl.setOpt(curl.option.URL, url); @@ -117,7 +117,7 @@ var Ussd = function(token, shortCode) { */ this.replyUssdRequest = function(callback) { // prepare request url - var url = REPLY_USSD.replace('[shortcode]', this.shortCode) + var url = REPLY_USSD.replace('[shortCode]', this.shortCode) .replace('[token]', this.token); // prepare request payload @@ -126,11 +126,11 @@ var Ussd = function(token, shortCode) { outboundUSSDMessage : { message : this.msg}, address : this.address, - senderAddress : this.shortcode, + senderAddress : this.shortCode, sessionID : this.session, flash : this.flash }}; - // intialize curl + // initialize curl var curl = new Curl(); // set request url curl.setOpt(curl.option.URL, url); diff --git a/lib/voice.js b/lib/voice.js new file mode 100644 index 0000000..39aced8 --- /dev/null +++ b/lib/voice.js @@ -0,0 +1,157 @@ +var Voice = function () { + this.obj = {}; + this.ask = require(path.join(__dirname, "/voice/ask.js")); + this.addAsk = function (obj) { + addAbstract.call(this, 'ask', obj); + return this; + }; + + this.call = require(path.join(__dirname, "/voice/call.js")); + this.addCall = function (obj) { + addAbstract.call(this, 'call', obj); + return this; + }; + + this.choices = require(path.join(__dirname, "/voice/choices.js")); + this.addChoices = function (obj) { + addAbstract.call(this, 'choices', obj); + return this; + }; + + this.conference = require(path.join(__dirname, "/voice/conference.js")); + this.addConference = function (obj) { + addAbstract.call(this, 'conference', obj); + return this; + }; + + this.joinPrompt = require(path.join(__dirname, "/voice/joinprompt.js")); + this.addJoinPrompt = function (obj) { + addAbstract.call(this, 'joinPrompt', obj); + return this; + }; + + this.leavePrompt = require(path.join(__dirname, "/voice/leaveprompt.js")); + this.addLeavePrompt = function (obj) { + addAbstract.call(this, 'leavePrompt', obj); + return this; + }; + + this.machineDetection = require( + path.join(__dirname, "/voice/machinedetection.js") + ); + this.addMachineDetection = function (obj) { + addAbstract.call(this, 'machineDetection', obj); + return this; + }; + + this.message = require(path.join(__dirname, "/voice/message.js")); + this.addMessage = function (obj) { + addAbstract.call(this, 'message', obj); + return this; + }; + + this.on = require(path.join(__dirname, "/voice/on.js")); + this.addOn = function (obj) { + addAbstract.call(this, 'on', obj); + return this; + }; + + this.record = require(path.join(__dirname, "/voice/record.js")); + this.addRecord = function (obj) { + addAbstract.call(this, 'record', obj); + return this; + }; + + this.redirect = require(path.join(__dirname, "/voice/redirect.js")); + this.addRedirect = function (obj) { + addAbstract.call(this, 'redirect', obj); + return this; + }; + + this.result = require(path.join(__dirname, "/voice/result.js")); + this.addResult = function (obj) { + addAbstract.call(this, 'result', obj); + return this; + }; + + this.say = require(path.join(__dirname, "/voice/say.js")); + this.addSay = function (obj) { + addAbstract.call(this, 'say', obj); + return this; + }; + + this.session = require(path.join(__dirname, "/voice/session.js")); + this.addSession = function (obj) { + addAbstract.call(this, 'session', obj); + return this; + }; + + this.startRecording = require( + path.join(__dirname, "/voice/startrecording.js") + ); + this.addStartRecording = function (obj) { + addAbstract.call(this, 'startRecording', obj); + return this; + }; + + this.transcription = require( + path.join(__dirname, "/voice/tanscription.js") + ); + this.addTranscription = function (obj) { + addAbstract.call(this, 'transcription', obj); + return this; + }; + + this.transfer = require(path.join(__dirname, "/voice/transfer.js")); + this.addTransfer = function (obj) { + addAbstract.call(this, 'transfer', obj); + return this; + }; + + this.wait = require(path.join(__dirname, "/voice/wait.js")); + this.addWait = function (obj) { + addAbstract.call(this, 'wait', obj); + return this; + }; + + this.addHangup = function () { + addAbstract.call(this, 'hangup', {}); + }; + + this.addReject = function () { + addAbstract.call(this, 'reject', {}); + }; + + addAbstract = function (key, obj) { + if (typeof obj === 'object' && typeof obj.getObject === 'function') { + obj = obj.getObject(); + } + + addToTropo.call(this, key, obj); + }; + + initTropo = function () { + if (typeof this.obj.tropo === 'undefined') { + this.obj.tropo = []; + } + }; + + addToTropo = function (key, obj) { + initTropo.call(this); + var i = this.obj.tropo.length; + + this.obj.tropo[i] = {}; + this.obj.tropo[i][key] = {}; + this.obj.tropo[i][key] = obj; + }; + + this.getObject = function () { + return this.obj; + }; + + return this; +}; + +module.exports = function () { + return new Voice(); +}; \ No newline at end of file diff --git a/lib/voice/ask.js b/lib/voice/ask.js new file mode 100644 index 0000000..619f144 --- /dev/null +++ b/lib/voice/ask.js @@ -0,0 +1,103 @@ +var Ask = function (say) { + var obj = {}; + this.say = say; + + this.setChoices = function (choices) { + this.choices = choices; + return this; + }; + + this.setMaxAttempt = function (attempt) { + obj.attempt = attempt; + return this; + }; + + this.setBargain = function (bargain) { + obj.bargain = bargain; + return this; + }; + + this.setMinConfidence = function (confidence) { + obj.confidence = confidence; + return this; + }; + + this.setName = function (name) { + obj.name = name; + return this; + }; + + this.setRecognizer = function (recognizer) { + obj.recognizer = recognizer; + return this; + }; + + this.setTimeout = function (timeout) { + obj.timeout = timeout; + return this; + }; + + this.setVoice = function (voice) { + obj.voice = voice; + return this; + }; + + this.setEnterDigitTimeout = function (idTimeout) { + obj.EnterDigitTimeout = idTimeout; + return this; + }; + + this.setSensitivity = function (sensitivity) { + obj.sensitivity = sensitivity; + return this; + }; + + this.setSpeechCompleteTimeout = function (scTimeout) { + obj.speechCompleteTimeout = scTimeout; + return this; + }; + + this.setSpeechIncompleteTimeout = function (siTimeout) { + obj.speechIncompleteTimeout = siTimeout; + return this; + }; + + this.getObject = function () { + if (typeof this.choices === 'undefined') { + throw new Error('Choices is required.'); + } + + if (typeof this.say === 'undefined') { + throw new Error('Say is required.'); + } + + obj.choices = this.say.event === null ? + this.choices : JSON.stringify(this.choices, rmNull); + obj.say = this.say.event === null ? + this.say : JSON.stringify(this.say, rmNull); + + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; + + rmNull = function (key, value) { + if (value === null) { + return undefined; + } + + return value; + }; + +}; + +module.exports = function (say) { + return new Ask(say); +}; \ No newline at end of file diff --git a/lib/voice/call.js b/lib/voice/call.js new file mode 100644 index 0000000..d06fe7a --- /dev/null +++ b/lib/voice/call.js @@ -0,0 +1,88 @@ +var Call = function (to) { + var obj = {}; + + this.to = to; + + this.setName = function (name) { + obj.name = name; + return this; + }; + + this.setAnswerToMedia = function (ansMedia) { + obj.answerToMedia = ansMedia; + return this; + }; + + this.setChannel = function (channel) { + obj.channel = channel; + return this; + }; + + this.from = function (from) { + obj.from = from; + return this; + }; + + this.setHeaders = function (headers) { + obj.headers = headers; + return this; + }; + + this.setRecording = function (recording) { + obj.recording = recording; + return this; + }; + + this.required = function (required) { + obj.required = required; + return this; + }; + + this.setTimeout = function (timeout) { + obj.timeout = timeout; + return this; + }; + + this.allSignals = function (signal) { + obj.allowSignals = signal; + return this; + }; + + this.setMachineDetection = function (mDetection) { + obj.machineDetection = mDetection; + return this; + }; + + this.getObject = function () { + if (typeof this.to === 'undefined') { + throw new Error('to is required'); + } + + obj.to = this.to; + + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; + + rmNull = function (key, value) { + if (value === null) { + return undefined; + } + + return value; + }; + + return this; +}; + +module.exports = function (to) { + return new Call(to); +}; \ No newline at end of file diff --git a/lib/voice/choices.js b/lib/voice/choices.js new file mode 100644 index 0000000..a96ff5e --- /dev/null +++ b/lib/voice/choices.js @@ -0,0 +1,44 @@ +var Choices = function (value) { + var obj = {}; + + if (typeof this.value !== 'undefined') { + this.value = value; + } + + this.setMode = function (mode) { + obj.mode = mode; + return this; + }; + + this.setTerminator = function (terminator) { + obj.terminator = terminator; + return this; + }; + + this.getObject = function () { + if (typeof this.value === 'undefined') { + throw new Error('Choices value is required'); + } + + if (typeof this.value !== 'undefined') { + obj.value = this.value; + } + + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; + + return this; +}; + +module.exports = function (value) { + return new Choices(value); +}; \ No newline at end of file diff --git a/lib/voice/conference.js b/lib/voice/conference.js new file mode 100644 index 0000000..90c63f0 --- /dev/null +++ b/lib/voice/conference.js @@ -0,0 +1,79 @@ +var Conference = function (id) { + var obj = {}; + this.id = id; + + this.mute = function (mute) { + obj.mute = mute; + return this; + }; + + this.setName = function (name) { + this.name = name; + return this; + }; + + this.setPlayTones = function (playTones) { + obj.playTones = playTones; + return this; + }; + + this.required = function (required) { + obj.required = required; + return this; + }; + + this.setTerminator = function (terminator) { + obj.terminator = terminator; + return this; + }; + + this.allowSignals = function (allowSignals) { + obj.allowSignals = allowSignals; + return this; + }; + + this.setEnterDigitTimeout = function (idTimeout) { + obj.EnterDigitTimeout = idTimeout; + return this; + }; + + this.setJoinPrompt = function (jPrompt) { + obj.jPrompt = jPrompt; + return this; + }; + + this.setLeavePrompt = function (lPrompt) { + obj.leavePrompt = lPrompt; + return this; + }; + + this.getObject = function () { + if (typeof this.id === 'undefined') { + throw new Error('Conference id is required.'); + } + + if (typeof this.name === 'undefined') { + throw new Error('Conference name is required.'); + } + + obj.id = this.id; + obj.name = this.name; + + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; + + return this; +}; + +module.exports = function (id) { + return new Conference(id); +}; \ No newline at end of file diff --git a/globeconnect/lib/voice/hangup.js b/lib/voice/hangup.js similarity index 100% rename from globeconnect/lib/voice/hangup.js rename to lib/voice/hangup.js diff --git a/lib/voice/joinprompt.js b/lib/voice/joinprompt.js new file mode 100644 index 0000000..a3d0794 --- /dev/null +++ b/lib/voice/joinprompt.js @@ -0,0 +1,34 @@ +var JoinPrompt = function (value) { + var obj = {}; + this.value = value; + + this.setVoice = function (voice) { + obj.voice = voice; + return this; + }; + + this.getObject = function () { + if (typeof this.value === 'undefined') { + throw new Error('Join Prompt is required.'); + } + + obj.value = this.value; + + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; + + return this; +}; + +module.exports = function (value) { + return new JoinPrompt(value); +}; \ No newline at end of file diff --git a/lib/voice/leaveprompt.js b/lib/voice/leaveprompt.js new file mode 100644 index 0000000..a36ebd0 --- /dev/null +++ b/lib/voice/leaveprompt.js @@ -0,0 +1,33 @@ +var LeavePrompt = function (value) { + var obj = {}; + this.value = value; + + this.setVoice = function (voice) { + obj.voice = voice; + return this; + }; + + this.getObject = function () { + if (typeof this.value === 'undefined') { + throw new Error('Leave Prompt is required.'); + } + + obj.value = this.value; + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; + + return this; +}; + +module.exports = function (value) { + return new LeavePrompt(value); +}; \ No newline at end of file diff --git a/lib/voice/machinedetection.js b/lib/voice/machinedetection.js new file mode 100644 index 0000000..f6495d8 --- /dev/null +++ b/lib/voice/machinedetection.js @@ -0,0 +1,31 @@ +var machineDetection = function () { + var obj = {}; + this.setIntroduction = function (introduction) { + obj.introduction = introduction; + return this; + }; + + this.setVoice = function (voice) { + obj.voice = voice; + return this; + }; + + this.getObject = function () { + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; + + return this; +}; + +module.exports = function () { + return new machineDetection(); +}; \ No newline at end of file diff --git a/globeconnect/lib/voice/message.js b/lib/voice/message.js similarity index 55% rename from globeconnect/lib/voice/message.js rename to lib/voice/message.js index c6d5e81..16741fb 100644 --- a/globeconnect/lib/voice/message.js +++ b/lib/voice/message.js @@ -1,58 +1,58 @@ -var Message = function(say, to) { +var Message = function (say, to) { var obj = {}; this.say = say; this.to = to; - this.setName = function(name) { + this.setName = function (name) { this.name = name; return this; }; - this.answerOnMedia = function(ansMedia) { + this.answerOnMedia = function (ansMedia) { obj.answerOnMedia = ansMedia; return this; }; - this.setChannel = function(channel) { + this.setChannel = function (channel) { obj.channel = channel; return this; }; - this.from = function(from) { + this.from = function (from) { obj.from = from; return this; }; - this.setNetwork = function(network) { + this.setNetwork = function (network) { obj.network = network; return this; }; - this.required = function(required) { + this.required = function (required) { obj.required = required; return this; }; - this.setTimeout = function(timeout) { + this.setTimeout = function (timeout) { obj.timeout = timeout; return this; }; - this.setVoice = function(voice) { + this.setVoice = function (voice) { obj.voice = voice; return this; }; - this.getObject = function() { - if(typeof this.say == 'undefined') { + this.getObject = function () { + if (typeof this.say === 'undefined') { throw new Error('say is required'); } - if(typeof this.to == 'undefined') { + if (typeof this.to === 'undefined') { throw new Error('to is required'); } - if(typeof this.name == 'undefined') { + if (typeof this.name === 'undefined') { throw new Error('Name is required'); } @@ -60,9 +60,12 @@ var Message = function(say, to) { obj.to = this.to; obj.say = this.say; - for(var key in obj) { - if(typeof obj[key] == 'object' && typeof obj[key].getObject == 'function') { - obj[key] = obj[key].getObject() + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); } } @@ -73,6 +76,6 @@ var Message = function(say, to) { }; -module.exports = function(say, to) { +module.exports = function (say, to) { return new Message(say, to); -} +}; \ No newline at end of file diff --git a/lib/voice/on.js b/lib/voice/on.js new file mode 100644 index 0000000..c6240b4 --- /dev/null +++ b/lib/voice/on.js @@ -0,0 +1,71 @@ +var On = function (e) { + var obj = {}; + this.event = e; + + this.setSay = function (say) { + this.say = say; + return this; + }; + + this.setName = function (name) { + this.name = name; + return this; + }; + + this.next = function (next) { + obj.next = next; + return this; + }; + + this.required = function (required) { + obj.required = required; + return this; + }; + + this.ask = function (ask) { + obj.ask = ask; + return this; + }; + + this.setMessage = function (message) { + obj.message = message; + return this; + }; + + this.wait = function (wait) { + obj.wait = wait; + return this; + }; + + this.getObject = function () { + if (typeof this.event === 'undefined') { + throw new Error('Event is required'); + } + + if (typeof this.say === 'undefined') { + throw new Error('Say is required'); + } + + obj.event = this.event; + obj.name = this.name; + obj.say = typeof this.say === 'object' ? + JSON.stringify(this.say) : this.say; + + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; + + return this; +}; + +module.exports = function (e, say) { + return new On(e, say); +}; \ No newline at end of file diff --git a/lib/voice/record.js b/lib/voice/record.js new file mode 100644 index 0000000..f6d57fd --- /dev/null +++ b/lib/voice/record.js @@ -0,0 +1,131 @@ +var Record = function (name, url) { + var obj = {}; + + this.name = name; + this.url = url; + + this.setAttempts = function (attempts) { + obj.attempts = attempts; + return this; + }; + + this.setBargain = function (bargain) { + obj.bargain = bargain; + return this; + }; + + this.setBeep = function (beep) { + obj.beep = beep; + return this; + }; + + this.setChoices = function (choices) { + obj.choices = choices; + return this; + }; + + this.setFormat = function (format) { + obj.format = format; + return this; + }; + + this.setMaxSilence = function (silence) { + obj.maxSilence = silence; + return this; + }; + + this.setMaxTime = function (maxTime) { + obj.maxTime = maxTime; + return this; + }; + + this.setMethod = function (method) { + obj.method = method; + return this; + }; + + this.setMinConfidence = function (minConfidence) { + obj.minConfidence = minConfidence; + return this; + }; + + this.required = function (required) { + obj.required = required; + return this; + }; + + this.say = function (say) { + obj.say = say; + return this; + }; + + this.setTimeout = function (timeout) { + obj.timeout = timeout; + return this; + }; + + this.setTranscription = function (transcription) { + this.transcription = transcription; + return this; + }; + + + this.setPassword = function (password) { + obj.password = password; + return this; + }; + + this.setUsername = function (username) { + obj.username = username; + return this; + }; + + this.setVoice = function (voice) { + obj.voice = voice; + return this; + }; + + this.allowSignals = function (allowSignals) { + obj.allowSignals = allowSignals; + return this; + }; + + this.setEnterDigitTimeout = function (idTimeout) { + obj.enterDigitTimeout = idTimeout; + return this; + }; + + this.getObject = function () { + if (typeof this.name === 'undefined') { + throw new Error('Name is required.'); + } + + if (typeof this.url === 'undefined') { + throw new Error('Url is required.'); + } + + if (typeof this.transcription !== 'undefined') { + obj.transcription = typeof this.transcription === 'object' ? + JSON.stringify(this.transcription) : this.transcription; + } + + obj.name = this.name; + obj.url = this.url; + + for (var key in obj) { + if (typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function') { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; + + return this; + +}; + +module.exports = function (name, url) { + return new Record(name, url); +}; \ No newline at end of file diff --git a/lib/voice/redirect.js b/lib/voice/redirect.js new file mode 100644 index 0000000..e7ac3c3 --- /dev/null +++ b/lib/voice/redirect.js @@ -0,0 +1,44 @@ +var Redirect = function (to) { + var obj = {}; + this.to = to; + + this.setName = function (name) { + this.name = name; + return this; + }; + + this.required = function (required) { + obj.required = required; + return this; + }; + + this.getObject = function () { + if (typeof this.to === 'undefined') { + throw new Error('To is required.'); + } + + if (typeof this.name === 'undefined') { + throw new Error('Name is required.'); + } + + obj.to = this.to; + obj.name = this.name; + + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; + + return this; +}; + +module.exports = function (to) { + return new Redirect(to); +}; \ No newline at end of file diff --git a/globeconnect/lib/voice/result.js b/lib/voice/result.js similarity index 53% rename from globeconnect/lib/voice/result.js rename to lib/voice/result.js index c158128..8939c36 100644 --- a/globeconnect/lib/voice/result.js +++ b/lib/voice/result.js @@ -1,13 +1,13 @@ -var Result = function(json) { +var Result = function (json) { var obj = {}; this.json = json; - this.getObject = function() { - if(typeof this.json.result == 'undefined') { + this.getObject = function () { + if (typeof this.json.result === 'undefined') { throw new Error('Invalid json data'); } - for(key in this.json.result) { + for (var key in this.json.result) { obj[key] = this.json.result[key]; } @@ -17,6 +17,6 @@ var Result = function(json) { return this; }; -module.exports = function(json) { +module.exports = function (json) { return new Result(json); -} +}; \ No newline at end of file diff --git a/lib/voice/say.js b/lib/voice/say.js new file mode 100644 index 0000000..5a1d8dd --- /dev/null +++ b/lib/voice/say.js @@ -0,0 +1,79 @@ +var Say = function (value) { + var obj = {}; + this.value = value; + + this.setAs = function (as) { + obj.as = as; + return this; + }; + + this.setEvent = function (e) { + obj.event = e; + return this; + }; + + this.required = function (required) { + obj.required = required; + return this; + }; + + this.setVoice = function (voice) { + obj.voice = voice; + return this; + }; + + this.allowSignals = function (allow) { + obj.allowSignals = allow; + return this; + }; + + this.setName = function (name) { + obj.name = name; + return this; + }; + + this.getObject = function () { + if (typeof this.value === 'undefined') { + throw new Error('Value is required.'); + } + + if (!Array.isArray(obj.event)) { + obj.value = this.value; + + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + + } + + return obj; + } + + var say = []; + for (var i = 0; i < obj.event.length; i++) { + if ( + typeof obj.event[i] === 'object' && + obj.event[i].getObject === 'function' + ) { + say[i] = obj.event[i].getObject(); + continue; + } + + say[i] = obj.event[i]; + } + + say[obj.event.length] = { + value: this.value + }; + return say; + }; + +}; + +module.exports = function (value) { + return new Say(value); +}; \ No newline at end of file diff --git a/lib/voice/session.js b/lib/voice/session.js new file mode 100644 index 0000000..10e2903 --- /dev/null +++ b/lib/voice/session.js @@ -0,0 +1,27 @@ +var Session = function (json) { + var obj = {}; + + this.json = json; + + this.getObject = function () { + if (typeof this.json.session === 'undefined') { + throw new Error('Invalid json data'); + } + + for (var key in this.json.session) { + obj[key] = this.json.session[key]; + } + + obj.to = to; + obj.from = from; + obj.headers = headers; + obj.parameters = parameters; + + return obj; + }; + +}; + +module.exports = function (json) { + return new Session(json); +}; \ No newline at end of file diff --git a/lib/voice/startrecording.js b/lib/voice/startrecording.js new file mode 100644 index 0000000..e280d39 --- /dev/null +++ b/lib/voice/startrecording.js @@ -0,0 +1,62 @@ +var StartRecording = function (url) { + var obj = {}; + this.url = url; + + this.setFormat = function (format) { + obj.format = format; + return this; + }; + + this.setMethod = function (method) { + obj.method = method; + return this; + }; + + this.setUsername = function (username) { + obj.username = username; + return this; + }; + + this.setPassword = function (password) { + obj.password = password; + return this; + }; + + this.setTranscriptionId = function (transId) { + obj.transcriptionID = transId; + return this; + }; + + this.setTranscriptionEmailFormat = function (transFormat) { + obj.transcriptionEmailFormat = transFormat; + return this; + }; + + this.setTranscriptionOutUri = function (transUri) { + obj.transcriptionOutURI = transUri; + return this; + }; + + this.getObject = function () { + if (typeof this.url === 'undefined') { + throw new Error('Url is required.'); + } + + obj.url = this.url; + + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; +}; + +module.exports = function (url) { + return new StartRecording(url); +}; \ No newline at end of file diff --git a/lib/voice/transcription.js b/lib/voice/transcription.js new file mode 100644 index 0000000..41f98ce --- /dev/null +++ b/lib/voice/transcription.js @@ -0,0 +1,32 @@ +var Transcription = function (id) { + var obj = {}; + + this.id = id; + + this.setUrl = function (url) { + obj.url = url; + return this; + }; + + this.getObject = function () { + if (typeof this.url === 'undefined') { + throw new Error('Url is required'); + } + + obj.id = this.id; + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; +}; + +module.exports = function (id) { + return new Wait(id); +}; \ No newline at end of file diff --git a/lib/voice/transfer.js b/lib/voice/transfer.js new file mode 100644 index 0000000..278b861 --- /dev/null +++ b/lib/voice/transfer.js @@ -0,0 +1,110 @@ +var Transfer = function (to) { + var obj = {}; + + this.to = to; + + this.setName = function (name) { + obj.name = name; + return this; + }; + + this.setAnswerOnMedia = function (ans) { + obj.setAnswerOnMedia = ans; + return this; + }; + + this.setChoices = function (choices) { + this.choices = choices; + return this; + }; + + this.setFrom = function (from) { + obj.from = from; + return this; + }; + + this.setHeaders = function (headers) { + this.headers = headers; + return this; + }; + + this.on = function (on) { + obj.on = on; + return this; + }; + + this.required = function (required) { + obj.required = required; + return this; + }; + + this.setTerminator = function (terminator) { + obj.terminator = terminator; + return this; + }; + + this.setTimeout = function (timeout) { + obj.timeout = timeout; + return this; + }; + + this.allowSignals = function (allow) { + obj.allowSignals = allow; + return this; + }; + + this.setEnterDigitTimeout = function (idTimeout) { + obj.enterDigitTimeout = idTimeout; + return this; + }; + + this.ringRepeat = function (ringRepeat) { + obj.ringRepeat = ringRepeat; + return this; + }; + + this.setMachineDetection = function (mDetection) { + obj.machineDetection = mDetection; + return this; + }; + + this.getObject = function () { + if (typeof this.to === 'undefined') { + throw new Error('To is required'); + } + + if (typeof obj.choices !== 'undefined') { + obj.choices = JSON.stringify(this.choices); + } + + if (typeof obj.headers !== 'undefined') { + obj.headers = JSON.stringify(this.headers); + } + + if (Array.isArray(obj.on)) { + obj.on = obj.on.join(','); + } else { + if (typeof obj.on !== 'undefined') { + obj.on = typeof obj.on === 'object' ? + JSON.stringify(obj.on) : obj.on; + } + } + + obj.to = this.to; + + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; +}; + +module.exports = function (to, name) { + return new Transfer(to, name); +}; \ No newline at end of file diff --git a/lib/voice/wait.js b/lib/voice/wait.js new file mode 100644 index 0000000..e688289 --- /dev/null +++ b/lib/voice/wait.js @@ -0,0 +1,32 @@ +var Wait = function (milliseconds) { + var obj = {}; + + this.milliseconds = milliseconds; + + this.allowSignals = function (allow) { + obj.allowSignals = allow; + return this; + }; + + this.getObject = function () { + if (typeof this.milliseconds === 'undefined') { + throw new Error('Milliseconds is required'); + } + + obj.milliseconds = this.milliseconds; + for (var key in obj) { + if ( + typeof obj[key] === 'object' && + typeof obj[key].getObject === 'function' + ) { + obj[key] = obj[key].getObject(); + } + } + + return obj; + }; +}; + +module.exports = function (milliseconds) { + return new Wait(milliseconds); +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..51c304a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,893 @@ +{ + "name": "globe-connect", + "version": "0.0.2", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, + "ajv": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" + }, + "are-we-there-yet": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", + "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "chownr": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.2.tgz", + "integrity": "sha512-GkfeAQh+QNy3wquu9oIZr6SS5x7wGdSgNQvD10X3r+AZr1Oys22HW8kAmDMvNg2+Dm0TeGaEuO8gFwdBXxwO8A==" + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" + }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "fs-extra": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fs-minipass": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz", + "integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==", + "requires": { + "minipass": "^2.2.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore-walk": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", + "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", + "requires": { + "minimatch": "^3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "requires": { + "mime-db": "1.40.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "minipass": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.5.0.tgz", + "integrity": "sha512-9FwMVYhn6ERvMR8XFdOavRz4QK/VJV8elU1x50vYexf9lslDcWe/f4HBRxCPd185ekRSjU6CfYyJCECa/CQy7Q==", + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", + "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", + "requires": { + "minipass": "^2.2.1" + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "nan": { + "version": "2.13.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", + "integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==" + }, + "needle": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz", + "integrity": "sha512-4Hnwzr3mi5L97hMYeNl8wRW/Onhy4nUKR/lVemJ8gJedxxUyBLm9kkrDColJvoSfwi0jCNhD+xCdOtiGDQiRZg==", + "requires": { + "debug": "^3.2.6", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, + "node-gyp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-4.0.0.tgz", + "integrity": "sha512-2XiryJ8sICNo6ej8d0idXDEMKfVfFK7kekGCtJAuelGsYHQxhj13KTf95swTCN2dZ/4lTfZ84Fu31jqJEEgjWA==", + "requires": { + "glob": "^7.0.3", + "graceful-fs": "^4.1.2", + "mkdirp": "^0.5.0", + "nopt": "2 || 3", + "npmlog": "0 || 1 || 2 || 3 || 4", + "osenv": "0", + "request": "^2.87.0", + "rimraf": "2", + "semver": "~5.3.0", + "tar": "^4.4.8", + "which": "1" + } + }, + "node-libcurl": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/node-libcurl/-/node-libcurl-2.0.1.tgz", + "integrity": "sha512-HFEdU130GZVeezJKtvw3eLNBTENVC6EqMZu7gpBAfY9MYNSgtRObEP1E+iPOlBmJesljyWf27XVqcfzXtyMAGw==", + "requires": { + "fs-extra": "7.0.1", + "nan": "2.13.2", + "node-gyp": "4.0.0", + "node-pre-gyp": "0.13.0", + "npmlog": "4.1.2", + "osenv": "0.1.5", + "tslib": "^1.9.3" + } + }, + "node-pre-gyp": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.13.0.tgz", + "integrity": "sha512-Md1D3xnEne8b/HGVQkZZwV27WUi1ZRuZBij24TNaZwUPU3ZAFtvT6xxJGaUVillfmMKnn5oD1HoGsp2Ftik7SQ==", + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + }, + "dependencies": { + "nopt": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + } + } + }, + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "requires": { + "abbrev": "1" + } + }, + "npm-bundled": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", + "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==" + }, + "npm-packlist": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.4.tgz", + "integrity": "sha512-zTLo8UcVYtDU3gdeaFu2Xu0n0EvelfHDGuqtNIn5RO7yQj4H1TqNdBc/yZjxnWA0PVB8D3Woyp0i5B43JwQ6Vw==", + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + }, + "osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "psl": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.3.0.tgz", + "integrity": "sha512-avHdspHO+9rQTLbv1RO+MPYeP/SzsCoxofjVnHanETfQhTJrmB0HlDoW+EiN/R+C0BZ+gERab9NY0lPN2TxNag==" + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + } + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, + "semver": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=" + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "tar": { + "version": "4.4.10", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.10.tgz", + "integrity": "sha512-g2SVs5QIxvo6OLp0GudTqEf05maawKUxXru104iaayWA09551tFCTI8f1Asb4lPfkBr91k07iL4c11XO3/b0tA==", + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.5", + "minizlib": "^1.2.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.3" + } + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + } + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "requires": { + "punycode": "^2.1.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "uuid": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", + "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==" + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "requires": { + "isexe": "^2.0.0" + } + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + } + } +} diff --git a/globeconnect/package.json b/package.json similarity index 74% rename from globeconnect/package.json rename to package.json index 8e79488..7cde4bc 100644 --- a/globeconnect/package.json +++ b/package.json @@ -15,11 +15,11 @@ "author": "clark galgo ", "license": "ISC", "dependencies": { - "node-libcurl": "1.0.0" + "node-libcurl": "^2.0.1" }, "homepage": "https://github.com/globelabs/globe-connect-nodejs", - "bugs" : { - "url" : "https://github.com/globelabs/globe-connect-nodejs/issues", - "email" : "globelabs@globe.com.ph" + "bugs": { + "url": "https://github.com/globelabs/globe-connect-nodejs/issues", + "email": "globelabs@globe.com.ph" } }