diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0e068ac --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "search.exclude": { + "**/node_modules": false, + "**/bower_components": true + } +} \ No newline at end of file diff --git a/AllCoinZ/Alexa.js b/AllCoinZ/Alexa.js new file mode 100644 index 0000000..00290b2 --- /dev/null +++ b/AllCoinZ/Alexa.js @@ -0,0 +1,1054 @@ +const Util = require('../AllCoinZ/util') +var Alexa = require('alexa-sdk'); +const dynamoDB = require('../db/dynamoDB'); + +const GenProc = require('../AllCoinZ/GenericProcess') +const jsCoin = require('../AllCoinZ/jsonCoin'); +const languageStrings = { + 'en': { + translation: { + SKILL_NAME: 'Smart Crypto', + HELP_MESSAGE: 'You can ask me to tell value of crypto coin, or, you can say exit... What can I help you with?', + HELP_REPROMPT: 'What can I help you with?', + STOP_MESSAGE: 'Goodbye! Have a good day.', + LAUNCH_MESSAGE: 'Hello Welcome to Smart Crypto !!! Say help for getting assistance or Say a coin name ', + LAUNCH_MESSAGE_REPROMPT: 'Tell me a coin name for it\'s value or say help.' + + }, + } +}; + + +const APP_ID = undefined; + + + +const skillName = "Smart Crypto"; + +const COIN_SELECT_MESSAGE = [{ + MSG: 'Which coin would you like to select next ?' +}, { + MSG: 'Which coin would you like to try next' +}, { + MSG: 'Which crypto coin next ?' +}] + +var SAMPLE_COINS = [{ + CoinName: "Bitcoin" +}, { + CoinName: "Ripple" +}, { + CoinName: "Ethereum" +}, { + CoinName: "Cardano" +}] +var SAMPLE_CURRENCIES = [{ + Currency: "INR" +}, { + Currency: "USD" +}, { + Currency: "EURO" +}, { + Currency: "CNY" +}] + +var WELCOME_MESSAGE = "Welcome to " + skillName + " !! \n " + getGenericHelpMessage() // 'Get crypto currency values in local currencies and manage portfolios . For example, " + getGenericHelpMessage() + " or Say help for available commands "; +var HELP_MESSAGE = "I can help you find the value of a crypto coin or manage your portfolio."; +var NEW_SEARCH_MESSAGE = getGenericHelpMessage(); +var SEARCH_STATE_HELP_MESSAGE = getGenericHelpMessage(); +const SHUTDOWN_MESSAGE = "Ok. Thank you for using " + skillName + " Wish you a good day "; +const EXIT_SKILL_MESSAGE = "Ok. Thank you for using " + skillName + " Wish you a good day " + + +const states = { + SearchUpdateMODE: "_SearchUpdateMODE", + RESULTS: "_RESULTS", + MULTIPLE_RESULTS: "_MULTIPLE_RESULTS", + UPDATE: "_UPDATE" +}; + +const newSessionHandlers = { + "LaunchRequest": function () { + this.handler.state = states.SearchUpdateMODE; + this.response.speak(WELCOME_MESSAGE).listen(getGenericHelpMessage()); + this.emit(':responseReady'); + }, + "GetCoinValueByCountIntent": function () { + console.log("SEARCH INTENT"); + this.handler.state = states.SearchUpdateMODE; + this.emitWithState("GetCoinValueByCountIntent"); + }, + "GetCoinValueByDecimalIntent": function () { + this.handler.state = states.SearchUpdateMODE; + this.emitWithState("GetCoinValueByDecimalIntent"); + }, + "UpdateCoinByCountIntent": function () { + this.handler.state = states.SearchUpdateMODE; + this.emitWithState("UpdateCoinByCountIntent"); + }, + "UpdateCoinByDecimalIntent": function () { + this.handler.state = states.SearchUpdateMODE; + this.emitWithState("UpdateCoinByDecimalIntent"); + }, + "ChangeCurrencyIntent": function () { + this.handler.state = states.SearchUpdateMODE; + this.emitWithState("ChangeCurrencyIntent"); + }, + "PortfolioIntent": function () { + this.handler.state = states.SearchUpdateMODE; + this.emitWithState("PortfolioIntent"); + }, + "TellMeMoreIntent": function () { + this.handler.state = states.SearchUpdateMODE; + this.response.speak(WELCOME_MESSAGE).listen(getGenericHelpMessage()); + this.emit(':responseReady'); + }, + "TellCoinValueIntent": function () { + this.handler.state = states.SearchUpdateMODE; + this.emitWithState("GetCoinValueByCountIntent"); + }, + "AMAZON.YesIntent": function () { + this.response.speak(getGenericHelpMessage()).listen(getGenericHelpMessage()); + this.emit(':responseReady'); + }, + "AMAZON.NoIntent": function () { + this.response.speak(SHUTDOWN_MESSAGE); + this.emit(':responseReady'); + }, + "AMAZON.RepeatIntent": function () { + this.response.speak(HELP_MESSAGE).listen(getGenericHelpMessage()); + this.emit(':responseReady'); + }, + "AMAZON.StopIntent": function () { + this.response.speak(EXIT_SKILL_MESSAGE); + this.emit(':responseReady'); + }, + "AMAZON.CancelIntent": function () { + this.response.speak(EXIT_SKILL_MESSAGE); + this.emit(':responseReady'); + }, + "AMAZON.StartOverIntent": function () { + this.handler.state = states.SearchUpdateMODE; + var output = "Ok, starting over." + getGenericHelpMessage(); + this.response.speak(output).listen(output); + this.emit(':responseReady'); + }, + 'AMAZON.HelpIntent': function () { + const imageObj = { + smallImageUrl: 'https://i.imgur.com/yXARQuc.png', + largeImageUrl: 'https://i.imgur.com/yXARQuc.png' + }; + const help = 'To change the default currency say "Set currency to USD" ' + + ' \n\n To add a coin to portfolio say "Add 1.23 XRP" ' + + ' \n\n To reduce a coin count from portfolio say "Deduct 0.23 BCH" ' + + ' \n\n To delete a coin from portfolio say "Delete 2 XRP" ' + + ' \n\n To get the portfolio ask What\'s my portfolio? ' + this.attributes.lastSearch = {} + this.attributes.lastSearch.lastSpeech = help + const speechOutput = this.t('LAUNCH_MESSAGE'); + const repromptOutput = "Please say a coin name or say help" + + this.emit(':askWithCard', help, repromptOutput, this.t('SKILL_NAME'), removeSSML(help), imageObj) + //this.emit(':askWithCard', help, repromptOutput, this.t('SKILL_NAME'), removeSSML(speechOutput)); + }, + "SessionEndedRequest": function () { + this.emit("AMAZON.StopIntent"); + }, + "Unhandled": function () { + this.handler.state = states.SearchUpdateMODE; + this.emitWithState("GetCoinValueByCountIntent"); + } +}; +var searchUpdateHandlers = Alexa.CreateStateHandler(states.SearchUpdateMODE, { + "AMAZON.YesIntent": function () { + this.response.speak(NEW_SEARCH_MESSAGE).listen(NEW_SEARCH_MESSAGE); + this.emit(':responseReady'); + }, + "AMAZON.NoIntent": function () { + this.response.speak(SHUTDOWN_MESSAGE); + this.emit(':responseReady'); + }, + "AMAZON.RepeatIntent": function () { + var output; + if (this.attributes.lastSearch && this.attributes.lastSearch.lastSpeech != undefined) { + output = this.attributes.lastSearch.lastSpeech; + } else { + output = getGenericHelpMessage(); + } + this.emit(":ask", output, output); + }, + "GetCoinValueByCountIntent": function () { + GetCoinValueByCountIntentHandler.call(this); + }, + "GetCoinValueByDecimalIntent": function () { + GetCoinValueByDecimalIntentHandler.call(this); + }, + "UpdateCoinByCountIntent": function () { + confirmPortfolioUpdate.call(this); + }, + "UpdateCoinByDecimalIntent": function () { + confirmPortfolioUpdate.call(this); + }, + "ChangeCurrencyIntent": function () { + ChangeCurrencyIntentHandler.call(this); + }, + "PortfolioIntent": function () { + PortfolioHandler.call(this); + }, + "TellChangeCurrencyIntent": function () { + this.handler.state = states.RESULTS; + this.emitWithState("TellChangeCurrencyIntent"); + }, + "TellPortfolioIntent": function () { + this.handler.state = states.RESULTS; + this.emitWithState("TellPortfolioIntent"); + }, + "TellCoinUpdateIntent": function () { + this.handler.state = states.RESULTS; + this.emitWithState("TellCoinUpdateIntent"); + }, + "TellCoinValueIntent": function () { + this.handler.state = states.RESULTS; + this.emitWithState("TellCoinValueIntent"); + }, + "TellMeMoreIntent": function () { + this.handler.state = states.RESULTS; + this.emitWithState("TellMeMoreIntent"); + }, + 'AMAZON.HelpIntent': function () { + const imageObj = { + smallImageUrl: 'https://i.imgur.com/yXARQuc.png', + largeImageUrl: 'https://i.imgur.com/yXARQuc.png' + }; + const help = 'To change the default currency say "Set currency to USD" ' + + ' \n\n To add a coin to portfolio say "Add 1.23 XRP" ' + + ' \n\n To reduce a coin count from portfolio say "Deduct 0.23 BCH" ' + + ' \n\n To delete a coin from portfolio say "Delete 2 XRP" ' + + ' \n\n To get the portfolio ask What\'s my portfolio? ' + + const speechOutput = this.t('LAUNCH_MESSAGE'); + const repromptOutput = "Please say a coin name or say help" + this.attributes.lastSearch = {} + this.attributes.lastSearch.lastSpeech = help + this.emit(':askWithCard', help, repromptOutput, this.t('SKILL_NAME'), removeSSML(help), imageObj) + //this.emit(':askWithCard', help, repromptOutput, this.t('SKILL_NAME'), removeSSML(speechOutput)); + }, + "AMAZON.StopIntent": function () { + this.response.speak(EXIT_SKILL_MESSAGE); + this.emit(':responseReady'); + }, + "AMAZON.CancelIntent": function () { + this.response.speak(EXIT_SKILL_MESSAGE); + this.emit(':responseReady'); + }, + "AMAZON.StartOverIntent": function () { + this.handler.state = states.SearchUpdateMODE; + var output = "Ok, starting over." + getGenericHelpMessage(); + this.response.speak(output).listen(output); + this.emit(':responseReady'); + }, + "SessionEndedRequest": function () { + this.emit("AMAZON.StopIntent"); + }, + "Unhandled": function () { + console.log("Unhandled intent in startSearchHandlers"); + this.response.speak(SEARCH_STATE_HELP_MESSAGE).listen(SEARCH_STATE_HELP_MESSAGE); + this.emit(':responseReady'); + } +}); + +function PortfolioHandler() { + + var self = this; + const uniqID = this.event.context.System.user.userId + + dynamoDB.g_getRecord({ + uniqID: uniqID + }).then(function (result) { + var myPortfolio; + if (result != null) { + myPortfolio = result.portfolio; + } + if (result == null || myPortfolio == null) { + var intentRequest = ' ' + "Say a coin name" + return self.emit(':askWithCard', "Your portfolio is empty .Please create a new portfolio. Check help for commands or " + intentRequest, "Your portfolio is empty .Please create a new portfolio. Check help !!!", self.t('SKILL_NAME'), "Your portfolio is empty .Please create a new portfolio. Check help for commands !!!"); + } + if (result.curr == null) { + Util.m_myCurrency == "INR" + } else { + Util.m_myCurrency = result.curr; + } + var jsonPortfolioParse = JSON.parse(myPortfolio) + var oPortFolioLatestData = GenProc.m_getPortFolioCoinData(jsonPortfolioParse, Util.m_myCurrency) + oPortFolioLatestData.then(function (myportFolioData) { + console.log('total') + + var myCoins = jsonPortfolioParse; + var currency = Util.m_myCurrency + var TotalDetails = ""; + + var priceinBTC = 0; + var priceinCurrency = 0; + var totalBTC = 0; + var totalCurrency = 0; + var displayCurrency; + var displayBTC; + + var BaseLinkUrl = "https://www.cryptocompare.com"; + var cryptoCoin = ""; + var link; + var ilink + var description; + + for (const coin of Object.keys(myCoins)) { + + if (myCoins[coin] <= 0) { + continue + } + cryptoCoin = jsCoin.m_findCoin(coin.toUpperCase());; + + + link = BaseLinkUrl + cryptoCoin[0].u; + ilink = BaseLinkUrl + cryptoCoin[0].iu; + + + priceinBTC = (myportFolioData.RAW[coin]["BTC"].PRICE * myCoins[coin]).toFixed(9) + priceinCurrency = (myportFolioData.RAW[coin][currency].PRICE * myCoins[coin]).toFixed(2) + //description = priceinCurrency + "" + myportFolioData.DISPLAY[coin][currency].TOSYMBOL + " |" + " " + priceinBTC + "" + myportFolioData.DISPLAY[coin]["BTC"].TOSYMBOL + + TotalDetails = TotalDetails + "" + (+myCoins[coin]).toFixed(3) + " " + coin + " equivalent to " + priceinCurrency + myportFolioData.DISPLAY[coin][currency].TOSYMBOL + "\n" + + + displayCurrency = myportFolioData.DISPLAY[coin][currency].TOSYMBOL + displayBTC = myportFolioData.DISPLAY[coin]["BTC"].TOSYMBOL + + totalBTC = +totalBTC + +priceinBTC + totalCurrency = +totalCurrency + +priceinCurrency + } + const imageObj = { + smallImageUrl: 'https://i.imgur.com/yXARQuc.png', + largeImageUrl: 'https://i.imgur.com/yXARQuc.png' + }; + if (cryptoCoin == '') { + var intentRequest = ' ' + " Say a coin name" + self.emit(':askWithCard', "Your portfolio is empty .Please create a new portfolio. Check help for commands or " + intentRequest, "Your portfolio is empty .Please create a new portfolio. Check help !!!", self.t('SKILL_NAME'), "Your portfolio is empty .Please create a new portfolio. Check help for commands !!!"); + return //sendPortfolioUpdate("Please create a new portfolio. Check help !!!"); + } + + var summaryDetails = "Total Portfolio Value: " + totalCurrency.toFixed(3) + " " + displayCurrency + " equivalent to " + totalBTC.toFixed(5) + " " + displayBTC + "\n\n" + //summaryDetails = summaryDetails + TotalDetails; + + var lastSearch = self.attributes.lastSearch = { + summaryDetails: summaryDetails, + TotalDetails: TotalDetails + } + self.attributes.lastSearch.lastIntent = "PortfolioIntent"; + self.attributes.lastSearch.lastIntentStatus = "PortfolioIntentPending" + self.emitWithState("TellPortfolioIntent"); + + //console.log("\n*[TPV]: " + " " + totalCurrency.toFixed(3) + " " + displayCurrency + " | " + totalBTC.toFixed(9) + " " + displayBTC) + + }).catch(function (err) { + return deferred.reject(false); + }) + + }) +} + +const availablecurrencies = ['TRY', 'KRW', 'SGD', 'VND', 'INR', 'RSD', 'QAR', 'JMD', 'UAH', 'TZS', 'RUB', 'BHD', 'SEK', 'UYU', 'IRR', 'USD', 'NZD', 'BAM', 'TOP', 'JPY', 'BYR', 'TWD', 'HRK', 'ILS', 'GBP', 'HNL', 'PLN', 'XAF', 'GHS', 'CZK', 'CUC', 'ETB', 'NGN', 'SZL', 'LKR', 'CHF', 'BBD', 'DOP', 'NAD', 'EUR', 'KHR', 'SBD', 'MZN', 'HKD', 'ARS', 'PEN', 'MWK', 'LBP', 'MOP', 'JPY', 'RWF', 'CLP', 'PYG', 'BTN', 'MGA', 'MAD', 'PGK', 'KGS', 'HUF', 'SVC', 'USD', 'MVR', 'MMK', 'GIP', 'AED', 'CHF', 'CAD', 'MXN', 'AUD', 'BGN', 'LSL', 'THB', 'NPR', 'ISK', 'RON', 'PKR', 'TTD', 'DZD', 'PHP', 'PAB', 'BIF', 'NOK', 'MYR', 'MUR', 'NIO', 'VUV', 'GTQ', 'EUR', 'CRC', 'OMR', 'UGX', 'AZN', 'EGP'] + +function isInArray(value, array) { + return array.indexOf(value) > -1; +} + +function ChangeCurrencyIntentHandler() { + var userCurrency = isSlotValid(this.event.request, "myCurrency"); + const uniqID = this.event.context.System.user.userId; + + var self = this; + + + + if (userCurrency == false) { + this.emit(':ask', 'Currency could not be identified.No changes are made.') + return; + } + userCurrency = userCurrency.toUpperCase(); + isValidCurrency = isInArray(userCurrency, availablecurrencies) + if (isValidCurrency == false) { + + this.emit(':ask', 'Currency could not be identified. Please say currencies short name like USD or EUR or INR or AUD ') + return; + } + + dynamoDB.g_UpdateInsert({ + displayName: "", + uniqID: uniqID, + curr: userCurrency + }).then(function () { + var lastSearch = self.attributes.lastSearch = { + + } + self.attributes.lastSearch.lastSpeech = "Default currency has been set to " + userCurrency + self.attributes.lastSearch.lastIntent = "TellChangeCurrencyIntent"; + self.emitWithState("TellChangeCurrencyIntent"); + + }, function (error) { + console.log(error) + }) +} + + + +function UpdateCoinByCountIntentHandler() { + var cryptoCoinValue = isSlotValid(this.attributes.lastSearch.speechOutput, "Coins"); + var inputcountSlotValue = isSlotValid(this.attributes.lastSearch.speechOutput, "Count"); + var decimalSlotValue = isSlotValid(this.attributes.lastSearch.speechOutput, "Decimal"); + var buySellSlotValue = isSlotValid(this.attributes.lastSearch.speechOutput, "BuySell"); + + var UsrePortfolio; + + var inputcountSlotValue; + var decimalSlotValue; + var self = this; + + var coinShortName = jsCoin.m_findCoin(cryptoCoinValue.toUpperCase()); + if (coinShortName == undefined || coinShortName == null || coinShortName.length == 0) { + var intentRequest = ' ' + getRandomValues(COIN_SELECT_MESSAGE, "MSG") + return this.emit(':askWithCard', "Coin cannot be identified . Try with a valid coin name " + intentRequest, "Coin cannot be identified . Try with a valid coin name " + intentRequest) + } else { + + cryptoCoinValue = coinShortName[0].n.toUpperCase() + + } + + + + + + if (inputcountSlotValue != false) { + inputcountSlotValue = parseInt(inputcountSlotValue); + if (isNaN(inputcountSlotValue)) { + inputcountSlotValue = 0; + } + } + if (decimalSlotValue != false) { + decimalSlotValue = parseInt(decimalSlotValue); + if (isNaN(decimalSlotValue)) { + decimalSlotValue = 0; + } else { + decimalSlotValue = '.' + decimalSlotValue + } + } + + inputcountSlotValue = +inputcountSlotValue + +decimalSlotValue; + + var userRequestedOption; + switch (buySellSlotValue.toUpperCase()) { + case "ADD": + case "BUY [+]": + case "ADD[+]": + case "ADD COIN": + case "B": + case "BUY": + userRequestedOption = "ADD"; + break; + case "REMOVE": + case "DELETE": + inputcountSlotValue = ""; + userRequestedOption = "DELETE"; + break; + case "SELL": + case "S": + case "REDUCE": + case "DEDUCT": + userRequestedOption = "DEDUCT"; + break; + default: + break; + } + + const uniqID = this.event.context.System.user.userId; + const displayName = ""; + dynamoDB.g_getRecord({ + uniqID: uniqID + }).then(function (item) { + var coinQuantity; + var updatedQuantity + var updatetext = ""; + if (userRequestedOption == "ADD") { + updatetext = "added" + } else if (userRequestedOption == "DEDUCT") { + updatetext = "deducted" + } else if (userRequestedOption == "DELETE") { + updatetext = "deleted" + updatedQuantity = 0; + } + if (item == null) { + updatedQuantity = inputcountSlotValue + userInfoData = { + displayName: displayName, + uniqID: uniqID, + curr: "INR", + portfolio: JSON.stringify({ + [cryptoCoinValue]: inputcountSlotValue + }) + } + } else { + var currentPortfolio; + if (item.portfolio) { currentPortfolio = JSON.parse(item.portfolio) } + if (currentPortfolio != null) { + if (currentPortfolio[cryptoCoinValue] == undefined) { + currentPortfolio[cryptoCoinValue] = inputcountSlotValue; + } else { + //var updatedQuantity = 1; + coinQuantity = currentPortfolio[cryptoCoinValue] + if (userRequestedOption == "ADD") { + updatedQuantity = +inputcountSlotValue + +coinQuantity; + } else if (userRequestedOption == "DEDUCT") { + updatedQuantity = +coinQuantity - inputcountSlotValue; + } else if (userRequestedOption == "DELETE") { + updatedQuantity = 0; + } + if (updatedQuantity < 0) { + updatedQuantity = 0; + } + currentPortfolio[cryptoCoinValue] = updatedQuantity + } + userInfoData = { + displayName: item.displayName, + uniqID: item.uniqID, + curr: item.curr, + portfolio: JSON.stringify(currentPortfolio) + } + } else { + userInfoData = { + displayName: "", + uniqID: uniqID, + curr: "INR", + portfolio: JSON.stringify({ + [cryptoCoinValue]: inputcountSlotValue + }) + } + } + } + var currentValue = inputcountSlotValue + if (updatedQuantity != undefined) { + currentValue = updatedQuantity + } + if (userRequestedOption == "DELETE") { + currentValue = 0; + } + dynamoDB.g_UpdateInsert(userInfoData).then(function () { + + var responseMessage = inputcountSlotValue + " " + cryptoCoinValue.toUpperCase() + " has been " + updatetext + " !!!\nAvailable " + cryptoCoinValue.toUpperCase() + " : " + currentValue + self.handler.state = states.SearchUpdateMODE; + self.attributes.lastSearch = {} //.lastSpeech = responseMessage; + var repromptSpeech = getRandomValues(COIN_SELECT_MESSAGE, "MSG"); + + var intentRequest = ' ' + getRandomValues(COIN_SELECT_MESSAGE, "MSG") + + self.response.speak(responseMessage + intentRequest).listen(repromptSpeech).cardRenderer("Portfolio Update :", removeSSML(responseMessage)) + self.emit(':responseReady'); + + }, function (error) { + //deferred.reject(error) + }) + }) + +} + +function confirmPortfolioUpdate() { + var cryptoCoinValue = isSlotValid(this.event.request, "Coins"); + var inputcountSlotValue = isSlotValid(this.event.request, "Count"); + var decimalSlotValue = isSlotValid(this.event.request, "Decimal"); + var buySellSlotValue = isSlotValid(this.event.request, "BuySell"); + + + + var slotsFilled = cryptoCoinValue && inputcountSlotValue && buySellSlotValue + if (buySellSlotValue != false && cryptoCoinValue != false && (buySellSlotValue.toUpperCase() == "REMOVE" || buySellSlotValue.toUpperCase() == "DELETE")) { + slotsFilled = true; + } + if (slotsFilled != false) { + var coinShortName = jsCoin.m_findCoin(cryptoCoinValue.toUpperCase()); + if (coinShortName == undefined || coinShortName == null || coinShortName.length == 0) { + var intentRequest = ' ' + getRandomValues(COIN_SELECT_MESSAGE, "MSG") + return this.emit(':askWithCard', "Coin cannot be identified . Try with a valid coin name " + intentRequest, "Coin cannot be identified . Try with a valid coin name " + intentRequest) + } else { + + cryptoCoinValue = coinShortName[0].n.toUpperCase() + + } + if (inputcountSlotValue != false) { + inputcountSlotValue = parseInt(inputcountSlotValue); + if (isNaN(inputcountSlotValue)) { + inputcountSlotValue = 0; + } + } + if (decimalSlotValue != false) { + decimalSlotValue = parseInt(decimalSlotValue); + if (isNaN(decimalSlotValue)) { + decimalSlotValue = 0; + } else { + decimalSlotValue = '.' + decimalSlotValue + } + } + + inputcountSlotValue = +inputcountSlotValue + +decimalSlotValue; + var buysell = buySellSlotValue.toUpperCase(); + + if (buysell.indexOf('DEL') > -1 || buysell.indexOf('REM') > -1) { + inputcountSlotValue = ""; + } + const speechOutput = 'You would like to ' + buysell + ' ' + inputcountSlotValue + ' ' + + cryptoCoinValue.toUpperCase() + ', is that correct?'; + + var lastSearch = this.attributes.lastSearch = { + speechOutput: this.event.request, + lastIntent : "UpdateCoinByCountIntent", + lastIntentStatus : "UpdateCoinByCountIntentPending", + lastSpeech : speechOutput + } + + // this.attributes.lastSearch.lastIntent = "UpdateCoinByCountIntent"; + // this.attributes.lastSearch.lastIntentStatus = "UpdateCoinByCountIntentPending" + // this.attributes.lastSearch.lastSpeech = speechOutput + + this.response.speak(speechOutput).listen(speechOutput); + this.handler.state = states.RESULTS; + this.emit(':responseReady'); + + + } else { + + if (buySellSlotValue != false) { + speechOutput = "You can say " + buySellSlotValue + " 10 BITCOIN or " + buySellSlotValue + " 10 Ripple or say cancel " + + } else { + speechOutput = "Unknown command. Please try with the available commands or say a valid coin name." + } + this.handler.state = states.SearchUpdateMODE; + this.response.speak(speechOutput).listen(speechOutput); + + this.emit(':responseReady'); + } +} + + +function repeatSlot() { + + + +} + +function GetCoinValueByCountIntentHandler() { + + if (this.attributes.lastSearch != undefined) { + if (this.attributes.lastSearch.lastIntentStatus != undefined) { + if (this.attributes.lastSearch.lastIntentStatus.toUpperCase() == "UPDATECOINBYCOUNTINTENTPENDING") { + this.attributes.lastSearch.lastIntentStatus = "" + UpdateCoinByCountIntentHandler.call(this); + return; + } + if (this.attributes.lastSearch.lastIntentStatus.toUpperCase() == "PORTFOLIOINTENTPENDING") { + this.attributes.lastSearch.lastIntentStatus = "" + this.handler.state = states.RESULTS; + this.emitWithState("TellMeMoreIntent") + return + } + + } + } + + + + var cryptoCoin = isSlotValid(this.event.request, "Coins"); + var inputcount = isSlotValid(this.event.request, "Count"); + var decimal = isSlotValid(this.event.request, "Decimal"); + + const uniqID = this.event.context.System.user.userId; + var self = this; + var inputcount; + var decimal; + + if (cryptoCoin != false) { + cryptoCoin = jsCoin.m_findCoin(cryptoCoin.toUpperCase()); + } + if (cryptoCoin == false || cryptoCoin == undefined) { + var output = "Coin cannot be identified Try with a valid coin name " + ' ' + getRandomValues(COIN_SELECT_MESSAGE, "MSG") + this.response.speak(output).listen(output); + return this.emit(':responseReady'); + //return self.emit(':askWithCard', "Coin cannot be identified . Try with a valid coin name ", "Coin cannot be identified . Try with a valid coin name ", this.t('SKILL_NAME'), "Coin cannot be identified . Try with a valid coin name ") + } + if (isNaN(inputcount) || inputcount == false) { + inputcount = 1; + } + if (decimal != false) { + if (isNaN(decimal)) { + decimal = 0; + } else { + decimal = '.' + decimal + } + } + inputcount = +inputcount + +decimal; + + Util.m_getCurrency(uniqID).then(function () { + var count = 1; + if (inputcount != null) { + count = inputcount + } + var oCoin; + oCoin = Util.m_getCoinObject({ + count: count, + CryptoCoin: cryptoCoin, + found: true + }); + oCoin.then(function (coinResult) { + var result = []; + result.push(coinResult) + var lastSearch = self.attributes.lastSearch = { + //results: result + }; + var output; + + //self.attributes.lastSearch.lastIntent = "GetCoinValueByCountIntent"; + //self.emitWithState("TellCoinValueIntent"); + var CoinInfo = coinResult; + + var speechOutput; + var repromptSpeech; + var cardContent; + + cardContent = generateCoinCard(CoinInfo) + speechOutput = generateCoinMessage(CoinInfo) + repromptSpeech = "Would you like to selet another coin ? Say yes or no"; + self.handler.state = states.SearchUpdateMODE; + self.attributes.lastSearch.lastSpeech = speechOutput; + self.response.cardRenderer(cardContent.title, cardContent.body, cardContent.image); + self.response.speak(speechOutput).listen(repromptSpeech); + self.emit(':responseReady'); + + + + + + }).catch(function (err) { + console.log("m_getCurrency method failed" + err) + self.response.speak(generateSearchResultsMessage(searchQuery, false)).listen(generateSearchResultsMessage(searchQuery, false)); + + }); + }) +} + + + +var descriptionHandlers = Alexa.CreateStateHandler(states.RESULTS, { + + + "TellMeNoIntent": function () { + if (this.attributes.lastSearch.lastIntent.toUpperCase() == "UPDATECOINBYCOUNTINTENT") { + speechOutput = "Ok. I am cancelling the portfolio update " + getRandomValues(COIN_SELECT_MESSAGE, "MSG") + repromptSpeech = " The portfolio update has been cancelled" + getRandomValues(COIN_SELECT_MESSAGE, "MSG") + this.handler.state = states.SearchUpdateMODE; + this.response.speak(speechOutput).listen(repromptSpeech); + this.emit(':responseReady'); + } else { + speechOutput = "Ok. " + getRandomValues(COIN_SELECT_MESSAGE, "MSG") + repromptSpeech = "" + getRandomValues(COIN_SELECT_MESSAGE, "MSG") + this.handler.state = states.SearchUpdateMODE; + this.response.speak(speechOutput).listen(repromptSpeech); + this.emit(':responseReady'); + } + }, + "TellMeMoreIntent": function () { + var speechOutput; + var repromptSpeech; + var cardContent; + if (this.attributes.lastSearch != undefined && this.attributes.lastSearch.lastIntent != undefined) { + if (this.attributes.lastSearch.lastIntent.toUpperCase() == "PORTFOLIOINTENT") { + var speechOutput = this.attributes.lastSearch.TotalDetails; + this.handler.state = states.SearchUpdateMODE; + this.attributes.lastSearch.lastSpeech = speechOutput; + repromptSpeech = getRandomValues(COIN_SELECT_MESSAGE, "MSG"); + this.response.speak("My portfolio coins are " + speechOutput + " " + repromptSpeech).listen(repromptSpeech).cardRenderer("My Portfolio Detailed View :", removeSSML(speechOutput.replace('equivalent to', '='))) + this.emit(':responseReady') + + } else if (this.attributes.lastSearch.lastIntent.toUpperCase() == "UPDATECOINBYCOUNTINTENT") { + + UpdateCoinByCountIntentHandler.call(this); + + } + } else { + speechOutput = getGenericHelpMessage(); + repromptSpeech = getGenericHelpMessage(); + this.handler.state = states.SearchUpdateMODE; + this.response.speak(speechOutput).listen(repromptSpeech); + this.emit(':responseReady'); + } + }, + "TellPortfolioIntent": function () { + var responseMessage = this.attributes.lastSearch.summaryDetails; + this.handler.state = states.RESULTS; + this.attributes.lastSearch.lastSpeech = responseMessage + " Would you like to hear the split wise details ?"; + this.response.speak(responseMessage + " Would you like to hear the split wise details ?").listen("Would you like to hear split wise details or Say a coin name.").cardRenderer("My Portfolio :", removeSSML(responseMessage)) + this.emit(':responseReady') + + + }, + "TellChangeCurrencyIntent": function () { + var responseMessage = this.attributes.lastSearch.lastSpeech; + this.handler.state = states.SearchUpdateMODE; + + var repromptSpeech = getRandomValues(COIN_SELECT_MESSAGE, "MSG"); + + + var intentRequest = ' ' + getRandomValues(COIN_SELECT_MESSAGE, "MSG") + this.attributes.lastSearch.lastSpeech = responseMessage + intentRequest; + this.response.speak(responseMessage + intentRequest).listen(repromptSpeech).cardRenderer("Currency Update :", responseMessage) + this.emit(':responseReady'); + + }, + + "TellCoinUpdateIntent": function () { + + var responseMessage = this.attributes.lastSearch; + this.handler.state = states.SearchUpdateMODE; + this.attributes.lastSearch.lastSpeech = responseMessage; + var repromptSpeech = getRandomValues(COIN_SELECT_MESSAGE, "MSG"); + this.response.speak(responseMessage).listen(repromptSpeech).cardRenderer("Portfolio Update :", responseMessage) + this.emit(':responseReady'); + } + + , + "TellCoinValueIntent": function () { + var CoinInfo = this.attributes.lastSearch.results[0]; + var infoType = isSlotValid(this.event.request, "infoType"); + var speechOutput; + var repromptSpeech; + var cardContent; + + cardContent = generateCoinCard(CoinInfo) + speechOutput = generateCoinMessage(CoinInfo) + repromptSpeech = "Would you like to selet another coin? Say yes or no"; + this.handler.state = states.SearchUpdateMODE; + this.attributes.lastSearch.lastSpeech = speechOutput; + this.response.cardRenderer(cardContent.title, cardContent.body, cardContent.image); + this.response.speak(speechOutput).listen(repromptSpeech); + this.emit(':responseReady'); + }, + "GetCoinValueByCountIntent": function () { + GetCoinValueByCountIntentHandler.call(this); + }, + + 'AMAZON.HelpIntent': function () { + const imageObj = { + smallImageUrl: 'https://i.imgur.com/yXARQuc.png', + largeImageUrl: 'https://i.imgur.com/yXARQuc.png' + }; + const help = 'To change the default currency say "Set currency to USD" ' + + ' \n\n To add a coin to portfolio say "Add 1.23 XRP" ' + + ' \n\n To reduce a coin count from portfolio say "Deduct 0.23 BCH" ' + + ' \n\n To delete a coin from portfolio say "Delete 2 XRP" ' + + ' \n\n To get the portfolio ask What\'s my portfolio? ' + + const speechOutput = this.t('LAUNCH_MESSAGE'); + const repromptOutput = "Please say a coin name or say help" + this.attributes.lastSearch = {} + this.attributes.lastSearch.lastSpeech = help + this.emit(':askWithCard', help, repromptOutput, this.t('SKILL_NAME'), removeSSML(help), imageObj) + //this.emit(':askWithCard', help, repromptOutput, this.t('SKILL_NAME'), removeSSML(speechOutput)); + }, + "AMAZON.StopIntent": function () { + this.response.speak(EXIT_SKILL_MESSAGE); + this.emit(':responseReady'); + }, + "AMAZON.CancelIntent": function () { + this.response.speak(EXIT_SKILL_MESSAGE); + this.emit(':responseReady'); + }, + "AMAZON.NoIntent": function () { + this.handler.state = states.RESULTS; + this.emitWithState("TellMeNoIntent"); + }, + "AMAZON.YesIntent": function () { + this.handler.state = states.RESULTS; + this.emitWithState("TellMeMoreIntent"); + }, + "AMAZON.RepeatIntent": function () { + this.response.speak(this.attributes.lastSearch.lastSpeech).listen(this.attributes.lastSearch.lastSpeech); + this.emit(':responseReady'); + }, + "AMAZON.StartOverIntent": function () { + this.handler.state = states.SearchUpdateMODE; + var output = "Ok, starting over." + getGenericHelpMessage(); + this.response.speak(output).listen(output); + this.emit(':responseReady'); + }, + "SessionEndedRequest": function () { + this.emit("AMAZON.StopIntent"); + }, + "GetCoinValueByCountIntent": function () { + // if (this.attributes.lastSearch) { + // this.attributes.lastSearch.lastIntent = ""; + // this.attributes.lastSearch.lastIntentStatus = "" + // } + GetCoinValueByCountIntentHandler.call(this); + }, + "GetCoinValueByDecimalIntent": function () { + // if (this.attributes.lastSearch) { + // this.attributes.lastSearch.lastIntent = ""; + // this.attributes.lastSearch.lastIntentStatus = "" + // } + GetCoinValueByDecimalIntentHandler.call(this); + }, + "UpdateCoinByCountIntent": function () { + if (this.attributes.lastSearch) { + this.attributes.lastSearch.lastIntent = ""; + this.attributes.lastSearch.lastIntentStatus = "" + } + confirmPortfolioUpdate.call(this); + }, + "UpdateCoinByDecimalIntent": function () { + if (this.attributes.lastSearch) { + this.attributes.lastSearch.lastIntent = ""; + this.attributes.lastSearch.lastIntentStatus = "" + } + confirmPortfolioUpdate.call(this); + }, + "ChangeCurrencyIntent": function () { + if (this.attributes.lastSearch) { + this.attributes.lastSearch.lastIntent = ""; + this.attributes.lastSearch.lastIntentStatus = "" + } + ChangeCurrencyIntentHandler.call(this); + }, + "PortfolioIntent": function () { + if (this.attributes.lastSearch) { + this.attributes.lastSearch.lastIntent = ""; + this.attributes.lastSearch.lastIntentStatus = "" + } + PortfolioHandler.call(this); + }, + "Unhandled": function () { + console.log("Unhandled intent in startSearchHandlers"); + this.response.speak(SEARCH_STATE_HELP_MESSAGE).listen(SEARCH_STATE_HELP_MESSAGE); + this.emit(':responseReady'); + } +}); + + +function generateCoinCard(CoinInfo) { + var coinInfoinCurrency = CoinInfo.CoinValue.DISPLAY[CoinInfo.CoinSN][CoinInfo.CoinCurrency] + var coinInfoinBTC = CoinInfo.CoinValue.DISPLAY[CoinInfo.CoinSN]["BTC"] + var currencyPrice = Util.m_removeCurrencySymbols(coinInfoinCurrency) + var BTCPrice = Util.m_removeCurrencySymbols(coinInfoinBTC) + var content = " \n " + CoinInfo.CoinCount + " " + CoinInfo.CoinSN + " = " + (CoinInfo.CoinCount * currencyPrice).toFixed(5) + " " + coinInfoinCurrency.TOSYMBOL + "" + + " \n " + CoinInfo.CoinCount + "" + CoinInfo.CoinSN + " = " + (CoinInfo.CoinCount * BTCPrice).toFixed(9) + " " + coinInfoinBTC.TOSYMBOL + "" + + " \n % in 24 Hrs : " + coinInfoinCurrency.CHANGEPCT24HOUR + "" + + " \n High Day : " + coinInfoinCurrency.HIGHDAY + "" + + " \n Low Day : " + coinInfoinCurrency.LOWDAY + "" + + " \n Market Cap : " + coinInfoinCurrency.MKTCAP + "" + + " \n Updated : " + coinInfoinCurrency.LASTUPDATE + "" + + const imageObj = { + smallImageUrl: CoinInfo.CoinImg, + largeImageUrl: CoinInfo.CoinImg + }; + return { + "title": "💰" + CoinInfo.CoinFN.toUpperCase() + "💰", + "body": content, + "image": imageObj + }; +} + +function generateCoinMessage(CoinInfo) { + var coinInfoinCurrency = CoinInfo.CoinValue.DISPLAY[CoinInfo.CoinSN][CoinInfo.CoinCurrency]; + var coinInfoinBTC = CoinInfo.CoinValue.DISPLAY[CoinInfo.CoinSN]["BTC"]; + var currencyPrice = Util.m_removeCurrencySymbols(coinInfoinCurrency); + var BTCPrice = Util.m_removeCurrencySymbols(coinInfoinBTC); + + var soundop = '' + CoinInfo.CoinCount + " " + CoinInfo.CoinFN + ' is ' + (CoinInfo.CoinCount * currencyPrice).toFixed(2) + " " + coinInfoinCurrency.TOSYMBOL + ' , ' + getRandomValues(COIN_SELECT_MESSAGE, "MSG") + '' + return soundop; + +} + + +function GetCoinValueByDecimalIntentHandler() { + + this.handler.state = states.SearchUpdateMODE; + this.emitWithState("GetCoinValueByCountIntent"); + +} + +function getGenericHelpMessage() { + //'You can ask me to tell value of crypto coin, or, you can say exit... What can I help you with?', + + var sentences = ["ask - What's the value of " + getRandomValues(SAMPLE_COINS, "CoinName"), + "say - Add 1.23 " + getRandomValues(SAMPLE_COINS, "CoinName"), + "say - What's my portfolio", + "say - Change currency to " + getRandomValues(SAMPLE_CURRENCIES, "Currency"), + "say - Set Currency to " + getRandomValues(SAMPLE_CURRENCIES, "Currency") + + ] + const randomMessage = "You can " + sentences[getRandom(0, sentences.length - 1)]; + return randomMessage +} + + +function getRandomValues(arrayOfStrings, itemName) { + var randomNumber = getRandom(0, arrayOfStrings.length - 1); + return "" + arrayOfStrings[randomNumber][itemName]; +} + +function getRandom(min, max) { + return Math.floor(Math.random() * (max - min + 1) + min); +} + + + +function isSlotValid(request, slotName) { + var slot = request.intent.slots[slotName]; + //console.log("request = "+JSON.stringify(request)); //uncomment if you want to see the request + var slotValue; + + //if we have a slot, get the text and store it into speechOutput + if (slot && slot.value) { + //we have a value in the slot + slotValue = slot.value.toLowerCase(); + return slotValue; + } else { + //we didn't get a value in the slot. + return false; + } +} + + +function removeSSML(s) { + return s.replace(/<\/?[^>]+(>|$)/g, ""); +}; + +function configure(request, response) { + + //amazon alexa context + var context = { + succeed: function (result) { + console.log(result); + response.json(result); + }, + fail: function (error) { + console.log(error); + } + }; + + var alexa = Alexa.handler(request.body, context); + alexa.resources = languageStrings; + //alexa.registerHandlers(handlers); + alexa.registerHandlers(newSessionHandlers, searchUpdateHandlers, descriptionHandlers); + alexa.execute(); +} + + +module.exports = { + configure: configure +} \ No newline at end of file diff --git a/AllCoinZ/GenericProcess.js b/AllCoinZ/GenericProcess.js index 70a4856..5b497dc 100644 --- a/AllCoinZ/GenericProcess.js +++ b/AllCoinZ/GenericProcess.js @@ -3,43 +3,77 @@ const telegram = require('../AllCoinZ/telegram') const Google = require('../AllCoinZ/Google') const slack = require('../AllCoinZ/slack') const Q = require('q') -const dbAllCoinZ = require('../db/initialize'); -var gUser = dbAllCoinZ.g_User; +//const dbAllCoinZ = require('../db/initialize'); +const dynamoDB = require('../db/dynamoDB'); +//var gUser = dbAllCoinZ.g_User; const myCoins = require('../AllCoinZ/jsonCoin'); - -function getWelcomeMessage(platform, displayName) { + +function getWelcomeMessage(displayName) { console.log(Util.m_platform) switch (Util.m_platform) { case "telegram": telegram.m_formatWelcomeMessage(displayName); break; case "slack": - slack.m_formatWelcomeMessage(displayName); + slack.m_formatWelcomeMessage(displayName); + break; + case "google": + Google.m_formatWelcomeMessage(displayName); + break; + default: + "Hello Welcome to AllCryptoCoinZ" + } +} + +function getDefaultFallBack() { + switch (Util.m_platform) { + case "telegram": + telegram.m_formatFallback(); + break; + case "slack": + slack.m_formatFallback(); + break; + case "google": + Google.m_formatFallback(); + break; + default: + "Hello Welcome to AllCryptoCoinZ" + } +} + +function help(displayName) { + + switch (Util.m_platform) { + case "telegram": + telegram.m_getHelp(displayName); + break; + case "slack": + slack.m_getHelp(displayName); break; case "google": - Google.m_formatWelcomeMessage(displayName); + Google.m_getHelp(displayName); break; default: "Hello Welcome to AllCryptoCoinZ" - } + } + } -function sendSimpleMessage(message){ - +function sendSimpleMessage(message, displayText, title) { console.log(Util.m_platform) switch (Util.m_platform) { case "telegram": telegram.m_sendSimpleMessage(callPayLoadFormatMessage(message)); break; case "slack": - slack.m_sendSimpleMessage(callPayLoadFormatMessage(message)); + slack.m_sendSimpleMessage(callPayLoadFormatMessage(message)); break; case "google": - Google.m_sendSimpleMessage(message); + Google.m_sendSimpleMessage(message, displayText, title); break; default: "Hello Welcome to AllCryptoCoinZ" - } + } } @@ -53,7 +87,7 @@ function sendCoinResponse(coinResult) { telegram.m_ResponseMessage(coinResult); break; case "slack": - slack.m_ResponseMessage(coinResult); + slack.m_ResponseMessage(coinResult); break; case "skype": telegram.m_ResponseMessage(coinResult); @@ -71,26 +105,46 @@ function sendCoinResponse(coinResult) { function SyncPortfolio(userInfo, gapp) { - var deferred = Q.defer(); - var portfolio; var cryptoCoin = gapp.getArgument("CryptoCoin"); - var newQuantity = gapp.getArgument("number"); - - var BuySell = (gapp.getArgument("BuySell").toUpperCase() == "B" ) + var newQuantity = "" + if (gapp.getArgument("number") != null) { + newQuantity = gapp.getArgument("number") + }; + + var buysellDeleteOption; + + if (gapp.getArgument("BuySell")) { + buysellDeleteOption = gapp.getArgument("BuySell").toUpperCase() + } + + + if (gapp.getArgument("Delete")) { + buysellDeleteOption = gapp.getArgument("Delete").toUpperCase() + } + + var userInfoData; - dbAllCoinZ.g_getRecord(gUser, { + dynamoDB.g_getRecord({ uniqID: userInfo.uniqID }).then(function (item) { - var coinQuantity; var updatedQuantity - var updatetext="added"; - + var updatetext = ""; + + if (buysellDeleteOption == "ADD") { + updatetext = "added" + } else if (buysellDeleteOption == "DEDUCT") { + updatetext = "deducted" + } else if (buysellDeleteOption == "DELETE") { + updatetext = "deleted" + updatedQuantity = 0; + } //console.log("items" + item); if (item == null) { + updatedQuantity = newQuantity userInfoData = { displayName: userInfo.displayName, uniqID: userInfo.uniqID, @@ -98,30 +152,33 @@ function SyncPortfolio(userInfo, gapp) { portfolio: JSON.stringify({ [cryptoCoin]: newQuantity }) - } //console.log(JSON.stringify(item)) - } else { - var currentPortfolio = JSON.parse(item.portfolio) - + var currentPortfolio; + if (item.portfolio) { currentPortfolio = JSON.parse(item.portfolio) } if (currentPortfolio != null) { - if (currentPortfolio[cryptoCoin] == undefined) { - currentPortfolio[cryptoCoin] = newQuantity; + coinQuantity = 0; } else { - var updatedQuantity = 1; + //var updatedQuantity = 1; coinQuantity = currentPortfolio[cryptoCoin] - - if (BuySell) { - updatetext="added" - updatedQuantity = +newQuantity + +coinQuantity; - } else { - updatetext="removed" - updatedQuantity = +coinQuantity - newQuantity; - } - currentPortfolio[cryptoCoin] = updatedQuantity } + if (buysellDeleteOption == "ADD") { + updatetext = "added" + updatedQuantity = +newQuantity + +coinQuantity; + } else if (buysellDeleteOption == "DEDUCT") { + updatetext = "deducted" + updatedQuantity = +coinQuantity - newQuantity; + } else if (buysellDeleteOption == "DELETE") { + updatetext = "deleted" + updatedQuantity = 0; + } + if (updatedQuantity < 0) { + updatedQuantity = 0; + } + currentPortfolio[cryptoCoin] = updatedQuantity + userInfoData = { displayName: item.displayName, uniqID: item.uniqID, @@ -129,55 +186,61 @@ function SyncPortfolio(userInfo, gapp) { portfolio: JSON.stringify(currentPortfolio) } } else { + if (updatetext != "added") { + quantityused = 0; + } else { + quantityused = newQuantity; + } userInfoData = { displayName: userInfo.displayName, uniqID: userInfo.uniqID, curr: "INR", portfolio: JSON.stringify({ - [cryptoCoin]: newQuantity + [cryptoCoin]: quantityused }) } } } + var currentValue = newQuantity + if (updatedQuantity != undefined) { + currentValue = updatedQuantity + } + if (updatetext == "deleted") { + currentValue = 0; + newQuantity = "All " + } + dynamoDB.g_UpdateInsert(userInfoData).then(function () { + switch (Util.m_platform) { + case "telegram": + case "slack": + sendSimpleMessage("Portfolio Details\n`" + newQuantity + " " + cryptoCoin + " has been " + updatetext + " successfully !!!`") + break; + case "google": + //sendSimpleMessage("**"+newQuantity + " " + cryptoCoin + "** has been " + updatetext + " !!! \nAvailable "+cryptoCoin+" : "+ updatedQuantity,"","Portfolio Update :"); - dbAllCoinZ.g_UpdateInsert(gUser, { - uniqID: userInfo.uniqID - }, userInfoData).then(function () { - - - - - switch (Util.m_platform) { - case "telegram": - case "slack": - sendSimpleMessage("Portfolio Details\n`"+ newQuantity + " " + cryptoCoin + " has been " +updatetext+" successfully !!!`") - break; - case "google": - sendSimpleMessage(newQuantity + " " + cryptoCoin + " has been " +updatetext+" successfully !!!"); - break; - default: - "Hello Welcome to AllCoinZ" + sendSimpleMessage("**" + newQuantity + " " + cryptoCoin + "** has been " + updatetext + " !!! \n*Available " + cryptoCoin + " :* **" + currentValue + "** \n \n", "", "Portfolio Update :") + break; + default: + "Hello Welcome to AllCoinZ" } - - //deferred.resolve(callPayLoadFormatMessage("Portfolio Details\n`"+ newQuantity + " " + cryptoCoin + " has been " +updatetext+" successfully !!!`")) - - // deferred.resolve(Util.m_getDefaultCardMessageResponse(Util.m_platform, { - // subtitle:"`"+ newQuantity + " " + cryptoCoin + " has been " +updatetext+" successfully !!!`", - // title: "Portfolio Details", - // buttons: [] - // })) + //deferred.resolve(callPayLoadFormatMessage("Portfolio Details\n`"+ newQuantity + " " + cryptoCoin + " has been " +updatetext+" successfully !!!`")) + + // deferred.resolve(Util.m_getDefaultCardMessageResponse(Util.m_platform, { + // subtitle:"`"+ newQuantity + " " + cryptoCoin + " has been " +updatetext+" successfully !!!`", + // title: "Portfolio Details", + // buttons: [] + // })) //console.log("updated the portfolio"); }, function (error) { deferred.reject(error) }) }) - return deferred.promise; } -function callPayLoadFormatMessage(message){ -var responseMessage +function callPayLoadFormatMessage(message) { + var responseMessage switch (Util.m_platform) { case "telegram": responseMessage = telegram.m_getPayLoadMessage(message); @@ -190,71 +253,57 @@ var responseMessage break; default: "Please try again !!!" - } - -return responseMessage; - + } + return responseMessage; } - function getPortfolio(userInfo) { var deferred = Q.defer(); - dbAllCoinZ.g_getRecord(gUser, { + dynamoDB.g_getRecord({ uniqID: userInfo.uniqID }).then(function (result) { - - if (result == null) { + var myPortfolio; + if (result != null) { + myPortfolio = result.portfolio; + } + if (result == null || myPortfolio == null) { switch (Util.m_platform) { - case "telegram","slack", "skype": - return deferred.reject("`Please create a new portfolio. Check help !!`") + case "telegram", "slack", "skype": + return deferred.reject("`Please create a new portfolio. Check help !!`") break; case "google": - Google.sendPortfolioUpdate("Please create a new portfolio. Check help !!!"); + return Google.m_sendPortfolioUpdate("Please create a new portfolio. Check help !!!"); break; default: "Please try again !!!" - - - } - + } } - let myPortfolio = result.portfolio; Util.m_myCurrency = result.curr; - if (myPortfolio == null) {} else { + if (myPortfolio == null) { } else { //console.log(JSON.parse(myPortfolio)); - deferred.resolve(JSON.parse(myPortfolio), result.curr); - - } - - - }, function (error) {}) - + }, function (error) { }) return deferred.promise; } function getTotalPortfolioValue(userInfo, fetchValue) { var deferred = Q.defer(); - getPortfolio(userInfo).then(function (myPortfolio) { - - if (fetchValue || Util.m_platform=="google") { + if (fetchValue || Util.m_platform == "google") { console.log('total1') var oPortFolioLatestData = getPortFolioCoinData(myPortfolio, Util.m_myCurrency) - oPortFolioLatestData.then(function (myportFolioData) { - - console.log('total') + console.log('total') switch (Util.m_platform) { case "telegram": - telegram.m_getPortfolioData(myportFolioData, myPortfolio); + telegram.m_getPortfolioData(myportFolioData, myPortfolio); break; case "slack": - slack.m_getPortfolioData(myportFolioData, myPortfolio); + slack.m_getPortfolioData(myportFolioData, myPortfolio); break; case "skype": - telegram.m_getPortfolioData(myportFolioData, myPortfolio); + telegram.m_getPortfolioData(myportFolioData, myPortfolio); break; case "google": Google.m_getPortfolioData(myportFolioData, myPortfolio); @@ -262,24 +311,18 @@ function getTotalPortfolioValue(userInfo, fetchValue) { default: "Please try again !!!" } - // console.log(resultPortFolioWithData) - deferred.resolve(true); }).catch(function (err) { - return deferred.reject(false); }) - - } else { - switch (Util.m_platform) { case "telegram": telegram.m_getPortfolioInfo(myPortfolio); break; case "slack": - slack.m_getPortfolioInfo(myPortfolio); + slack.m_getPortfolioInfo(myPortfolio); break; case "skype": telegram.m_getPortfolioInfo(myPortfolio); @@ -290,67 +333,51 @@ function getTotalPortfolioValue(userInfo, fetchValue) { default: "Please try again !!!" } - deferred.resolve(true); } - - }, function (error) { console.log(error); - - return deferred.reject(false); + return deferred.reject(false); }) return deferred.promise; - - - } function getPortFolioCoinData(input, myCurrency) { - var deferred = Q.defer(); var request = require('request'); - var cryptoCoinstoFetch = "BTC"; - - - for (const coin of Object.keys(input)) { var foundCoin = myCoins.m_findCoin(coin.toUpperCase()) - //console.log(foundCoin); + //console.log(foundCoin); if (foundCoin !== null && foundCoin != "") { cryptoCoinstoFetch = cryptoCoinstoFetch + "," + foundCoin[0].n } } var baseUrl = 'https://min-api.cryptocompare.com/data/pricemultifull?fsyms='; var parsedUrl = baseUrl + cryptoCoinstoFetch + "&tsyms=BTC," + myCurrency + "&e=CCCAGG" - //console.log(parsedUrl); request(parsedUrl, function (error, response, body) { - - var JSONResponse = JSON.parse(response.body); - - //console.log("CV" + JSON.stringify(JSONResponse)); + //console.log("CV" + JSON.stringify(JSONResponse)); if (JSONResponse != null || JSONResponse !== undefined) { //console.log("JSON Response" + JSON.stringify(response.body)) deferred.resolve(JSONResponse); } else { - deferred.reject(null); } - }) return deferred.promise; } module.exports = { - m_getWelcomeMessage: getWelcomeMessage, - m_sendSimpleMessage:sendSimpleMessage, + m_sendSimpleMessage: sendSimpleMessage, m_sendCoinResponse: sendCoinResponse, m_SyncPortfolio: SyncPortfolio, m_getTotalPortfolioValue: getTotalPortfolioValue, - m_callPayLoadFormatMessage:callPayLoadFormatMessage, + m_callPayLoadFormatMessage: callPayLoadFormatMessage, + m_getDefaultFallBack: getDefaultFallBack, + m_help: help, + m_getPortFolioCoinData: getPortFolioCoinData } \ No newline at end of file diff --git a/AllCoinZ/Google.js b/AllCoinZ/Google.js index c0f2a9c..7569182 100644 --- a/AllCoinZ/Google.js +++ b/AllCoinZ/Google.js @@ -2,89 +2,142 @@ const Util = require('../AllCoinZ/util') const jsCoin = require('../AllCoinZ/jsonCoin'); var gapp; -function sendPortfolioUpdate(message){ - -gapp.ask(""+ message+"") +function sendSimpleMessage(message, displayText, title, image) { + if (title == undefined) { title = "Smart Crypto" } + if (displayText == undefined) { displayText = "" } + var basicards = gapp.buildBasicCard(message).setTitle(title) + if (image == null) { + basicards.setImage("https://i.imgur.com/EvSC8to.png", "Smart Crypto")//https://i.imgur.com/5hFARdc.jpg + .setImageDisplay("DEFAULT") + } + gapp.ask(gapp.buildRichResponse() + .addSimpleResponse({ + speech: message.split("*").join(""), + displayText: displayText + }) + .addSuggestions(Util.m_getDefaultSuggestions) + .addBasicCard(basicards + ) + + ) } -function sendSimpleMessage(message){ - sendPortfolioUpdate(message) +function sendPortfolioUpdate(message) { + sendSimpleMessage(message) } - function setgapp(mgapp){ - gapp=mgapp - } - - -function formatWelcomeMessage(displayName) { - var welcomeMessage ="" - const textToSpeech = '' + - 'Here are SSML samples. ' + - 'I can pause . ' + - 'I can play a sound . ' + - 'I can speak in cardinals. Your position is 10 in line. ' + - 'Or I can speak in ordinals. You are 10 in line. ' + - 'Or I can even speak in digits. Your position in line is 10. ' + - 'I can also substitute phrases, like the W3C. ' + - 'Finally, I can speak a paragraph with two sentences. ' + - '

This is sentence one.This is sentence two.

' + - '
'; - - welcomeMessage =''+ - 'Welcome to AllCryptoCoinZSay help anytime. Which coin would you want to select ? '+ - '' - - gapp.ask(welcomeMessage) + +function setgapp(mgapp) { + gapp = mgapp } +function getHelp(displayName) { + // gapp.ask(gapp.buildRichResponse() + // // Create a basic card and add it to the rich response + // .addSimpleResponse('addSimpleResponse') + + // .addBasicCard(gapp.buildBasicCard('Welcome to Smart Crypto') + // .setTitle('Math & prime numbers') + // .addButton('Read more', 'https://example.google.com/mathandprimes') + // .setImage('https://example.google.com/42.png', 'Image alternate text') + // .setImageDisplay('CROPPED') + // ) + // ); + + var hasScreen = gapp.hasSurfaceCapability(gapp.SurfaceCapabilities.SCREEN_OUTPUT) + + var richresponse = gapp.buildRichResponse() + // Create a basic card and add it to the rich response + if (hasScreen) { + richresponse = richresponse.addSimpleResponse('Smart Crypto Help') + .addBasicCard(gapp.buildBasicCard( + ' \n \n*To change the default currency say* **Set currency to USD or cur INR**' + + ' \n \n*To add a coin to portfolio say* **Add 1.23 XRP**' + + ' \n \n*To reduce a coin count from portfolio say* **Deduct 0.23 BCH**' + + ' \n \n*To delete a coin from portfolio say* **Delete XRP**' + + ' \n \n*To get the portfolio ask* **What\'s my portfolio?**') + .setTitle('Smart Crypto Help') + // .addButton('Read more', 'https://example.google.com/mathandprimes') + // .setImage('https://example.google.com/42.png', 'Image alternate text') + // .setImageDisplay('CROPPED') + ) + } else { + richresponse = richresponse.addSimpleResponse('Smart Crypto Help' + + 'To change the default currency say Set currency to USD' + + + + 'To add a coin to portfolio say Add 1.23 XRP' + + + + 'To reduce a coin count from portfolio say Deduct 0.23 BCH' + + + + 'To delete a coin from portfolio say Delete 123 XRP' + + + + 'To get the portfolio ask What\'s my portfolio?') + } + gapp.ask(richresponse) -function ResponseMessage(CoinInfo) { + gapp.ask(gapp.buildRichResponse() + .addSimpleResponse('addSimpleResponse') + .addBasicCard(gapp.buildBasicCard('Welcome to Smart Crypto' + + 'To change the default currency say **Set currency to USD or cur INR**' + + 'To add a coin to portfolio say **Add 1.23 XRP**' + + 'To reduce a coin count from portfolio say **Deduct 0.23 BCH**' + + 'To delete a coin from portfolio say **Delete 1.23 XRP**' + + 'To get the portfolio ask **What\'s my portfolio?**') + .setTitle('Math & prime numbers') + .addButton('Read more', 'https://example.google.com/mathandprimes') + .setImage('https://example.google.com/42.png', 'Image alternate text') + .setImageDisplay('CROPPED') - console.log("ResponseMessage") - var coinInfoinCurrency = CoinInfo.CoinValue.DISPLAY[CoinInfo.CoinSN][CoinInfo.CoinCurrency] - var coinInfoinBTC = CoinInfo.CoinValue.DISPLAY[CoinInfo.CoinSN]["BTC"] + )) - var currencyPrice = Util.m_removeCurrencySymbols(coinInfoinCurrency) - var BTCPrice = Util.m_removeCurrencySymbols(coinInfoinBTC) - - var coinDetail = "💰" + "*" + CoinInfo.CoinFN.toUpperCase() + "*💰\n\n` " + CoinInfo.CoinCount + " " + CoinInfo.CoinSN + "` = *" + (CoinInfo.CoinCount * currencyPrice).toFixed(5) + " " + coinInfoinCurrency.TOSYMBOL + "*" + "\n " + - "\n` " + CoinInfo.CoinCount + " " + CoinInfo.CoinSN + "` = *" + (CoinInfo.CoinCount * BTCPrice).toFixed(9) + " " + coinInfoinBTC.TOSYMBOL + "* \n\n _ % in 24 Hrs : _ *" + coinInfoinCurrency.CHANGEPCT24HOUR + "* \n " + "_ High Day : _ *" + coinInfoinCurrency.HIGHDAY + "* \n " + - "_ Low Day : _ *" + coinInfoinCurrency.LOWDAY + "* \n " + "_ Market Cap : _ *" + coinInfoinCurrency.MKTCAP + "* \n " + "_ Updated : _ *" + coinInfoinCurrency.LASTUPDATE + "* \n " - var text; - - text = CoinInfo.CoinFN.toUpperCase() +" = " + (CoinInfo.CoinCount * currencyPrice).toFixed(5) + " " + coinInfoinCurrency.TOSYMBOL - - var sound = ''+CoinInfo.CoinFN.toUpperCase() +" is " + (CoinInfo.CoinCount * currencyPrice).toFixed(5) + " " + coinInfoinCurrency.TOSYMBOL + ''; - - var simpleResponse = ' '+ CoinInfo.CoinCount + ' '+ CoinInfo.CoinFN + ' is '+(CoinInfo.CoinCount * currencyPrice).toFixed(2) + " " +coinInfoinCurrency.TOSYMBOL+''; - - var content = "*"+CoinInfo.CoinCount + " " + CoinInfo.CoinSN + "* = **" + (CoinInfo.CoinCount * currencyPrice).toFixed(5)+ " " +coinInfoinCurrency.TOSYMBOL+"**"+"
*"+ - CoinInfo.CoinCount + "" + CoinInfo.CoinSN + "* = **" + (CoinInfo.CoinCount * BTCPrice).toFixed(9) + " " + coinInfoinBTC.TOSYMBOL + "**
"+ - "*% in 24 Hrs :* **" + coinInfoinCurrency.CHANGEPCT24HOUR + "**
" + - "*High Day :* **" + coinInfoinCurrency.HIGHDAY + "**
" + - "*Low Day :* **" + coinInfoinCurrency.LOWDAY + "**
" + - "*Market Cap :* **" + coinInfoinCurrency.MKTCAP + "**
" + - "*Updated :* **" + coinInfoinCurrency.LASTUPDATE + "** " + return + + + + const textToSpeech = '' + + 'Here are SSML samples. ' + + 'I can pause . ' + + 'I can play a sound . ' + + 'I can speak in cardinals. Your position is 10 in line. ' + + 'Or I can speak in ordinals. You are 10 in line. ' + + 'Or I can even speak in digits. Your position in line is 10. ' + + 'I can also substitute phrases, like the W3C. ' + + 'Finally, I can speak a paragraph with two sentences. ' + + '

This is sentence one.This is sentence two.

' + + '
'; + + welcomeMessage = 'Welcome to Smart Crypto' + + 'To change the default currency say **Set currency to USD**' + + //sendSimpleMessage(welcomeMessage) } - - -function getPayLoadMessage(message){ - - return { - speech:"telegram", - "messages": [{ - "platform": "telegram", - "type": 4, - payload: { - "telegram": - { - "text": message, - parse_mode: "Markdown", -}}}]} - + + + + +function getPayLoadMessage(message) { + + return { + speech: "telegram", + "messages": [{ + "platform": "telegram", + "type": 4, + payload: { + "telegram": { + "text": message, + parse_mode: "Markdown", + } + } + }] + } + } function getCoinInfo(CoinInfo) { @@ -98,7 +151,7 @@ function getCoinInfo(CoinInfo) { var coinDetail = "💰" + "*" + CoinInfo.CoinFN.toUpperCase() + "*💰\n\n` " + CoinInfo.CoinCount + " " + CoinInfo.CoinSN + "` = *" + (CoinInfo.CoinCount * currencyPrice).toFixed(5) + " " + coinInfoinCurrency.TOSYMBOL + "*" + "\n " + - "\n` " + CoinInfo.CoinCount + " " + CoinInfo.CoinSN + "` = *" + (CoinInfo.CoinCount * BTCPrice).toFixed(9) + " " + coinInfoinBTC.TOSYMBOL + "* \n\n _ % in 24 Hrs : _ *" + coinInfoinCurrency.CHANGEPCT24HOUR + "* \n " + "_ High Day : _ *" + coinInfoinCurrency.HIGHDAY + "* \n " + + "\n` " + CoinInfo.CoinCount + " " + CoinInfo.CoinSN + "` = *" + (CoinInfo.CoinCount * BTCPrice).toFixed(5) + " " + coinInfoinBTC.TOSYMBOL + "* \n\n _ % in 24 Hrs : _ *" + coinInfoinCurrency.CHANGEPCT24HOUR + "* \n " + "_ High Day : _ *" + coinInfoinCurrency.HIGHDAY + "* \n " + "_ Low Day : _ *" + coinInfoinCurrency.LOWDAY + "* \n " + "_ Market Cap : _ *" + coinInfoinCurrency.MKTCAP + "* \n " + "_ Updated : _ *" + coinInfoinCurrency.LASTUPDATE + "* \n " var customcardMessage = { @@ -119,8 +172,8 @@ function getCoinInfo(CoinInfo) { } -function formatMyPortfoliowithData(data, myCoins,) { - var currency =Util.m_myCurrency +function formatMyPortfoliowithData(data, myCoins) { + var currency = Util.m_myCurrency var op = "\n" var priceinBTC = 0; var priceinCurrency = 0; @@ -129,17 +182,13 @@ function formatMyPortfoliowithData(data, myCoins,) { var displayCurrency; var displayBTC; for (const coin of Object.keys(myCoins)) { - - priceinBTC = (Util.m_removeCurrencySymbols(data.DISPLAY[coin]["BTC"]) * myCoins[coin]).toFixed(9) - + priceinBTC = (Util.m_removeCurrencySymbols(data.DISPLAY[coin]["BTC"]) * myCoins[coin]).toFixed(5) + priceinCurrency = (Util.m_removeCurrencySymbols(data.DISPLAY[coin][currency]) * myCoins[coin]).toFixed(2) - - - op = op +"`" + (+myCoins[coin]).toFixed(2) + "` "+ "*[" + coin + "*]=`" + priceinCurrency + "" + data.DISPLAY[coin][currency].TOSYMBOL + " |" + " " + priceinBTC + "" + data.DISPLAY[coin]["BTC"].TOSYMBOL + "` " + + op = op + "`" + (+myCoins[coin]).toFixed(2) + "` " + "*[" + coin + "*]=`" + priceinCurrency + "" + data.DISPLAY[coin][currency].TOSYMBOL + " |" + " " + priceinBTC + "" + data.DISPLAY[coin]["BTC"].TOSYMBOL + "` " + "\n" - displayCurrency = data.DISPLAY[coin][currency].TOSYMBOL displayBTC = data.DISPLAY[coin]["BTC"].TOSYMBOL @@ -148,84 +197,189 @@ function formatMyPortfoliowithData(data, myCoins,) { } - op = op + "\n*[TPV]: " + " " + totalCurrency.toFixed(3) + " " + displayCurrency + " | " + totalBTC.toFixed(9) + " " + displayBTC + "*" - gapp.ask("Total Value is "+''+ totalCurrency.toFixed(3) + " " + displayCurrency +"") + op = op + "\n*[TPV]: " + " " + totalCurrency.toFixed(3) + " " + displayCurrency + " | " + totalBTC.toFixed(5) + " " + displayBTC + "*" + gapp.ask("Total Value is " + '' + totalCurrency.toFixed(3) + " " + displayCurrency + "") return op; } + + + +function ResponseMessage(CoinInfo) { + + // console.log("ResponseMessage") + var coinInfoinCurrency = CoinInfo.CoinValue.DISPLAY[CoinInfo.CoinSN][CoinInfo.CoinCurrency] + var coinInfoinBTC = CoinInfo.CoinValue.DISPLAY[CoinInfo.CoinSN]["BTC"] + + var currencyPrice = Util.m_removeCurrencySymbols(coinInfoinCurrency) + var BTCPrice = Util.m_removeCurrencySymbols(coinInfoinBTC) + + var coinDetail = "💰" + "*" + CoinInfo.CoinFN.toUpperCase() + "*💰\n\n` " + CoinInfo.CoinCount + " " + CoinInfo.CoinSN + "` = *" + (CoinInfo.CoinCount * currencyPrice).toFixed(5) + " " + coinInfoinCurrency.TOSYMBOL + "*" + "\n " + + "\n` " + CoinInfo.CoinCount + " " + CoinInfo.CoinSN + "` = *" + (CoinInfo.CoinCount * BTCPrice).toFixed(5) + " " + coinInfoinBTC.TOSYMBOL + "* \n\n _ % in 24 Hrs : _ *" + coinInfoinCurrency.CHANGEPCT24HOUR + "* \n " + "_ High Day : _ *" + coinInfoinCurrency.HIGHDAY + "* \n " + + "_ Low Day : _ *" + coinInfoinCurrency.LOWDAY + "* \n " + "_ Market Cap : _ *" + coinInfoinCurrency.MKTCAP + "* \n " + "_ Updated : _ *" + coinInfoinCurrency.LASTUPDATE + "* \n " + var text; + + text = CoinInfo.CoinFN.toUpperCase() + " = " + (CoinInfo.CoinCount * currencyPrice).toFixed(5) + " " + coinInfoinCurrency.TOSYMBOL + + var sound = '' + CoinInfo.CoinFN.toUpperCase() + " is " + (CoinInfo.CoinCount * currencyPrice).toFixed(5) + " " + coinInfoinCurrency.TOSYMBOL + ''; + + var simpleResponse = ' ' + CoinInfo.CoinCount + ' ' + CoinInfo.CoinFN + ' is ' + (CoinInfo.CoinCount * currencyPrice).toFixed(2) + " " + coinInfoinCurrency.TOSYMBOL + ',' + getRandomValues(COIN_SELECT_MESSAGE, "MSG") + ''; + + var content = " \n *" + CoinInfo.CoinCount + " " + CoinInfo.CoinSN + "* = **" + (CoinInfo.CoinCount * currencyPrice).toFixed(5) + " " + coinInfoinCurrency.TOSYMBOL + "**" + + " \n *" + CoinInfo.CoinCount + "" + CoinInfo.CoinSN + "* = **" + (CoinInfo.CoinCount * BTCPrice).toFixed(5) + " " + coinInfoinBTC.TOSYMBOL + "**" + + " \n *% in 24 Hrs :* **" + coinInfoinCurrency.CHANGEPCT24HOUR + "**" + + " \n *High Day :* **" + coinInfoinCurrency.HIGHDAY + "**" + + " \n *Low Day :* **" + coinInfoinCurrency.LOWDAY + "**" + + " \n *Market Cap :* **" + coinInfoinCurrency.MKTCAP + "**" + + " \n *Updated :* **" + coinInfoinCurrency.LASTUPDATE + "**" + + gapp.ask(gapp.buildRichResponse() + // Create a basic card and add it to the rich response + .addSimpleResponse(simpleResponse) + + .addSuggestions(Util.m_getDefaultSuggestions) + .addBasicCard(gapp.buildBasicCard(content) + .setTitle("💰💰💰" + CoinInfo.CoinFN.toUpperCase() + "💰💰💰") + .addButton('View ' + CoinInfo.CoinSN, CoinInfo.CoinURL) + .setImage(CoinInfo.CoinImg, CoinInfo.CoinFN) + .setImageDisplay('DEFAULT') + ) + ) + + // gapp.askWithCarousel(gapp.buildRichResponse().addSimpleResponse(simpleResponse) + // .addSuggestions(['BTC', 'XRP', 'ETH', 'ADA', 'XVG']), + + + // gapp.buildCarousel("💰" + CoinInfo.CoinFN.toUpperCase() + "💰") + // // Add the first item to the carousel + // .addItems(gapp.buildOptionItem('CoinInfo.CoinSN' + "FIAT", + // [CoinInfo.PRICE]) + // .setTitle(CoinInfo.CoinCount + " " + CoinInfo.CoinSN + " = " + (CoinInfo.CoinCount * currencyPrice).toFixed(5) + " " + coinInfoinCurrency.TOSYMBOL) + // .setDescription(CoinInfo.CoinCount + " " + CoinInfo.CoinSN + " = " + (CoinInfo.CoinCount * BTCPrice).toFixed(9) + " " + coinInfoinBTC.TOSYMBOL + // ) + // .setImage(CoinInfo.CoinImg, CoinInfo.CoinFN) + + // ) + // .addItems(gapp.buildOptionItem('CoinInfo.CoinSN' + "PERCENT24", + // [CoinInfo.CHANGEPCT24HOUR]) + // .setTitle("% in 24 Hrs: " + coinInfoinCurrency.CHANGEPCT24HOUR) + // .setDescription("% in 12 Hrs: " + coinInfoinCurrency.CHANGEPCTDAY) + // .setImage(CoinInfo.CoinImg, CoinInfo.CoinFN) + // ) + // .addItems(gapp.buildOptionItem('CoinInfo.CoinSN' + "HIGHDAY", + // [CoinInfo.HIGHDAY]) + // .setTitle("High Day : " + coinInfoinCurrency.HIGHDAY) + // .setDescription("Low Day : " + coinInfoinCurrency.LOWDAY ) + // .setImage(CoinInfo.CoinImg, CoinInfo.CoinFN) + // ) + // .addItems(gapp.buildOptionItem('CoinInfo.CoinSN' + "MKTCAP", + // [CoinInfo.MKTCAP]) + // .setTitle("Market Cap : " + coinInfoinCurrency.MKTCAP) + // .setDescription("Updated : " + coinInfoinCurrency.LASTUPDATE) + // .setImage(CoinInfo.CoinImg, CoinInfo.CoinFN) + // ) + // ); + + + + +} + +const COIN_SELECT_MESSAGE = [{ + MSG: 'Which coin would you like to select next ?' +}, { + MSG: 'Which coin would you like to try next' +}, { + MSG: 'Which crypto coin next ?' +}] + + +function getRandomValues(arrayOfStrings, itemName) { + var randomNumber = getRandom(0, arrayOfStrings.length - 1); + return "" + arrayOfStrings[randomNumber][itemName]; +} + +function getRandom(min, max) { + return Math.floor(Math.random() * (max - min + 1) + min); +} + + function getPortfolioData(data, myCoins) { - var currency =Util.m_myCurrency - var op=""; - + var currency = Util.m_myCurrency + var op = ""; + var priceinBTC = 0; var priceinCurrency = 0; var totalBTC = 0; var totalCurrency = 0; var displayCurrency; var displayBTC; -// for (const coin of Object.keys(myCoins)) { - - -// priceinBTC = (Util.m_removeCurrencySymbols(data.DISPLAY[coin]["BTC"]) * myCoins[coin]).toFixed(9) - -// priceinCurrency = (Util.m_removeCurrencySymbols(data.DISPLAY[coin][currency]) * myCoins[coin]).toFixed(2) - - -// op = op +"`" + (+myCoins[coin]).toFixed(2) + "` "+ "*[" + coin + "*]=`" + priceinCurrency + "" + data.DISPLAY[coin][currency].TOSYMBOL + " |" + " " + priceinBTC + "" + data.DISPLAY[coin]["BTC"].TOSYMBOL + "` " + -// "\n" -// displayCurrency = data.DISPLAY[coin][currency].TOSYMBOL -// displayBTC = data.DISPLAY[coin]["BTC"].TOSYMBOL - -// totalBTC = +totalBTC + +priceinBTC -// totalCurrency = +totalCurrency + +priceinCurrency + var mylist = gapp.buildList('My Portfolio:') + var BaseLinkUrl = "https://www.cryptocompare.com"; + var cryptoCoin = ""; + var link; + var ilink + var description; + for (const coin of Object.keys(myCoins)) { -// } - - - - var mylist = gapp.buildList('My Portfolio:') - - var BaseLinkUrl = "https://www.cryptocompare.com"; - var cryptoCoin ; - var link ; - var ilink - for (const coin of Object.keys(myCoins)){ - - + if (myCoins[coin] <= 0) { + continue + } cryptoCoin = jsCoin.m_findCoin(coin.toUpperCase());; - console.log("after my "+ BaseLinkUrl + cryptoCoin[0].iu) + // console.log("after my " + BaseLinkUrl + cryptoCoin[0].iu) - link = BaseLinkUrl + cryptoCoin[0].u; - ilink = BaseLinkUrl + cryptoCoin[0].iu; + link = BaseLinkUrl + cryptoCoin[0].u; + ilink = BaseLinkUrl + cryptoCoin[0].iu; op = op + "" + (+myCoins[coin]).toFixed(3) + " " + coin + "" - - - priceinBTC = (Util.m_removeCurrencySymbols(data.DISPLAY[coin]["BTC"]) * myCoins[coin]).toFixed(9) + + + priceinBTC = (Util.m_removeCurrencySymbols(data.DISPLAY[coin]["BTC"]) * myCoins[coin]).toFixed(5) priceinCurrency = (Util.m_removeCurrencySymbols(data.DISPLAY[coin][currency]) * myCoins[coin]).toFixed(2) - - mylist.addItems(gapp.buildOptionItem(coin, - ['AllCryptoCoinZ']) - .setTitle((+myCoins[coin]).toFixed(3) +" "+coin) - .setDescription(priceinCurrency + "" + data.DISPLAY[coin][currency].TOSYMBOL + " |" + " " + priceinBTC + "" + data.DISPLAY[coin]["BTC"].TOSYMBOL) - .setImage(ilink, coin) - ) + description = priceinCurrency + "" + data.DISPLAY[coin][currency].TOSYMBOL + " |" + " " + priceinBTC + "" + data.DISPLAY[coin]["BTC"].TOSYMBOL + + mylist.addItems(gapp.buildOptionItem((+myCoins[coin]).toFixed(3) + "#" + coin, [coin]) + .setTitle((+myCoins[coin]).toFixed(3) + " " + coin) + .setDescription(description) + .setImage(ilink, coin) + ) displayCurrency = data.DISPLAY[coin][currency].TOSYMBOL displayBTC = data.DISPLAY[coin]["BTC"].TOSYMBOL totalBTC = +totalBTC + +priceinBTC totalCurrency = +totalCurrency + +priceinCurrency - } - - mylist.title ="My Portfolio Value: " + totalCurrency.toFixed(3) + " " + displayCurrency + " | " + totalBTC.toFixed(9) + " " + displayBTC - console.log(mylist.title) - - console.log("\n*[TPV]: " + " " + totalCurrency.toFixed(3) + " " + displayCurrency + " | " + totalBTC.toFixed(9) + " " + displayBTC ) - gapp.askWithList(gapp.buildRichResponse() - .addSimpleResponse(""+"My Portfolio Value: " + totalCurrency.toFixed(3) + " " + displayCurrency + " equalent to " + totalBTC.toFixed(9) + " BTC " +"") - .addSuggestions(['BTC','XRP','ETH','ADA','XVG']),mylist) - + } + + + if (cryptoCoin == '') { + return sendPortfolioUpdate("Please create a new portfolio. Check help !!!"); + } + + mylist.title = "Portfolio Value: " + totalCurrency.toFixed(3) + " " + displayCurrency //+ " \n" + totalBTC.toFixed(5) + " " + displayBTC + + if (mylist.items.length < 500) { + mylist.addItems(gapp.buildOptionItem("My Portfolio", ['My Portfolio']) + .setTitle("My Portfolio") + .setDescription(totalCurrency.toFixed(3) + " " + displayCurrency + " | " + totalBTC.toFixed(6) + " " + displayBTC) + .setImage("https://i.imgur.com/EvSC8to.png", "Smart Crypto") + ) + } + + + + mylist.title = "My Portfolio Value: " + totalCurrency.toFixed(3) + " " + displayCurrency //+ " | " + totalBTC.toFixed(9) + " " + displayBTC + // console.log(mylist.title) + + // console.log("\n*[TPV]: " + " " + totalCurrency.toFixed(3) + " " + displayCurrency + " | " + totalBTC.toFixed(5) + " " + displayBTC) + gapp.askWithList(gapp.buildRichResponse() + .addSimpleResponse("" + "My Portfolio Value: " + totalCurrency.toFixed(3) + " " + displayCurrency + " equivalent to " + totalBTC.toFixed(5) + " BTC " + getRandomValues(COIN_SELECT_MESSAGE, "MSG") + "") + .addSuggestions(Util.m_getDefaultSuggestions) + , mylist) + + + + } @@ -233,36 +387,42 @@ function getPortfolioData(data, myCoins) { //format portfolio info function getPortfolioInfo(myCoins) { - - var op; - - + + var op; + + var mylist = gapp.buildList('My Portfolio:') - - for (const coin of Object.keys(myCoins)){ - - op = op + "" + (+myCoins[coin]).toFixed(3) + " " + coin + "" - - mylist.addItems(gapp.buildOptionItem(coin, - ['AllCryptoCoinZ']) - .setTitle((+myCoins[coin]).toFixed(3) +" "+coin) - .setDescription("description") - .setImage("https://assets.pcmag.com/media/images/436663-yahoo-aabaco.jpg", coin)) - - } - gapp.askWithList(gapp.buildRichResponse() - .addSimpleResponse("My Portfolio: "+op+"") - .addSuggestions( - ['Total Value']),mylist) + + for (const coin of Object.keys(myCoins)) { + + op = op + "" + (+myCoins[coin]).toFixed(3) + " " + coin + "" + + mylist.addItems(gapp.buildOptionItem(coin, ['SmartCrypto']) + .setTitle((+myCoins[coin]).toFixed(3) + " " + coin) + .setDescription("description") + .setImage("https://assets.pcmag.com/media/images/436663-yahoo-aabaco.jpg", coin)) + + } + gapp.askWithList(gapp.buildRichResponse() + .addSimpleResponse("My Portfolio: " + op + "") + .addSuggestions( + ['Total Value']), mylist) } +function formatFallback() { + sendSimpleMessage("I don't understand it.Please check the command or Coin name.") + + +} module.exports = { - m_formatWelcomeMessage: formatWelcomeMessage, + m_ResponseMessage: ResponseMessage, m_getPortfolioData: getPortfolioData, m_getPortfolioInfo: getPortfolioInfo, - m_getPayLoadMessage:getPayLoadMessage, - m_gapp:setgapp, - m_sendPortfolioUpdate:sendPortfolioUpdate, - m_sendSimpleMessage:sendSimpleMessage + m_getPayLoadMessage: getPayLoadMessage, + m_gapp: setgapp, + m_sendPortfolioUpdate: sendPortfolioUpdate, + m_sendSimpleMessage: sendSimpleMessage, + m_formatFallback: formatFallback, + m_getHelp: getHelp } \ No newline at end of file diff --git a/AllCoinZ/exposedAPI.js b/AllCoinZ/exposedAPI.js new file mode 100644 index 0000000..ea771ff --- /dev/null +++ b/AllCoinZ/exposedAPI.js @@ -0,0 +1,78 @@ + +const Util = require('../AllCoinZ/util') +const fetchCoin = require('../AllCoinZ/fetchCoin'); + +var welcome = function (req, res) { + + res.status(200).send('JAI - Welcome to Smart Crypto \n' + new Date()).end(); + +} + +var getCoins = function (req, res) { + + var optype = ""; + optype = req.params.optype + + fetchCoin.m_updateCoins(optype).then(function (success) { + console.log(success) + res.setHeader('Content-Type', 'application/json'); + res.status(200).send(success) + + }, function (error) { + console.log(error); + res.status(400).send(error) + }) +} + +var deleteUser = function (req, res) { + + if (req.params.secret == "rmr999") { + Util.m_deleteUser(req.params.key).then(function (useritem) { + var users = JSON.stringify(useritem) + res.setHeader('Content-Type', 'application/json'); + res.status(200).send(users) + }) + } else { + res.status(400).send("Check request") + } + +} + +var getUsers = function (req, res) { + if (req.params.secret == "rmr999") { + Util.m_getUsers().then(function (useritem) { + var users = JSON.stringify(useritem) + res.setHeader('Content-Type', 'application/json'); + res.status(200).send(users) + }) + } else { + res.status(400).send("Check the request") + } + +} + +var getCoinValue = function (req, res) { + if (req.params.coin != "") { + var oCoin + oCoin = Util.m_getCoinObject({ + Count: 1, + CryptoCoin: req.params.coin, + currency: "INR" + }) + oCoin.then(function (CoinInfo) { + var coinDetail = "💰" + "" + CoinInfo.CoinFN.toUpperCase() + "💰\n\n " + 1 + " " + CoinInfo.CoinSN + " = " + CoinInfo.CoinValue.RAW[CoinInfo.CoinSN][CoinInfo.CoinCurrency].PRICE.toFixed(5) + "\n " + res.setHeader('Content-Type', 'application/text'); + res.status(200).send(coinDetail) + + }).catch(function (err) { + console.log("m_getCoinObject method failed" + err) + }); + } else { + res.status(400).send("Check the request") + } + +} +module.exports = { + welcome: welcome, getCoins: getCoins, deleteUser: deleteUser, getUsers: getUsers, getCoinValue: getCoinValue + +} \ No newline at end of file diff --git a/AllCoinZ/fetchCoin.js b/AllCoinZ/fetchCoin.js index 5c348ad..8326ea1 100644 --- a/AllCoinZ/fetchCoin.js +++ b/AllCoinZ/fetchCoin.js @@ -1,24 +1,26 @@ const coinURL = "https://min-api.cryptocompare.com/data/all/coinlist" const Q = require('q') const request = require('request'); -// const userInfo = require('./db/initialize'); const jsCoin = require('../AllCoinZ/jsonCoin') -// let gUser = userInfo.m_User; function fetchCoins() {} +var alexa = []; function updateCoins(optype) { var deferred = Q.defer(); request(coinURL, function (error, response, body) { -var keyv + var keyv var JSONResponse = JSON.parse(response.body); - var p = JSONResponse.Data; + var p = JSONResponse.Data; var coinarray = []; var CollectionEntityJSON = [] - var csvOp + var csvOp; + + var alexajson; + var notUpdate = optype != undefined && optype != "update" for (var key in p) { if (p.hasOwnProperty(key)) { //console.log(key + " -> " + p[key]); @@ -28,22 +30,47 @@ var keyv n: p[key].Name, c: p[key].CoinName } + coinarray.push(keyv) + if (notUpdate) { + + //csvOp = csvOp + "\n" + parse(p[key].Name) + "\"" + "," + "\"" + parse(p[key].CoinName) + "\"" + "," + "\"" + parse(p[key].Name) + "\"" - var entityJSON = { - "value": parse(p[key].Name), - "synonyms": [ - parse(p[key].CoinName) + "," + parse(p[key].Name) - ] + csvOp = csvOp + "\n" + "\"" + parse(p[key].Name) + "\"" + "," + "\"" + parse(p[key].CoinName) + "\"" //+ "," + "\"" + parse(p[key].Name) + "\"" + csvOp = csvOp + "\n" + "\"" + parse(p[key].Name) + "\"" + "," + "\"" + parse(p[key].Name) + "\"" //+ "," + "\"" + parse(p[key].Name) + "\"" + + var entityJSON = { + "value": parse(p[key].Name), + "synonyms": [ + parse(p[key].CoinName) + "," + parse(p[key].Name) + ] + } + CollectionEntityJSON.push(entityJSON); + + if (!isDuplicate(parse(p[key].CoinName))) { + alexa.push({ + "id": null, + "name": { + "value": parse(p[key].CoinName), + //"synonyms": [parse(p[key].Name) + ',' + parse(p[key].CoinName)] + } + }); + } + if (!isDuplicate(parse(p[key].Name))) { + alexa.push({ + "id": null, + "name": { + "value": parse(p[key].Name), + // "synonyms": [parse(p[key].CoinName) + ',' + parse(p[key].Name)] + } + }); + } } - csvOp = csvOp + "\n" + parse(p[key].Name) + "\"" + "," + "\"" + parse(p[key].CoinName) + "\"" + "," + "\"" + parse(p[key].Name) + "\"" - CollectionEntityJSON.push(entityJSON); - coinarray.push(keyv) } } - csvOp = csvOp.split('undefined').join('') + var jsonCoin = { "Coins": coinarray @@ -53,19 +80,23 @@ var keyv var jsonv = JSON.stringify(jsonCoin) var type = ""; - if (optype != undefined) { + if (optype != undefined && optype != "update") { if (optype.toLowerCase() == "csv") { + csvOp = csvOp.split('undefined').join('') type = csvOp } if (optype.toLowerCase() == "json") { type = JSON.stringify(CollectionEntityJSON) } - jsCoin.m_setCoins(jsonv) + if (optype.toLowerCase() == "alexa") { + type = alexa + } + return deferred.resolve(type) } + jsCoin.m_setCoins(jsonv) - -/* var fs = require('fs'); + var fs = require('fs'); fs.writeFile("AllCryptoCoinZ/data/coinentityCSV.txt", csvOp, function (err) { if (err) { console.log(err); @@ -99,12 +130,20 @@ var keyv }); console.log("The file was saved!"); }); -*/ + }) return deferred.promise } +function isDuplicate(CoinName) { + + return (alexa.find(function (coin) { + return ((coin.name.value.toLowerCase()).trim() == (CoinName.toLowerCase()).trim()) + }) != undefined) + +} + function parse(coin) { return coin.split('(').join('').split(')').join('').split('_').join('').split('@').join('') diff --git a/AllCoinZ/home.html b/AllCoinZ/home.html new file mode 100644 index 0000000..429e13a --- /dev/null +++ b/AllCoinZ/home.html @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AllCoinZ/jsonCoin.js b/AllCoinZ/jsonCoin.js index 86582ec..dbe7dcf 100644 --- a/AllCoinZ/jsonCoin.js +++ b/AllCoinZ/jsonCoin.js @@ -1,22 +1,22 @@ var allcoins; -function setCoins(coins){ - allcoins=JSON.parse(coins) +function setCoins(coins) { + allcoins = JSON.parse(coins) } -var BaseLinkUrl="https://www.cryptocompare.com"; +var BaseLinkUrl = "https://www.cryptocompare.com"; //console.log(JSON.stringify(jsonCoin)); -function findCoin (coinName) { - coinName=coinName.toUpperCase(); +function findCoin(coinName) { + coinName = coinName.toUpperCase(); var coin = allcoins.Coins.filter(function (coin) { - return (coin.c.toUpperCase() == coinName || coin.n.toUpperCase() == coinName) - }); + return (coin.c.toUpperCase() == coinName || coin.n.toUpperCase() == coinName) + }); return coin; } -module.exports={ +module.exports = { -m_setCoins :setCoins, -m_findCoin:findCoin + m_setCoins: setCoins, + m_findCoin: findCoin } \ No newline at end of file diff --git a/AllCoinZ/slack.js b/AllCoinZ/slack.js index 43ea3d4..c458758 100644 --- a/AllCoinZ/slack.js +++ b/AllCoinZ/slack.js @@ -1,24 +1,22 @@ const Util = require('../AllCoinZ/util') -function formatWelcomeMessage(displayName) { - - var message = getPayLoadMessage("\n Hello *" + displayName + "* !!!\n\n *💰All CoinZ - Get CryptoCoins' value in local currencies!!!💰*\n\n `Type in any Coin name like` *BTC* `or` *BitCoin* .\n\n *>*` Can ask interactively : `" + - "\n * -What's the value of XRP* \n * -How much is BTC* \n * -Get me value of ETH and so on..*\n\n *>* `Send` *help* `for help/configuration` \n\n *>*` Set default currency by sending:` \n -*CUR[USD]* / *CURR BTC* / *CUR IND*" - //+"\n aaa" - + "\n \n*>*` Set Portfolio using` :\n - `To Add send` *B 1.23 BTC* \n - `To Remove send` *S 1.00 BTC* \n - `To view current Portfolio send` *VP* \n - `To view Total Porftolio Value send` *PT*" +function getHelp(displayName){ + formatWelcomeMessage(displayName) +} - ) - sendDialogHTTPResponse(message) +function formatWelcomeMessage(displayName) { + + var message = "\n Hello *" + displayName + "* !!!\n\n *💰AllCryptoCoinZ💰* \n *Get CryptoCoins' value in fiat currencies!!!*\n\n `Type in any Coin name like` *BTC* `or` *BitCoin* .\n\n *>*` Can ask interactively : `"+ + "\n * -What's the value of XRP* \n * -How much is BTC* \n * -Get me value of ETH and so on..*\n\n *>* `Send` *help* `for help/configuration` \n\n *>*` Set default currency by sending:` \n -*CUR[USD]* / *CURR BTC* / *CUR IND*" + +"\n\n*>*` Set Portfolio using` :\n - `To Add send` *A 1.23 BTC* \n - `To Deduct send` *R 1.00 BTC* \n - `To view current Portfolio send` *VP* \n - `To view Total Porftolio Value send` *PT*" + sendSimpleMessage(getPayLoadMessage(message)) + } function sendSimpleMessage(message){ - sendDialogHTTPResponse(message) - } - - -function sendDialogHTTPResponse(result) { +function sendDialogHTTPResponse(result){ var HttpResponse = Util.m_getHttpResponse(); HttpResponse.send(result) } @@ -198,10 +196,19 @@ function getPortfolioData(myportfolioData, myCoins) { var slackTPV = getPayLoadMessage("*Total Portfolio Value:*\n" + formatMyPortfoliowithData(myportfolioData, myCoins, Util.m_myCurrency)) sendDialogHTTPResponse(slackTPV) } + + +function formatFallback(){ + sendSimpleMessage("`Please check the keyword or Coin name . Check help for keywords`") + + +} module.exports = { m_formatWelcomeMessage: formatWelcomeMessage, m_ResponseMessage: ResponseMessage, m_getPortfolioData: getPortfolioData, m_getPortfolioInfo: getPortfolioInfo, m_getPayLoadMessage: getPayLoadMessage, - m_sendSimpleMessage:sendSimpleMessage + m_sendSimpleMessage:sendSimpleMessage, + m_formatFallback:formatFallback, + m_getHelp:getHelp } \ No newline at end of file diff --git a/AllCoinZ/telegram.js b/AllCoinZ/telegram.js index b80ae92..85bf4e3 100644 --- a/AllCoinZ/telegram.js +++ b/AllCoinZ/telegram.js @@ -1,20 +1,22 @@ const Util = require('../AllCoinZ/util') + +function gethelp(displayName){ + formatWelcomeMessage(displayName) +} + function formatWelcomeMessage(displayName) { - var cardResponse = Util.m_getDefaultCardMessageResponse(Util.m_platform); - var message = "\n Hello *" + displayName + "* !!!\n\n *💰All CoinZ - Get CryptoCoins' value in local currencies!!!💰*\n\n `Type in any Coin name like` *BTC* `or` *BitCoin* .\n\n *>*` Can ask interactively : `"+ + + var message = "\n Hello *" + displayName + "* !!!\n\n *💰AllCryptoCoinZ💰* \n *Get CryptoCoins' value in fiat currencies!!!*\n\n `Type in any Coin name like` *BTC* `or` *BitCoin* .\n\n *>*` Can ask interactively : `"+ "\n * -What's the value of XRP* \n * -How much is BTC* \n * -Get me value of ETH and so on..*\n\n *>* `Send` *help* `for help/configuration` \n\n *>*` Set default currency by sending:` \n -*CUR[USD]* / *CURR BTC* / *CUR IND*" - +"\n\n*>*` Set Portfolio using` :\n - `To Add send` *B 1.23 BTC* \n - `To Remove send` *S 1.00 BTC* \n - `To view current Portfolio send` *VP* \n - `To view Total Porftolio Value send` *PT*" - cardResponse.messages[0].subtitle = message - sendDialogHTTPResponse(cardResponse) + +"\n\n*>*` Set Portfolio using` :\n - `To Add send` *A 1.23 BTC* \n - `To Dedcut send` *R 1.00 BTC* \n - `To view current Portfolio send` *VP* \n - `To view Total Porftolio Value send` *PT*" + sendSimpleMessage(getPayLoadMessage(message)) + } function sendSimpleMessage(message){ - sendDialogHTTPResponse(message) - } - function sendDialogHTTPResponse(result){ var HttpResponse = Util.m_getHttpResponse(); HttpResponse.send(result) @@ -22,9 +24,7 @@ function sendDialogHTTPResponse(result){ function ResponseMessage(coinResult) { - var responseData = { - "messages": [getCoinInfo(coinResult), { "platform": "telegram", "type": 4, @@ -217,7 +217,10 @@ function getPortfolioInfo(myCoins) { } - + function formatFallback(){ + + sendSimpleMessage("`Please check the keyword or Coin name . Check help for keywords`") + } module.exports = { @@ -226,5 +229,7 @@ module.exports = { m_getPortfolioData: getPortfolioData, m_getPortfolioInfo: getPortfolioInfo, m_getPayLoadMessage:getPayLoadMessage, - m_sendSimpleMessage:sendSimpleMessage + m_sendSimpleMessage:sendSimpleMessage, + m_formatFallback:formatFallback, + m_getHelp:gethelp } \ No newline at end of file diff --git a/AllCoinZ/util.js b/AllCoinZ/util.js index b77c8a0..1cd913b 100644 --- a/AllCoinZ/util.js +++ b/AllCoinZ/util.js @@ -1,18 +1,20 @@ const Q = require('q') -const dbAllCoinZ = require('../db/initialize'); -var gUser = dbAllCoinZ.g_User; +//const dbAllCoinZ = require('../db/initialize'); +const dynamoDB = require('../db/dynamoDB'); + const myCoins = require('../AllCoinZ/jsonCoin'); var platform; -let myCurrency; +var myCurrency; var HttpResponse; -function setHttpResponse(HttpRes){ - HttpResponse=HttpRes +function setHttpResponse(HttpRes) { + HttpResponse = HttpRes } -function getHttpResponse(){ - return HttpResponse; + +function getHttpResponse() { + return HttpResponse; } function removeCurrencySymbols(currency) { @@ -22,9 +24,22 @@ function removeCurrencySymbols(currency) { +function deleteUser(id) { + var deferred = Q.defer(); + dynamoDB.g_deleteUser(id).then(function (item) { + deferred.resolve(item) + }, function (error) { + console.log("Could not fetch" + JSON.stringify(error)) + deferred.reject("Could not fetch" + JSON.stringify(error)) + + }) + + return deferred.promise; +} + function getUsers() { var deferred = Q.defer(); - dbAllCoinZ.g_getRecords(gUser).then(function (item) { + dynamoDB.g_getRecords().then(function (item) { deferred.resolve(item) @@ -41,7 +56,7 @@ function getUsers() { function getCurrency(uniqID) { var deferred = Q.defer(); - dbAllCoinZ.g_getRecord(gUser, { + dynamoDB.g_getRecord({ uniqID: uniqID }).then(function (item) { ////console.log("item " + item) @@ -103,39 +118,37 @@ function getSimpleMessageObject(message) { -function getCoinObject(coinsCount) { +function getCoinObject(CoinInfo) { var speechOutput = "";; var cryptoCoin; var speechOP = ""; + var deferred = Q.defer(); + cryptoCoin = CoinInfo.CryptoCoin; + if (CoinInfo.currency != undefined) { + myCurrency = CoinInfo.currency + } - var deferred = Q.defer(); + if (CoinInfo.found != true) { - cryptoCoin = coinsCount.CryptoCoin; - ////console.log("hello " + JSON.stringify(result.parameters)) + } - console.log("myCurrency" + myCurrency) if (cryptoCoin == undefined || myCurrency == undefined) { speechOP = "Coin or Currency cannot be identified."; - deferred.reject(null); + deferred.reject(speechOP); } else { - //console.log("cryptocoins" + cryptoCoin) - - // for (const key of Object.keys(myCoins)) { - // //console.log(key, myCoins[key]); - // } - - console.log("get coin val" + cryptoCoin) - cryptoCoin = myCoins.m_findCoin(cryptoCoin.toUpperCase());; + if (CoinInfo.found != true) { + cryptoCoin = myCoins.m_findCoin(cryptoCoin.toUpperCase());; + } else { + cryptoCoin = CoinInfo.CryptoCoin + } var BaseLinkUrl = "https://www.cryptocompare.com"; var link = BaseLinkUrl + cryptoCoin[0].u; var ilink = BaseLinkUrl + cryptoCoin[0].iu; - //var baseUrl = 'https://min-api.cryptocompare.com/data/pricemulti?fsyms='; - //var parsedUrl = baseUrl + cryptoCoin[0].n + "&tsyms=" + currency var baseUrl = 'https://min-api.cryptocompare.com/data/pricemultifull?fsyms='; var parsedUrl = baseUrl + cryptoCoin[0].n + "&tsyms=BTC," + myCurrency + "&e=CCCAGG" @@ -146,15 +159,9 @@ function getCoinObject(coinsCount) { var request = require('request'); request(parsedUrl, function (error, response, body) { - //console.log("JSON Response" + JSON.stringify(response.body)) var JSONResponse = JSON.parse(response.body); - ////console.log("JSON Coin Value :"+cryptoCoin[0].n+ ":"+ JSONResponse[cryptoCoin[0].n]); - //console.log(JSONResponse); - var coinValue = "" // JSONResponse[cryptoCoin[0].n.toUpperCase()][currency]; + var coinValue = "" var speechOP = "" - ////console.log("CV" + coinValue); - - if (coinValue != undefined) { oCoin = { CoinFN: cryptoCoin[0].c, @@ -163,20 +170,20 @@ function getCoinObject(coinsCount) { CoinURL: link, CoinValue: JSONResponse, CoinCurrency: myCurrency, - CoinCount: coinsCount.count + CoinCount: CoinInfo.count } deferred.resolve(oCoin); } else { oCoin = null; deferred.reject(null); } - ////console.log(speechOP); + }) } return deferred.promise; } - +var defaultSuggestions = ['BTC', 'XRP', 'ETH', 'ADA', 'Add Coin', 'Deduct Coin', 'Del [x]', 'My Portfolio', 'Set Currency'] module.exports = { @@ -188,6 +195,8 @@ module.exports = { m_getCoinObject: getCoinObject, m_myCurrency: myCurrency, m_getUsers: getUsers, - m_setHttpResponse:setHttpResponse, - m_getHttpResponse:getHttpResponse + m_deleteUser: deleteUser, + m_setHttpResponse: setHttpResponse, + m_getHttpResponse: getHttpResponse, + m_getDefaultSuggestions: defaultSuggestions } \ No newline at end of file diff --git a/README.md b/README.md index e58a041..17654aa 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,3 @@ -Welcome to the AllCryptoCoinZ +Welcome to the SmartCrypto ========================= -Click `Show` in the header to see your app live. Updates to your code will instantly deploy and update live. - -**Glitch** is the friendly commmunity where you'll build the app of your dreams. Glitch lets you instantly create, remix, edit, and host an app, bot or site, and you can invite collaborators or helpers to simultaneously edit code with you. - -Find out more [about Glitch](https://glitch.com/about). - - -Your Project ------------- - -On the front-end, -- edit `public/client.js`, `public/style.css` and `views/index.html` -- drag in `assets`, like images or music, to add them to your project - -On the back-end, -- your app starts at `server.js` -- add frameworks and packages in `package.json` -- safely store app secrets in `.env` (nobody can see this but you and people you invite) - - -Made by [Fog Creek](https://fogcreek.com/) -------------------- - -\ ゜o゜)ノ diff --git a/app.yaml b/app.yaml index f1774cb..8c0ecf2 100644 --- a/app.yaml +++ b/app.yaml @@ -1,2 +1,4 @@ env: flex runtime: nodejs +skip_files: +- ^(.*/)?\.sqlite$ \ No newline at end of file diff --git a/data/ACCImg.png b/data/ACCImg.png new file mode 100644 index 0000000..ece5a51 Binary files /dev/null and b/data/ACCImg.png differ diff --git a/data/AllCryptoCoinZ.sqlite b/data/AllCryptoCoinZ.sqlite deleted file mode 100644 index 6b1dfec..0000000 Binary files a/data/AllCryptoCoinZ.sqlite and /dev/null differ diff --git a/db/dynamoDB.js b/db/dynamoDB.js new file mode 100644 index 0000000..2a31e97 --- /dev/null +++ b/db/dynamoDB.js @@ -0,0 +1,169 @@ +var AWS = require("aws-sdk"); + +AWS.config.update({ + region: "us-west-2", + endpoint: 'https://dynamodb.us-west-2.amazonaws.com',// "http://localhost:8009", + accessKeyId: '', + secretAccessKey: '' +}); + +var dynamodb = new AWS.DynamoDB(); + +var params = { + TableName: "Users", + KeySchema: [ + { AttributeName: "uniqID", KeyType: "HASH" }, //Partition key + + ], + AttributeDefinitions: [ + { AttributeName: "uniqID", AttributeType: "S" }, + + ], + ProvisionedThroughput: { + ReadCapacityUnits: 10, + WriteCapacityUnits: 10 + } +}; + +dynamodb.describeTable({ TableName: 'Users' }, function (err, data) { + if (err) { + dynamodb.createTable(params, function (err, data) { + if (err) { + console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2)); + } else { + console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2)); + } + }); + } + else { + console.log(data); + } +}) + + + +var docClient = new AWS.DynamoDB.DocumentClient() +var table = "Users"; +var displayName = ""; +var curr = ""; +var portfolio = ""; +var uniqID = ""; +var inputs + +var getRecords = function () { + return new Promise((resolve, reject) => { + inputs = { + TableName: table, + Key: { + "displayName": displayName, + "curr": curr, + "portfolio": portfolio, + "uniqID": uniqID, + } + }; + docClient.scan(inputs, function (err, data) { + if (err) { + console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2)); + reject(err) + } else { + console.log("getRecords succeeded:", JSON.stringify(data, null, 2)); + resolve(data) + } + }); + }) +}; + +var getRecord = function (where) { + return new Promise((resolve, reject) => { + inputs = { + TableName: table, + Key: where + }; + docClient.get(inputs, function (err, data) { + if (err) { + console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2)); + reject(err); + } else { + console.log("getRecord succeeded:", JSON.stringify(data, null, 2)); + if (data.Item) { + resolve(data.Item); + } + else { + resolve(null); + } + + } + }); + }) +}; + + +var deleteUsers = function (id) { + return new Promise((resolve, reject) => { + inputs = { + TableName: table, + Key: { uniqID: id } + }; + docClient.delete(inputs, function (err, data) { + if (err) { + console.error("Unable to delete item. Error JSON:", JSON.stringify(err, null, 2)); + reject(err) + } else { + console.log("delete succeeded:", JSON.stringify(data, null, 2)); + resolve(data) + } + }); + }) +}; + + +var updateInsert = function (newItem) { + return new Promise((resolve, reject) => { + + var UpdateExpressionConfigured = "SET " + var ExpressionAttributeValueConfigured = {} + if (newItem.displayName) { + UpdateExpressionConfigured += "displayName=:displayName," + ExpressionAttributeValueConfigured[":displayName"] = newItem.displayName + } + if (newItem.curr) { + UpdateExpressionConfigured += "curr=:curr," + ExpressionAttributeValueConfigured[":curr"] = newItem.curr + } + if (newItem.portfolio) { + UpdateExpressionConfigured += "portfolio=:portfolio," + ExpressionAttributeValueConfigured[":portfolio"] = newItem.portfolio + } + UpdateExpressionConfigured = UpdateExpressionConfigured.substr(0, UpdateExpressionConfigured.length - 1) + inputs = { + TableName: table, + Key: { "uniqID": newItem.uniqID }, + + UpdateExpression: UpdateExpressionConfigured, + ExpressionAttributeValues: ExpressionAttributeValueConfigured, + // ConditionExpression: "uniqID = :uniqID", + ReturnValues: "ALL_NEW" + } + + docClient.update(inputs, function (err, data) { + if (err) { + console.error("Unable to update item. Error JSON:", JSON.stringify(err, null, 2)); + reject(err); + } else { + console.log("UpdateItem succeeded:", JSON.stringify(data, null, 2)); + resolve(data); + } + }) + + }) +} + + +module.exports = { + // g_User: User, + g_getRecord: getRecord, + g_getRecords: getRecords, + // g_createRecord: createRecord, + g_UpdateInsert: updateInsert, + g_deleteUser: deleteUsers +} \ No newline at end of file diff --git a/db/initialize.js b/db/initialize.js index 28730f6..39ecdad 100644 --- a/db/initialize.js +++ b/db/initialize.js @@ -7,7 +7,9 @@ var Sequelize = require('sequelize'); var app = express(); -global.lg = function(message){console.log(message)}; +global.lg = function (message) { + console.log(message) +}; // setup a new database @@ -18,23 +20,23 @@ var sequelize = new Sequelize('AllCryptoCoinZ', process.env.DB_USER, process.env pool: { max: 5, min: 0, - idle: 10000 + idle: 10000 }, - // Security note: the database is saved to the file `database.sqlite` on the local filesystem. It's deliberately placed in the `.data` directory - // which doesn't get copied if someone remixes the project. - //storage: 'D:/MyPersonalWork/2017 December/NewProjects_/Git/AllCryptoCoinZ/AllCryptoCoinZ/data/AllCryptoCoinZ.sqlite' + // Security note: the database is saved to the file `database.sqlite` on the local filesystem. It's deliberately placed in the `.data` directory + // which doesn't get copied if someone remixes the project. + //storage: 'D:/MyPersonalWork/2017 December/NewProjects_/Git/AllCryptoCoinZ/data/AllCryptoCoinZ.sqlite' storage: 'data/AllCryptoCoinZ.sqlite' }); // authenticate with the database sequelize .authenticate() - .then(() => { + .then(() => { console.log('Connection has been established successfully.'); }) .catch(err => { console.error('Unable to connect to the database:', err); - }); + }); @@ -48,12 +50,12 @@ const User = sequelize.define('user', { curr: { type: Sequelize.STRING }, - portfolio:{ - type:Sequelize.STRING + portfolio: { + type: Sequelize.STRING } }); - + User.sync( //{force: true} ); @@ -65,8 +67,8 @@ User.sync( // }, function (error) { // console.log("Value Error" + JSON.stringify(error)) // }) - - + + // User.destroy({ // where: { // uniqID:"U8J0ZPRJR"490302005 @@ -74,67 +76,88 @@ User.sync( // }) // User.find({where:{uniqID:"ABwppHGPMtus_OInPU49GevukD7HE7e-XDr47X8CXS28ftsSq5PMByRWw_Z8PEV0OcMR5cXA8KWt8bFHzA"}}).then(function(success){ - + // console.log(success) // },function(error){console.log(error)}) - + //methods var getRecords = function (model) { - + return model.findAll(); }; -var getRecord = function (model,where) { +var getRecord = function (model, where) { return model.find({ - where: where + where: where }); }; -var createRecord = function (model,item) { - model.create(item).then(function(error){ - - - },function(error){ - +var createRecord = function (model, item) { + model.create(item).then(function (error) { + + + }, function (error) { + }); }; +// User.destroy({ +// where: { +// uniqID:"U8J0ZPRJR"490302005 +// } +// }) + +var deleteUsers = function (model, id) { + if (id == "all") { + return model.destroy({ + where:{} + }); + } else { + return model.destroy({ + where: { + id: id + } + }); + } +}; + var updateInsert = function (model, where, newItem) { -return model.findOne({ - where: where + return model.findOne({ + where: where }).then(function (item) { - - if (!item) { - console.log("Item Not Found"); - return model.create(newItem).then(function (item) { - return { - item: item, - created: true - } - }) - } else { - console.log("Item Found"); - return model.update(newItem, { - where: where - }).then(function (item) { - return { - item: item, - created: false - } - - }) - } + + if (!item) { + console.log("Item Not Found"); + return model.create(newItem).then(function (item) { + return { + item: item, + created: true + } + }) + } else { + console.log("Item Found"); + return model.update(newItem, { + where: where + }).then(function (item) { + return { + item: item, + created: false + } + + }) + } }) } module.exports = { - g_User:User, - g_getRecord:getRecord, - g_getRecords:getRecords, - g_createRecord:createRecord, - g_UpdateInsert:updateInsert, -} + g_User: User, + g_getRecord: getRecord, + g_getRecords: getRecords, + g_createRecord: createRecord, + g_UpdateInsert: updateInsert, + g_deleteUser: deleteUsers +} \ No newline at end of file diff --git a/my-folder/extra b/my-folder/extra deleted file mode 100644 index 213848d..0000000 --- a/my-folder/extra +++ /dev/null @@ -1,411 +0,0 @@ - - - - - gapp.askWithList(gapp.buildRichResponse() - .addSimpleResponse("My Portfolio: "+op+"") - .addSuggestions( - ['Total Value']), - - // Build a list - gapp.buildList('Things to learn about') - // Add the first item to the list - .addItems(gapp.buildOptionItem('MATH_AND_PRIME1', - ['math', 'math and prime', 'prime numbers', 'prime']) - .setTitle('1 BTC')) - .addItems(gapp.buildOptionItem('MATH_AND_PRIME2', - ['2']) - .setTitle('2 BTC')) - .addItems(gapp.buildOptionItem('MATH_AND_PRIME3', - ['3']) - .setTitle('3 BTC')) - .addItems(gapp.buildOptionItem('MATH_AND_PRIME4', - ['4']) - .setTitle('4 BTC')) - .addItems(gapp.buildOptionItem('MATH_AND_PRIME5', - ['5']) - .setTitle('5 BTC')) - .addItems(gapp.buildOptionItem('MATH_AND_PRIME55', - ['6']) - .setTitle('6 BTC')) - - - - - // Add the second item to the list - // .addItems(gapp.buildOptionItem('EGYPT', - // ['religion', 'egpyt', 'ancient egyptian']) - // .setTitle('Ancient Egyptian religion') - // .setDescription('42 gods who ruled on the fate of the dead in the ' + - // 'afterworld. Throughout the under…') - // .setImage('http://example.com/egypt', 'Egypt') - // ) - // // Add third item to the list - // .addItems(gapp.buildOptionItem('RECIPES', - // ['recipes', 'recipe', '42 recipes']) - // .setTitle('42 recipes with 42 ingredients') - // .setDescription('Here\'s a beautifully simple recipe that\'s full ' + - // 'of flavor! All you need is some ginger and…') - // .setImage('http://example.com/recipe', 'Recipe') ) - ); - - -var display = { - "DISPLAY": { - "BTC": { - "USD": { - "FROMSYMBOL": "Ƀ", - "TOSYMBOL": "$", - "MARKET": "CryptoCompare Index", - "PRICE": "$ 14,624.3", - "LASTUPDATE": "Just now", - "LASTVOLUME": "Ƀ 0.05483", - "LASTVOLUMETO": "$ 799.39", - "LASTTRADEID": "145826016", - "VOLUMEDAY": "Ƀ 84,958.0", - "VOLUMEDAYTO": "$ 1,238,574,452.6", - "VOLUME24HOUR": "Ƀ 123,694.2", - "VOLUME24HOURTO": "$ 1,780,576,820.0", - "OPENDAY": "$ 14,398.7", - "HIGHDAY": "$ 15,109.8", - "LOWDAY": "$ 13,951.1", - "OPEN24HOUR": "$ 13,960.0", - "HIGH24HOUR": "$ 15,147.8", - "LOW24HOUR": "$ 13,443.7", - "LASTMARKET": "Bitfinex", - "CHANGE24HOUR": "$ 664.23", - "CHANGEPCT24HOUR": "4.76", - "CHANGEDAY": "$ 225.57", - "CHANGEPCTDAY": "1.57", - "SUPPLY": "Ƀ 16,769,875.0", - "MKTCAP": "$ 245.25 B", - "TOTALVOLUME24H": "Ƀ 324.93 K", - "TOTALVOLUME24HTO": "$ 4,723.44 M" - } - } - } - } - -// var defaultdata = { -// "speech": "hello", -// "messages": [ -// { -// "type": 1, -// "platform": "telegram", -// "title": cryptoCoin[0].c +"("+cryptoCoin[0].n+")", -// "subtitle": "\n\n*"+cryptoCoin[0].c +"("+cryptoCoin[0].n+")*"+ " is " + "*"+coinValue + " " + currency+"*", -// "imageUrl": ilink, -// "buttons": [ -// { -// "text": "View Profile", -// "postback": link -// } -// ] -// }, -// { -// "type": 1, -// "speech": "hello" -// } -// ] -// } - - - - - -//console.log("Value" + gUser) - -// dbAllCoinZ.g_createRecord(gUser,{ -// displayName: "rahul", -// uniqID: 1234, -// curr: "INR" -// }) - - -// dbAllCoinZ.g_UpdateInsert(gUser,{uniqID:123456},{ -// displayName: "mrrahul", -// uniqID: 12345, -// curr: "INR" -// // }) - -// var a = dbAllCoinZ.g_getRecords(gUser); -// a.then(function (success) { -// //console.log("Value" + JSON.stringify(success)) -// }, function (error) { -// //console.log("Value" + JSON.stringify(error)) -// }) - - - - // const app = new ApiAiApp({ - // req, - // res - // }); - - ////console.log(JSON.stringify(req.headers)) - ////console.log(JSON.stringify(req.body)) - -// dbAllCoinZ.g_getRecords(gUser, { -// displayName: "rahul", -// uniqID: 1234, -// curr: "INR" -// }).then(function (items) { -// console.log(JSON.stringify(items)) - -// }) - - - - - - - - - - -server.post('/getCoinValue', function (req, res) { - - - console.log(JSON.stringify(req.result)) - - let result = req.body.result; - let source = req.body.originalRequest.source - - //console.log(JSON.stringify(req.body.originalRequest)) - ////console.log(result.metadata.intentName) - // console.log(JSON.stringify(req.body)) - - - switch (source) { - case "telegram": - platform = "telegram" - displayName = (req.body).originalRequest.data.message.chat.username; - uniqID = (req.body).originalRequest.data.message.chat.id - break; - case "slack_testbot": - displayName = (req.body).originalRequest.data.user; - uniqID = (req.body).originalRequest.data.user; - platform = "slack" - break; - case "skype": - platform = "skype" - break; - default: - platform = "telegram" - } - Util.m_platform = platform - - - - if (result.metadata.intentName == "1ViewPortfolio") { - - GenProc.m_getTotalPortfolioValue({ - displayName, - uniqID - }, false).then(function (VPortfolio) { - sendDialogflowResponse(res, VPortfolio) - - }, function (error) { - console.log(error); - sendDialogflowResponse(res, error) - }) - } else if (result.metadata.intentName == "1TotalPortfolioValue") { - //var welcomeMessageResponse = GenProc.m_getWelcomeMessage(platform,displayName) - //sendDialogflowResponse(res, welcomeMessageResponse) - GenProc.m_getTotalPortfolioValue({ - displayName, - uniqID - }, true) - .then(function (TPV) { - console.log("aaa" + TPV) - sendDialogflowResponse(res, TPV) - }, - function (error) { - console.log(error); - sendDialogflowResponse(res, error) - }) - - - - - - } else if (result.metadata.intentName == "BuySellCoin") { - - - - } else if (result.metadata.intentName == "Default Welcome Intent" || result.metadata.intentName =="help") { - - } else if (result.metadata.intentName == "getCoinValue") { - - Util.m_getCurrency(uniqID).then(function () { - - var count = 1; - if (result.parameters.count != "") { - count = result.parameters.count - } - - var oCoin = Util.m_getCoinObject({ - count: count, - CryptoCoin: result.parameters.CryptoCoin - }) - oCoin.then(function (coinResult) { - sendResult(true, coinResult, res) - }).catch(function (err) { - console.log("m_getCurrency method failed") - }); - }) - - } else if (result.metadata.intentName == "ChangeCurrency") { - - - } else if (result.metadata.intentName == "Default Fallback Intent") { - - - //sendResult(false, null, res) - } - - -}); - - - - - -function ResponseMessage(a){ - -var mess= { - speech:"telegram", - - "messages": [ - { - "speech": "content to be read aloud", /* this is the message required by Api.AI's web interface */ - "type": 0 - }, - - // Below are the Actions Rich Messages - { - "platform": "google", - "type": "simple_response", - "displayText": "top level text", /* basic top text used for screen devices */ - "textToSpeech": "can voice speech to be read out loud" /* only used for voice interface */ - }, - { - "platform": "google", - "type": "basic_card", - "title": "title text", - "subtitle": "subtitle text", - "formattedText": "text with newlines and such", - "image": { - "url": "http://example.com/image.png", - "accessibilityText": "image descrition for screen readers" /* this property is now required */ - }, - "buttons": [ - { - "title": "Link title", - "openUrlAction": { - "url": "https://example.com/linkout.html" - } - } - ] - }, - { - "platform": "google", - "type": "suggestion_chips", - "suggestions": [ - { - "title": "Next" - }, - { - "title": "Previous" - }, - { - "title": "Return to Results" - } - ] - } - ]} - - -var HttpResponse = Util.m_getHttpResponse(); - HttpResponse.send(mess) - -} - - - - - - - -// var responseData = { - -// "messages": [getCoinInfo(coinResult), { -// "platform": "telegram", -// "type": 4, -// payload: { -// "telegram": { -// "text": "⚡ Please select next coin...", //\n\n["+link +"]",, -// //photo:coinResult.CoinImg, -// parse_mode: "HTML", -// disable_web_page_preview: false, -// "title": "AllCoinZ", -// "reply_markup": { -// "keyboard": [ -// [{ -// "text": "BTC" - -// }, { -// "text": "ETH" - -// }, { -// "text": "XRP" - -// }, { -// "text": "PINK" - -// }, { -// "text": "DOGE" -// }, { -// "text": "IOTA" -// }], -// [{ -// "text": "ETN" -// }, { -// "text": "XLM" -// }, { -// "text": "XVG" -// }, { -// "text": "ADA" -// }, { -// "text": "BCH" -// }, { -// "text": "TRX" -// }], -// [{ -// "text": "C[USD]" -// }, { -// "text": "C[INR]" -// }, { -// "text": "View Portfolio" -// }, { -// "text": "Portfolio Total" -// }, -// //{ -// // "text": "CUR[BTC]" -// // }, { -// // "text": "CUR[EUR]" -// // } -// ] - -// ], -// resize_keyboard: true - -// } -// } -// } -// }] - -// } - -// //console.log(responseData) -// return responseData; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..9465208 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,2162 @@ +{ + "name": "my-glitch-app", + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/geojson": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-1.0.6.tgz", + "integrity": "sha512-Xqg/lIZMrUd0VRmSRbCAewtwGZiAk3mEUDvV4op1tGl+LvyPcb/MIOSxTl9z+9+J+R4/vpjiCAT4xeKzH9ji1w==" + }, + "@types/node": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-9.3.0.tgz", + "integrity": "sha512-wNBfvNjzsJl4tswIZKXCFQY0lss9nKUyJnG6T94X/eqjRgI2jHZ4evdjhQYBSan/vGtF6XVXPApOmNH2rf0KKw==" + }, + "accepts": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz", + "integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=", + "requires": { + "mime-types": "2.1.17", + "negotiator": "0.6.1" + } + }, + "actions-on-google": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/actions-on-google/-/actions-on-google-1.7.0.tgz", + "integrity": "sha512-T9JIIs5uvPHPkKbVqAFZcRGPWO/HB9XGBi+5Ov8z/ATu2x3iFhrCO5o80KsTN8E9VRxI9oXo6kkfU5MaYDOvJw==", + "requires": { + "debug": "2.6.9", + "google-auth-library": "0.10.0", + "lodash.camelcase": "4.3.0", + "lodash.snakecase": "4.1.1" + } + }, + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "requires": { + "co": "4.6.0", + "fast-deep-equal": "1.0.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" + } + }, + "alexa-sdk": { + "version": "1.0.25", + "resolved": "https://registry.npmjs.org/alexa-sdk/-/alexa-sdk-1.0.25.tgz", + "integrity": "sha512-+FVFNi+mxBZm2HL+oi5u4JTNjQ2uDs4Tp9eqcWIxL3AAD+AU4a6gWpu6LEjxIVCqaI1Ro/RyDm3mnJZA9g6G8w==", + "requires": { + "aws-sdk": "2.188.0", + "i18next": "3.5.2", + "i18next-sprintf-postprocessor": "0.2.2" + } + }, + "alexa-verifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/alexa-verifier/-/alexa-verifier-1.0.0.tgz", + "integrity": "sha512-1XE/40ajf4sESuvAdacxVrxy06tkewC2sJ8qC5T/zQtGiYRsuoQjj6UkSpw7WTqG8wkmESANz/w5NnfIruyCjQ==", + "requires": { + "node-forge": "0.7.1", + "validator": "9.2.0" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" + }, + "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-sdk": { + "version": "2.188.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.188.0.tgz", + "integrity": "sha1-kGKrx9umOTRZ+i80I89dKU8ARhE=", + "requires": { + "buffer": "4.9.1", + "events": "1.1.1", + "jmespath": "0.15.0", + "querystring": "0.2.0", + "sax": "1.2.1", + "url": "0.10.3", + "uuid": "3.1.0", + "xml2js": "0.4.17", + "xmlbuilder": "4.2.1" + } + }, + "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.6.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", + "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "base64-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz", + "integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw==" + }, + "base64url": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/base64url/-/base64url-2.0.0.tgz", + "integrity": "sha1-6sFuA+oUOO/5Qj1puqNiYu0fcLs=" + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", + "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" + }, + "body-parser": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", + "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "1.0.4", + "debug": "2.6.9", + "depd": "1.1.2", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "on-finished": "2.3.0", + "qs": "6.5.1", + "raw-body": "2.3.2", + "type-is": "1.6.15" + } + }, + "boom": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", + "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", + "requires": { + "hoek": "4.2.0" + } + }, + "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" + } + }, + "browser-stdout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", + "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=" + }, + "buffer": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "requires": { + "base64-js": "1.2.1", + "ieee754": "1.1.8", + "isarray": "1.0.0" + } + }, + "buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=" + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "cls-bluebird": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cls-bluebird/-/cls-bluebird-2.1.0.tgz", + "integrity": "sha1-N+8eCAqP+1XC9BZPU28ZGeeWiu4=", + "requires": { + "is-bluebird": "1.0.2", + "shimmer": "1.2.0" + } + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, + "colors": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", + "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=" + }, + "combined-stream": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "requires": { + "delayed-stream": "1.0.0" + } + }, + "commander": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "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=" + }, + "cryptiles": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", + "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", + "requires": { + "boom": "5.2.0" + }, + "dependencies": { + "boom": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", + "requires": { + "hoek": "4.2.0" + } + } + } + }, + "d": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", + "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", + "requires": { + "es5-ext": "0.10.37" + } + }, + "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": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "diff": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz", + "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==" + }, + "dottie": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.0.tgz", + "integrity": "sha1-2hkZgci41xPKARXViYzzl8Lw3dA=" + }, + "ecc-jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", + "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "ecdsa-sig-formatter": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.9.tgz", + "integrity": "sha1-S8kmJ07Dtau1AW5+HWCSGsJisqE=", + "requires": { + "base64url": "2.0.0", + "safe-buffer": "5.1.1" + } + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "encodeurl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", + "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=" + }, + "es5-ext": { + "version": "0.10.37", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.37.tgz", + "integrity": "sha1-DudB0Ui4AGm6J9AgOTdWryV978M=", + "requires": { + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1" + } + }, + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.37", + "es6-symbol": "3.1.1" + } + }, + "es6-map": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.5.tgz", + "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.37", + "es6-iterator": "2.0.3", + "es6-set": "0.1.5", + "es6-symbol": "3.1.1", + "event-emitter": "0.3.5" + } + }, + "es6-set": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", + "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.37", + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1", + "event-emitter": "0.3.5" + } + }, + "es6-symbol": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", + "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.37" + } + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.37" + } + }, + "events": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", + "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" + }, + "express": { + "version": "4.16.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.2.tgz", + "integrity": "sha1-41xt/i1kt9ygpc1PIXgb4ymeB2w=", + "requires": { + "accepts": "1.3.4", + "array-flatten": "1.1.1", + "body-parser": "1.18.2", + "content-disposition": "0.5.2", + "content-type": "1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "1.1.2", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "etag": "1.8.1", + "finalhandler": "1.1.0", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "1.1.2", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "2.0.2", + "qs": "6.5.1", + "range-parser": "1.2.0", + "safe-buffer": "5.1.1", + "send": "0.16.1", + "serve-static": "1.13.1", + "setprototypeof": "1.1.0", + "statuses": "1.3.1", + "type-is": "1.6.15", + "utils-merge": "1.0.1", + "vary": "1.1.2" + }, + "dependencies": { + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" + } + } + }, + "extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", + "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "fast-deep-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", + "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=" + }, + "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=" + }, + "finalhandler": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", + "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", + "requires": { + "debug": "2.6.9", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "statuses": "1.3.1", + "unpipe": "1.0.0" + }, + "dependencies": { + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" + } + } + }, + "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.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", + "integrity": "sha1-b7lPvXGIUwbXPRXMSX/kzE7NRL8=", + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.17" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "generic-pool": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.4.0.tgz", + "integrity": "sha512-lYsIpjkyNBnRLKrcnJlXTEXB2ISmK9g7N4WqWwXbvr+tVB1+raaFnHoCYecWnuCo/XGHgM935WOWmr5Zx3tJKw==" + }, + "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.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "google-auth-library": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-0.10.0.tgz", + "integrity": "sha1-bhW6vuhf0d0U2NEoopW2g41SE24=", + "requires": { + "gtoken": "1.2.3", + "jws": "3.1.4", + "lodash.noop": "3.0.1", + "request": "2.83.0" + } + }, + "google-p12-pem": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-0.1.2.tgz", + "integrity": "sha1-M8RqsCGqc0+gMys5YKmj/8svMXc=", + "requires": { + "node-forge": "0.7.1" + } + }, + "growl": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==" + }, + "gtoken": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-1.2.3.tgz", + "integrity": "sha512-wQAJflfoqSgMWrSBk9Fg86q+sd6s7y6uJhIvvIPz++RElGlMtEqsdAR2oWwZ/WTEtp7P9xFbJRrT976oRgzJ/w==", + "requires": { + "google-p12-pem": "0.1.2", + "jws": "3.1.4", + "mime": "1.6.0", + "request": "2.83.0" + } + }, + "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.0.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", + "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", + "requires": { + "ajv": "5.5.2", + "har-schema": "2.0.0" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" + }, + "hawk": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", + "requires": { + "boom": "4.3.1", + "cryptiles": "3.1.2", + "hoek": "4.2.0", + "sntp": "2.1.0" + } + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" + }, + "hoek": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz", + "integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ==" + }, + "http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "requires": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": "1.4.0" + }, + "dependencies": { + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" + } + } + }, + "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.4.1", + "sshpk": "1.13.1" + } + }, + "i18next": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-3.5.2.tgz", + "integrity": "sha1-kwOQ1cMYzqpIWLUt0OQOayA/n0E=" + }, + "i18next-sprintf-postprocessor": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/i18next-sprintf-postprocessor/-/i18next-sprintf-postprocessor-0.2.2.tgz", + "integrity": "sha1-LkCfEENXk4Jpi2otpwzapVHWfqQ=" + }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" + }, + "ieee754": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", + "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=" + }, + "inflection": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/inflection/-/inflection-1.12.0.tgz", + "integrity": "sha1-ogCTVlbW9fa8TcdQLhrstwMihBY=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ipaddr.js": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.5.2.tgz", + "integrity": "sha1-1LUFvemUaYfM8PxY2QEP+WB+P6A=" + }, + "is-bluebird": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-bluebird/-/is-bluebird-1.0.2.tgz", + "integrity": "sha1-CWQ5Bg9KpBGr7hkUOoTWpVNG1uI=" + }, + "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=" + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "jmespath": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", + "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "optional": true + }, + "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.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + }, + "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=" + }, + "jsonwebtoken": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.1.1.tgz", + "integrity": "sha512-+ijVOtfLMlCII8LJkvabaKX3+8tGrGjiCTfzoed2D1b/ebKTO1hIYBQUJHbd9dJ9Fa4kH+dhYEd1qDwyzDLUUw==", + "requires": { + "jws": "3.1.4", + "lodash.includes": "4.3.0", + "lodash.isboolean": "3.0.3", + "lodash.isinteger": "4.0.4", + "lodash.isnumber": "3.0.3", + "lodash.isplainobject": "4.0.6", + "lodash.isstring": "4.0.1", + "lodash.once": "4.1.1", + "ms": "2.1.1", + "xtend": "4.0.1" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, + "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" + } + }, + "jwa": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.1.5.tgz", + "integrity": "sha1-oFUs4CIHQs1S4VN3SjKQXDDnVuU=", + "requires": { + "base64url": "2.0.0", + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.9", + "safe-buffer": "5.1.1" + } + }, + "jws": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.1.4.tgz", + "integrity": "sha1-+ei5M46KhHJ31kRLFGT2GIDgUKI=", + "requires": { + "base64url": "2.0.0", + "jwa": "1.1.5", + "safe-buffer": "5.1.1" + } + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + }, + "lodash.camelcase": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", + "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=" + }, + "lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8=" + }, + "lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY=" + }, + "lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha1-YZwK89A/iwTDH1iChAt3sRzWg0M=" + }, + "lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w=" + }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" + }, + "lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=" + }, + "lodash.noop": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash.noop/-/lodash.noop-3.0.1.tgz", + "integrity": "sha1-OBiPTWUKOkdCWEObluxFsyYXEzw=" + }, + "lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=" + }, + "lodash.snakecase": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz", + "integrity": "sha1-OdcUo1NXFHg3rv1ktdy7Fr7Nj40=" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + }, + "mime-db": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", + "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" + }, + "mime-types": { + "version": "2.1.17", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", + "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", + "requires": { + "mime-db": "1.30.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.11" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, + "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" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + } + } + }, + "mocha": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.1.tgz", + "integrity": "sha512-SpwyojlnE/WRBNGtvJSNfllfm5PqEDFxcWluSIgLeSBJtXG4DmoX2NNAeEA7rP5kK+79VgtVq8nG6HskaL1ykg==", + "requires": { + "browser-stdout": "1.3.0", + "commander": "2.11.0", + "debug": "3.1.0", + "diff": "3.3.1", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.3", + "he": "1.1.1", + "mkdirp": "0.5.1", + "supports-color": "4.4.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "moment": { + "version": "2.20.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.20.1.tgz", + "integrity": "sha512-Yh9y73JRljxW5QxN08Fner68eFLxM5ynNOAw2LbIB1YAGeQzZT8QFSUvkAz609Zf+IHhhaUxqZK8dG3W/+HEvg==" + }, + "moment-timezone": { + "version": "0.5.14", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.14.tgz", + "integrity": "sha1-TrOP+VOLgBCLpGekWPPtQmjM/LE=", + "requires": { + "moment": "2.20.1" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "nan": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz", + "integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY=" + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + }, + "node-forge": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.1.tgz", + "integrity": "sha1-naYR6giYL0uUIGs760zJZl8gwwA=" + }, + "oauth-sign": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1.0.2" + } + }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + }, + "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=" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "prettyjson": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prettyjson/-/prettyjson-1.2.1.tgz", + "integrity": "sha1-/P+rQdGcq0365eV15kJGYZsS0ok=", + "requires": { + "colors": "1.1.2", + "minimist": "1.2.0" + } + }, + "proxy-addr": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.2.tgz", + "integrity": "sha1-ZXFQT0e7mI7IGAJT+F3X4UlSvew=", + "requires": { + "forwarded": "0.1.2", + "ipaddr.js": "1.5.2" + } + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + }, + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" + }, + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + }, + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "raw-body": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", + "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "unpipe": "1.0.0" + } + }, + "request": { + "version": "2.83.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz", + "integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==", + "requires": { + "aws-sign2": "0.7.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.3.1", + "har-validator": "5.0.3", + "hawk": "6.0.2", + "http-signature": "1.2.0", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.17", + "oauth-sign": "0.8.2", + "performance-now": "2.1.0", + "qs": "6.5.1", + "safe-buffer": "5.1.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.3", + "tunnel-agent": "0.6.0", + "uuid": "3.1.0" + } + }, + "retry-as-promised": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-2.3.2.tgz", + "integrity": "sha1-zZdO5P2bX+A8vzGHHuSCIcB3N7c=", + "requires": { + "bluebird": "3.5.1", + "debug": "2.6.9" + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "sax": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", + "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" + }, + "semver": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", + "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==" + }, + "send": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.1.tgz", + "integrity": "sha512-ElCLJdJIKPk6ux/Hocwhk7NFHpI3pVm/IZOYWqUmoxcgeyM+MpxHHKhb8QmlJDX1pU6WrgaHBkVNm73Sv7uc2A==", + "requires": { + "debug": "2.6.9", + "depd": "1.1.2", + "destroy": "1.0.4", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "etag": "1.8.1", + "fresh": "0.5.2", + "http-errors": "1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "2.3.0", + "range-parser": "1.2.0", + "statuses": "1.3.1" + }, + "dependencies": { + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" + } + } + }, + "sequelize": { + "version": "4.31.2", + "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-4.31.2.tgz", + "integrity": "sha512-ldbh1tNPpeFZ30bWAW0HqW2rinjmCmvb2lqRQ/TxhjIT70ypnQzFhBjXeIxZDFtov5koaw9NTbaOwJQn8nkYgA==", + "requires": { + "bluebird": "3.5.1", + "cls-bluebird": "2.1.0", + "debug": "3.1.0", + "depd": "1.1.2", + "dottie": "2.0.0", + "generic-pool": "3.4.0", + "inflection": "1.12.0", + "lodash": "4.17.4", + "moment": "2.20.1", + "moment-timezone": "0.5.14", + "retry-as-promised": "2.3.2", + "semver": "5.4.1", + "terraformer-wkt-parser": "1.1.2", + "toposort-class": "1.0.1", + "uuid": "3.1.0", + "validator": "9.2.0", + "wkx": "0.4.2" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "serve-static": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.1.tgz", + "integrity": "sha512-hSMUZrsPa/I09VYFJwa627JJkNs0NrfL1Uzuup+GqHfToR2KcsXFymXSV90hoyw3M+msjFuQly+YzIH/q0MGlQ==", + "requires": { + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "parseurl": "1.3.2", + "send": "0.16.1" + } + }, + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + }, + "shimmer": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.0.tgz", + "integrity": "sha512-xTCx2vohXC2EWWDqY/zb4+5Mu28D+HYNSOuFzsyRDRvI/e1ICb69afwaUwfjr+25ZXldbOLyp+iDUZHq8UnTag==" + }, + "sntp": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", + "requires": { + "hoek": "4.2.0" + } + }, + "sprintf-js": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.1.tgz", + "integrity": "sha1-Nr54Mgr+WAH2zqPueLblqrlA6gw=" + }, + "sqlite3": { + "version": "3.1.13", + "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-3.1.13.tgz", + "integrity": "sha512-JxXKPJnkZ6NuHRojq+g2WXWBt3M1G9sjZaYiHEWSTGijDM3cwju/0T2XbWqMXFmPqDgw+iB7zKQvnns4bvzXlw==", + "requires": { + "nan": "2.7.0", + "node-pre-gyp": "0.6.38" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "bundled": true + }, + "ajv": { + "version": "4.11.8", + "bundled": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true + }, + "aproba": { + "version": "1.2.0", + "bundled": true + }, + "are-we-there-yet": { + "version": "1.1.4", + "bundled": true, + "requires": { + "delegates": "1.0.0", + "readable-stream": "2.3.3" + } + }, + "asn1": { + "version": "0.2.3", + "bundled": true + }, + "assert-plus": { + "version": "0.2.0", + "bundled": true + }, + "asynckit": { + "version": "0.4.0", + "bundled": true + }, + "aws-sign2": { + "version": "0.6.0", + "bundled": true + }, + "aws4": { + "version": "1.6.0", + "bundled": true + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "bundled": true, + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "block-stream": { + "version": "0.0.9", + "bundled": true, + "requires": { + "inherits": "2.0.3" + } + }, + "boom": { + "version": "2.10.1", + "bundled": true, + "requires": { + "hoek": "2.16.3" + } + }, + "brace-expansion": { + "version": "1.1.8", + "bundled": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "caseless": { + "version": "0.12.0", + "bundled": true + }, + "co": { + "version": "4.6.0", + "bundled": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true + }, + "combined-stream": { + "version": "1.0.5", + "bundled": true, + "requires": { + "delayed-stream": "1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "bundled": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true + }, + "cryptiles": { + "version": "2.0.5", + "bundled": true, + "requires": { + "boom": "2.10.1" + } + }, + "dashdash": { + "version": "1.14.1", + "bundled": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true + } + } + }, + "debug": { + "version": "2.6.9", + "bundled": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.4.2", + "bundled": true + }, + "delayed-stream": { + "version": "1.0.0", + "bundled": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true + }, + "ecc-jsbn": { + "version": "0.1.1", + "bundled": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "extend": { + "version": "3.0.1", + "bundled": true + }, + "extsprintf": { + "version": "1.3.0", + "bundled": true + }, + "forever-agent": { + "version": "0.6.1", + "bundled": true + }, + "form-data": { + "version": "2.1.4", + "bundled": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.17" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true + }, + "fstream": { + "version": "1.0.11", + "bundled": true, + "requires": { + "graceful-fs": "4.1.11", + "inherits": "2.0.3", + "mkdirp": "0.5.1", + "rimraf": "2.6.2" + } + }, + "fstream-ignore": { + "version": "1.0.5", + "bundled": true, + "requires": { + "fstream": "1.0.11", + "inherits": "2.0.3", + "minimatch": "3.0.4" + } + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "requires": { + "aproba": "1.2.0", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" + } + }, + "getpass": { + "version": "0.1.7", + "bundled": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true + } + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "bundled": true + }, + "har-schema": { + "version": "1.0.5", + "bundled": true + }, + "har-validator": { + "version": "4.2.1", + "bundled": true, + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true + }, + "hawk": { + "version": "3.1.3", + "bundled": true, + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "hoek": { + "version": "2.16.3", + "bundled": true + }, + "http-signature": { + "version": "1.1.1", + "bundled": true, + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.1", + "sshpk": "1.13.1" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true + }, + "ini": { + "version": "1.3.4", + "bundled": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "bundled": true + }, + "isarray": { + "version": "1.0.0", + "bundled": true + }, + "isstream": { + "version": "0.1.2", + "bundled": true + }, + "jsbn": { + "version": "0.1.1", + "bundled": true, + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "bundled": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "bundled": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "bundled": true + }, + "jsonify": { + "version": "0.0.0", + "bundled": true + }, + "jsprim": { + "version": "1.4.1", + "bundled": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true + } + } + }, + "mime-db": { + "version": "1.30.0", + "bundled": true + }, + "mime-types": { + "version": "2.1.17", + "bundled": true, + "requires": { + "mime-db": "1.30.0" + } + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true + }, + "node-pre-gyp": { + "version": "0.6.38", + "bundled": true, + "requires": { + "hawk": "3.1.3", + "mkdirp": "0.5.1", + "nopt": "4.0.1", + "npmlog": "4.1.2", + "rc": "1.2.1", + "request": "2.81.0", + "rimraf": "2.6.2", + "semver": "5.4.1", + "tar": "2.2.1", + "tar-pack": "3.4.0" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "requires": { + "abbrev": "1.1.1", + "osenv": "0.1.4" + } + }, + "npmlog": { + "version": "4.1.2", + "bundled": true, + "requires": { + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true + }, + "oauth-sign": { + "version": "0.8.2", + "bundled": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true + }, + "osenv": { + "version": "0.1.4", + "bundled": true, + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true + }, + "performance-now": { + "version": "0.2.0", + "bundled": true + }, + "process-nextick-args": { + "version": "1.0.7", + "bundled": true + }, + "punycode": { + "version": "1.4.1", + "bundled": true + }, + "qs": { + "version": "6.4.0", + "bundled": true + }, + "rc": { + "version": "1.2.1", + "bundled": true, + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.4", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true + } + } + }, + "readable-stream": { + "version": "2.3.3", + "bundled": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "request": { + "version": "2.81.0", + "bundled": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.17", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.1.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.3", + "tunnel-agent": "0.6.0", + "uuid": "3.1.0" + } + }, + "rimraf": { + "version": "2.6.2", + "bundled": true, + "requires": { + "glob": "7.1.2" + } + }, + "safe-buffer": { + "version": "5.1.1", + "bundled": true + }, + "semver": { + "version": "5.4.1", + "bundled": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true + }, + "sntp": { + "version": "1.0.9", + "bundled": true, + "requires": { + "hoek": "2.16.3" + } + }, + "sshpk": { + "version": "1.13.1", + "bundled": true, + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true + } + } + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "1.0.3", + "bundled": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "stringstream": { + "version": "0.0.5", + "bundled": true + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true + }, + "tar": { + "version": "2.2.1", + "bundled": true, + "requires": { + "block-stream": "0.0.9", + "fstream": "1.0.11", + "inherits": "2.0.3" + } + }, + "tar-pack": { + "version": "3.4.0", + "bundled": true, + "requires": { + "debug": "2.6.9", + "fstream": "1.0.11", + "fstream-ignore": "1.0.5", + "once": "1.4.0", + "readable-stream": "2.3.3", + "rimraf": "2.6.2", + "tar": "2.2.1", + "uid-number": "0.0.6" + } + }, + "tough-cookie": { + "version": "2.3.3", + "bundled": true, + "requires": { + "punycode": "1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "bundled": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "bundled": true, + "optional": true + }, + "uid-number": { + "version": "0.0.6", + "bundled": true + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true + }, + "uuid": { + "version": "3.1.0", + "bundled": true + }, + "verror": { + "version": "1.10.0", + "bundled": true, + "requires": { + "assert-plus": "1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "1.3.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true + } + } + }, + "wide-align": { + "version": "1.1.2", + "bundled": true, + "requires": { + "string-width": "1.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true + } + } + }, + "sshpk": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", + "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + } + }, + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + }, + "stringstream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", + "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=" + }, + "supports-color": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", + "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "requires": { + "has-flag": "2.0.0" + } + }, + "terraformer": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/terraformer/-/terraformer-1.0.8.tgz", + "integrity": "sha1-UeCtiXRvzyFh3G9lqnDkI3fItZM=", + "requires": { + "@types/geojson": "1.0.6" + } + }, + "terraformer-wkt-parser": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/terraformer-wkt-parser/-/terraformer-wkt-parser-1.1.2.tgz", + "integrity": "sha1-M2oMj8gglKWv+DKI9prt7NNpvww=", + "requires": { + "terraformer": "1.0.8" + } + }, + "toposort-class": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toposort-class/-/toposort-class-1.0.1.tgz", + "integrity": "sha1-f/0feMi+KMO6Rc1OGj9e4ZO9mYg=" + }, + "tough-cookie": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", + "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", + "requires": { + "punycode": "1.4.1" + } + }, + "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.1.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "optional": true + }, + "type-is": { + "version": "1.6.15", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", + "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", + "requires": { + "media-typer": "0.3.0", + "mime-types": "2.1.17" + } + }, + "underscore.string": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.4.tgz", + "integrity": "sha1-LCo/n4PmR2L9xF5s6sZRQoZCE9s=", + "requires": { + "sprintf-js": "1.1.1", + "util-deprecate": "1.0.2" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "url": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", + "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + }, + "dependencies": { + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" + } + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "uuid": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" + }, + "validator": { + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/validator/-/validator-9.2.0.tgz", + "integrity": "sha512-6Ij4Eo0KM4LkR0d0IegOwluG5453uqT5QyF5SV5Ezvm8/zmkKI/L4eoraafZGlZPC9guLkwKzgypcw8VGWWnGA==" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, + "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.3.0" + } + }, + "wkx": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/wkx/-/wkx-0.4.2.tgz", + "integrity": "sha1-d201pjSlwi5lbkdEvetU+D/Szo0=", + "requires": { + "@types/node": "9.3.0" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "xml2js": { + "version": "0.4.17", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz", + "integrity": "sha1-F76T6q4/O3eTWceVtBlwWogX6Gg=", + "requires": { + "sax": "1.2.1", + "xmlbuilder": "4.2.1" + } + }, + "xmlbuilder": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.2.1.tgz", + "integrity": "sha1-qlijBBoGb5DqoWwvU4n/GfP0YaU=", + "requires": { + "lodash": "4.17.4" + } + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + } + } +} diff --git a/package.json b/package.json index 582edce..0cc4466 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "start": "node server.js" }, "dependencies": { + "alexa-sdk": "1.0.25", "express": "^4.15.3", "sqlite3": "*", "sequelize": "*", @@ -19,7 +20,10 @@ "q": "^1.5.1", "es6-map": "^0.1.4", "prettyjson": "^1.2.1", - "underscore.string": "^3.3.4" + "alexa-verifier": "^1.0.0", + "underscore.string": "^3.3.4", + "mocha": "^5.0.0", + "jsonwebtoken": ">=8.1.1" }, "engines": { "node": "8.1.x" diff --git a/server.js b/server.js index b35cf86..e0b8ad3 100644 --- a/server.js +++ b/server.js @@ -1,5 +1,3 @@ - - 'use strict'; //rahulmr const express = require('express'); @@ -8,92 +6,406 @@ const http = require('http'); const request = require('request'); const Map = require('es6-map'); const Q = require('q') -const dbAllCoinZ = require('./db/initialize'); +//const dbAllCoinZ = require('./db/initialize'); + +const dynamoDB = require('./db/dynamoDB'); +const exposedAPI = require('./AllCoinZ/exposedAPI'); const telegramAPI = require('./AllCoinZ/telegram') const Util = require('./AllCoinZ/util') const GenProc = require('./AllCoinZ/GenericProcess') const telegramPush = require('./AllCoinZ/push') const fetchCoin = require('./AllCoinZ/fetchCoin'); const Google = require('./AllCoinZ/Google') +const Alexa = require('./AllCoinZ/Alexa') +var verifier// = require('alexa-verifier-middleware') +const uuidv1 = require('uuid/v1'); +const ApiAiApp = require('actions-on-google').DialogflowApp; +var jwt = require('jsonwebtoken'); -var gUser = dbAllCoinZ.g_User; +var uniqID; +var displayName; +var currency = ""; +var exchange = "CCCAGG" +var platform; +var gapp; + +var res; +var hanlders = Alexa.handlers +var languageStrings = Alexa.languageStrings + +var verifier = require('alexa-verifier') +//var gUser = dbAllCoinZ.g_User; + +const app = express(); +var alexaRouter = express.Router() +//app.use('/', alexaRouter) + +alexaRouter.use(function (req, res, next) { + if (req._body) { + var er = 'The raw request body has already been parsed.' + return res.status(400).json({ status: 'failure', reason: er }) + } + + // TODO: if _rawBody is set and a string, don't obliterate it here! + + // mark the request body as already having been parsed so it's ignored by + // other body parser middlewares + req._body = true + req.rawBody = '' + req.on('data', function (data) { + return req.rawBody += data + }) + req.on('end', function () { + var certUrl, er, error, signature + + try { + req.body = JSON.parse(req.rawBody) + } catch (error) { + er = error + req.body = {} + } + certUrl = req.headers.signaturecertchainurl + signature = req.headers.signature + var skipver = req.headers.skipver + if (req.body && req.body.originalRequest) { + if (req.body.originalRequest.source) { + skipver = "bypass" + } + } + if (skipver) { + if (skipver == 'rmr999alexaskill' || skipver == "bypass") { + next() + } + } else { + verifier(certUrl, signature, req.rawBody, function (er) { + if (er) { + res.status(400).json({ status: 'failure', reason: er }) + } else { + next() + } + }) + } + }) +}) +//alexaRouter.use(verifier) -const server = express(); -server.use(bodyParser.urlencoded({ +app.use(bodyParser.urlencoded({ extended: true })); -server.use(bodyParser.json()); -let uniqID; -let displayName; -var currency = ""; -var exchange = "CCCAGG" -var platform; +app.use(bodyParser.json()); -var gapp; -const ApiAiApp = require('actions-on-google').DialogflowApp; -let res; +var projectID = 'allcryptocoinz' +app.get('/auth', (req, res) => { + //res.status(200).send('JAI - @ Welcome to Smart Crypto \n' + new Date()).end(); + var clientID = 'JAIsmartcrypto' + var redirectURL = 'https://oauth-redirect.googleusercontent.com/r/' + projectID + var ACCESS_TOKEN = 'JAISmartCryptoAT' + uuidv1() + var STATE_STRING; + if (req.query.client_id) { + if (req.query.client_id != clientID) { + res.status(503).send("Incorrect ClientID"); + } + } + if (req.query.redirect_uri) { + if (req.query.redirect_uri != redirectURL) { + res.status(503).send("Incorrect Re-directURL") + } + } + if (req.query.response_type) { + if (req.query.response_type != 'token') { + res.status(503).send("Incorrect Response_type") + } + } + + if (req.query.state) { + STATE_STRING = req.query.state + } + var responseoAuthURL = 'https://oauth-redirect.googleusercontent.com/r/' + projectID + '#access_token=' + ACCESS_TOKEN + '&token_type=bearer&state=' + STATE_STRING + res.redirect(responseoAuthURL) +}); + + +app.get('/home', function (request, response, next) { + response.sendFile(__dirname + '/AllCoinZ/home.html'); +} +) + +//https://actionsts.smartcrypto.bid/https://a5641d11.ngrok.io +var exposedURL = 'https://a5641d11.ngrok.io/' +app.get('/token', (req, res) => { + + var authorizCode = req.query.code + var state = req.query.state; + var authURL = 'https://www.googleapis.com/oauth2/v1/userinfo?access_token=' //+ authorizCode + var clientID //= 'JAISPCI' + clientID = '178495420010-247u2k5ir6r9e6biehjv2i43a5nudgmu.apps.googleusercontent.com' + var redirectURL = 'https://oauth-redirect.googleusercontent.com/r/'+projectID + + var clientsecret = '' + + request.post({ + headers: { 'content-type': 'application/x-www-form-urlencoded' }, + url: 'https://www.googleapis.com/oauth2/v4/token', + form: { + code: authorizCode, client_id: clientID, client_secret: clientsecret, + redirect_uri: exposedURL + 'token', + grant_type: 'authorization_code' + } + }, function (error, response, body) { + + if (error == null && body) { + var access_token = JSON.parse(body).access_token; + console.log(body); + request(authURL + access_token, function (error, response, body) { + console.log('error:', error); + console.log('statusCode:', response && response.statusCode); + console.log('body:', body); + if (body && error == null) { + var email = JSON.parse(body).email + var userID = JSON.parse(body).id + var name = JSON.parse(body).name + var ACCESS_TOKEN = 'JAISmartCryptoAT' + uuidv1(); + var userOb = { name: name, email: email, userID: userID } + var jwttoken = jwt.sign(userOb, 'JAISmartCrypto'); + + dynamoDB.g_UpdateInsert({ + displayName: name, + uniqID: jwttoken, + curr: "USD" + }).then(function () { + + var responseoAuthURL// = 'https://oauth-redirect.googleusercontent.com/r/' + projectID + '?code=' + ACCESS_TOKEN + '&state=' + state + responseoAuthURL = 'https://oauth-redirect.googleusercontent.com/r/' + projectID + '#access_token=' + jwttoken + '&token_type=bearer&state=' + state + res.redirect(responseoAuthURL) + //GenProc.m_sendSimpleMessage("Hello " + name + ", Welcome to Smart Crypto!!! Say help for getting assitance or Say a coin name ") + }, function (error) { + console.log(error) + }) + + + + + } + }); + } + }); +}) -server.post('/', function (request, response, next) { - + +app.post('/', function (request, response, next) { + //console.log(request) console.log(JSON.stringify(request.body)) - gapp = new ApiAiApp({ request, response }); - - Google.m_gapp(gapp) - //console.log("GAPP" + JSON.stringify(gapp.body_.originalRequest)) - - - res = response; - Util.m_setHttpResponse(res) - let originalRequest = gapp.body_.originalRequest - - //console.log(originalRequest.source) - switch (originalRequest.source) { - case "telegram": - platform = "telegram" - displayName = originalRequest.data.message.chat.username; - uniqID = originalRequest.data.message.chat.id - break; - case "slack_testbot": - displayName = originalRequest.data.user; - uniqID = originalRequest.data.user; - platform = "slack" - break; - case "skype": - platform = "skype" - break; - case "google": - platform = "google" - displayName = gapp.body_.originalRequest.data.user.userId - uniqID = gapp.body_.originalRequest.data.user.userId - break; - default: - platform = "telegram" - } - Util.m_platform = platform - - let actionMap = new Map(); - actionMap.set('getCoinValue', getCoinValue); - actionMap.set('TotalPortfolioValue', TotalPortfolioValue); - actionMap.set('ViewPortfolio', ViewPortfolio); - actionMap.set('ViewPortfolio', ViewPortfolio); - actionMap.set('input.welcome', DefaultWelcomeIntent); - actionMap.set('setCurrency', ChangeCurrency); - actionMap.set('input.unknown', DefaultFallbackIntent); - actionMap.set('BuySellCoin', BuySellCoin); - actionMap.set('gethelp', DefaultWelcomeIntent); - - gapp.handleRequest(actionMap); + var reqsession = request.body.session + if (reqsession != undefined) { + if (reqsession.user != null) { + if (reqsession.user.userId.toUpperCase().indexOf('AMZN') > -1) { + Alexa.configure(request, response) + } + } + } else { + + gapp = new ApiAiApp({ + request, + response + }); + Google.m_gapp(gapp) + //console.log("GAPP" + JSON.stringify(gapp.body_.originalRequest)) + res = response; + Util.m_setHttpResponse(res) + var originalRequest = gapp.body_.originalRequest + + //console.log(originalRequest.source) + switch (originalRequest.source) { + case "telegram": + platform = "telegram" + displayName = originalRequest.data.message.chat.username; + uniqID = originalRequest.data.message.chat.id + break; + case "slack_testbot": + displayName = originalRequest.data.user; + uniqID = originalRequest.data.user; + platform = "slack" + break; + case "skype": + platform = "skype" + break; + case "google": + platform = "google" + uniqID = gapp.getUser().accessToken//gapp.body_.originalRequest.data.user.userId + break; + default: + platform = "telegram" + } + Util.m_platform = platform + + var actionMap = new Map(); + actionMap.set('getCoinValue', getCoinValue); + actionMap.set('TotalPortfolioValue', TotalPortfolioValue); + actionMap.set('ViewPortfolio', ViewPortfolio); + actionMap.set('ViewPortfolio', ViewPortfolio); + actionMap.set('input.welcome', DefaultWelcomeIntent); + actionMap.set('setCurrency', ChangeCurrency); + actionMap.set('input.unknown', DefaultFallbackIntent); + actionMap.set('BuySellCoin', BuySellCoin); + actionMap.set('gethelp', help); + actionMap.set('DeleteCoin', BuySellCoin); + actionMap.set('GoogleWelcomeContext', googleWelcomeContext) + actionMap.set('ViewPortfolio-SelectItemAction', portfolioOptionSelect) + actionMap.set('getCoinValueOption', getCoinValueOption) + actionMap.set('namepermission', namepermission) + actionMap.set('sign.in', checkAuthenticated) + + gapp.handleRequest(actionMap); + } }) + +function getCoinValueOption() { + console.log("getCoinValueOption") + const selectedItem = gapp.getContextArgument('actions_intent_option', 'OPTION').value; +} + +function help() { + GenProc.m_help(displayName) +} + +function namepermission() { + if (gapp.isPermissionGranted()) { + var userName = gapp.getUserName().displayName; + displayName = userName + var userID = gapp.getUser().accessToken//gapp.getUser().user_id; + dynamoDB.g_UpdateInsert({ + displayName: userName, + uniqID: userID, + curr: "USD" + }).then(function () { + GenProc.m_sendSimpleMessage("Hello " + userName + ", Welcome to Smart Crypto!!! Say help for getting assitance or Say a coin name ") + }, function (error) { + console.log(error) + }) + + } else { + GenProc.m_sendSimpleMessage("Hello Welcome to Smart Crypto!!! Say help for getting assitance or Say a coin name ") + } +} + + +function googleWelcomeContext() { + if (gapp.getSignInStatus() == "OK") { + // if (gapp.getUser().accessToken) { + // var userName = getuser(gapp.getUser().accessToken).name + // GenProc.m_sendSimpleMessage("Hello **" + userName + "**, \nWelcome to Smart Crypto!!! \n \n*Say a coin name* ") + // } + + if (gapp.getUser().accessToken) { + checkUserExist(gapp.getUser().accessToken).then(function (data) { + var userName = getuser(data.uniqID).name + GenProc.m_sendSimpleMessage("Hello **" + userName + "**, \nWelcome to Smart Crypto!!! \n \n*Say a coin name* ") + }) + } else { + return gapp.tell('You need to sign-in before using some features.This is a one time process and is needed to store your currency/portfolio details.'); + } + } else if (!gapp.getUser().accessToken) { + return gapp.tell('You need to sign-in before using some features.This is a one time process and is needed to store your currency/portfolio details.'); + } +} + + +function portfolioOptionSelect() { + const selectedItem = gapp.getContextArgument('actions_intent_option', 'OPTION').value; + var coinObject = { + count: selectedItem.split('#')[0], + CryptoCoin: selectedItem.split('#')[1] + } + if (!selectedItem) { + gapp.ask('You did not select any item from the list'); + } + + if (selectedItem == 'My Portfolio') { + ViewPortfolio(); + } + else { + getCoinValue(coinObject, true) + } +} + +function askSignIn() { + gapp.askForSignIn(); +} + +function getuser(jsonToken) { + var decodedUser = jwt.verify(jsonToken, 'JAISmartCrypto'); + return decodedUser; +} +function checkUserExist(accesstoken) { + return new Promise((resolve, reject) => { + dynamoDB.g_getRecord({ + uniqID: accesstoken + }).then((data) => { + if (data == null) { + reject(null) + } else { + resolve(data) + } + }) + + }) + +} function DefaultWelcomeIntent() { - GenProc.m_getWelcomeMessage(platform, displayName) + if (Util.m_platform == "google") { + if (gapp.getUser().accessToken) { + checkUserExist(gapp.getUser().accessToken).then(function (data) { + var userName = getuser(data.uniqID).name + GenProc.m_sendSimpleMessage("Hello **" + userName + "**, \nWelcome to Smart Crypto!!! \n \n*Say a coin name* ") + }, function () { + GenProc.m_sendSimpleMessage("Hello , \nUserToken is corrupted .Please contact support !!! \n \n ") + }) + } else { + askSignIn(); + } + + } else { + GenProc.m_getWelcomeMessage(displayName) + } } +function DefaultWelcomeIntent1() { + if (Util.m_platform == "google") { + if (!gapp.getUser().accessToken) { + askSignIn(); + } else { + var namePermission = gapp.SupportedPermissions.NAME; + dynamoDB.g_getRecord({ + uniqID: gapp.getUser().accessToken//gapp.getUser().user_id + }).then((data) => { + if (data == null) { + if (!gapp.isPermissionGranted()) { + return gapp.askForPermission('Thanks for signing in . And to address you by name ', gapp.SupportedPermissions.NAME); + } + } else { + GenProc.m_sendSimpleMessage("Hello **" + data.displayName + "**, \nWelcome to Smart Crypto!!! \n \n*Say a coin name* ") + } + }) + } + } else { + GenProc.m_getWelcomeMessage(displayName) + } +} + +function checkAuthenticated() { + if (gapp.getSignInStatus() === gapp.SignInStatus.OK) { + let accessToken = gapp.getUser().accessToken; + } else { + gapp.tell('You need to sign-in before using some features.This is a one time process and is needed to store your currency/portfolio details.'); + + } +} function ChangeCurrency() { var userCurrency = gapp.getArgument("currency-name") if (userCurrency == "" && gapp.getArgument["CryptoCoin"] !== "") { @@ -102,150 +414,107 @@ function ChangeCurrency() { if (userCurrency == "") { return GenProc.m_sendSimpleMessage("Currency could not be identified.No changes are made :(") } - - dbAllCoinZ.g_UpdateInsert(gUser, { - uniqID: uniqID - }, { - displayName: displayName, - uniqID: uniqID, - curr: userCurrency - }).then(function () { - GenProc.m_sendSimpleMessage("Default currency has been set to " + userCurrency) - }, function (error) { - console.log(error) - }) + dynamoDB.g_UpdateInsert({ + displayName: displayName, + uniqID: uniqID, + curr: userCurrency + }).then(function () { + GenProc.m_sendSimpleMessage("Default currency has been set to " + userCurrency) + }, function (error) { + GenProc.m_sendSimpleMessage("Currency could not be set.Please try again or contact support") + }) } function DefaultFallbackIntent() { - sendDialogflowResponse(res, GenProc.m_sendSimpleMessage("`Please check the keyword or Coin name . Check help for keywords`")) + GenProc.m_getDefaultFallBack() } + function BuySellCoin() { GenProc.m_SyncPortfolio({ displayName, uniqID }, gapp) - // .then(function (message) { - // sendDialogflowResponse(res, message) - // }, function (error) { - // sendDialogflowResponse(res, error) - // }) -} -function getCoinValue() { +} +function getCoinValue(coinObject, external) { Util.m_getCurrency(uniqID).then(function () { var count = 1; if (gapp.getArgument("count") != null) { count = gapp.getArgument("count") } - var oCoin = Util.m_getCoinObject({ - count: count, - CryptoCoin: gapp.getArgument("CryptoCoin") - }) + var oCoin; + if (external != true) { + oCoin = Util.m_getCoinObject({ + count: count, + CryptoCoin: gapp.getArgument("CryptoCoin") + }) + } else { + + oCoin = Util.m_getCoinObject(coinObject) + } oCoin.then(function (coinResult) { GenProc.m_sendCoinResponse(coinResult) }).catch(function (err) { - console.log("m_getCurrency method failed" + err) + console.log("m_getCoinObject method failed" + err) }); - } - ) + }) } + + + function ViewPortfolio() { GenProc.m_getTotalPortfolioValue({ displayName, uniqID }, false) - // .then(function (VPortfolio) { - // sendDialogflowResponse(res, VPortfolio) - // }, function (error) { - // console.log(error); - // sendDialogflowResponse(res, error) - // }) + } function TotalPortfolioValue() { GenProc.m_getTotalPortfolioValue({ displayName, uniqID }, true) - // .then(function (TPV) { - // //console.log("aaa" + TPV) - // sendDialogflowResponse(res, TPV) - // }, - // function (error) { - // console.log(error); - // sendDialogflowResponse(res, error) - // }) + } +app.get('/rahulmr', (req, res) => { + //res.status(200).send('JAI - Welcome to Smart Crypto \n' + new Date()).end(); + exposedAPI.welcome(req, res); +}); -server.listen((process.env.PORT || 8000), function () { +app.listen((process.env.PORT || 8000), function () { //console.log("Server is up and running... "); - fetchCoin.m_updateCoins("").then(function (success) { + fetchCoin.m_updateCoins("update").then(function (success) { console.log("Loaded the coin array without errors..") - }, function (error) { console.log(error) }) + }, function (error) { + console.log(error) + }) }); -server.get('/users/:value?', (req, res) => { - - if (req.params.value == "rmr999") { - Util.m_getUsers().then(function (useritem) { - var users = JSON.stringify(useritem) - res.setHeader('Content-Type', 'application/json'); - res.status(200).send(users) - }) - - - } else { res.status(400).send("Check the request") } - +app.get('/updateCoins/:optype?', (req, res) => { + exposedAPI.getCoins(req, res); }); -server.get('/rahulmr', (req, res) => { - res.status(200).send('JAI - Welcome to AllCryptoCoinZ \n' + new Date()).end(); +app.get('/users/del/:key?/:secret?', (req, res) => { + exposedAPI.deleteUser(req, res); }); - - -server.get('/updateCoins/:optype?', (req, res) => { - var optype = ""; - optype = req.params.optype - - fetchCoin.m_updateCoins(optype).then(function (success) { - console.log(success) - res.setHeader('Content-Type', 'application/json'); - res.status(200).send(success) - - }, function (error) { console.log(error); res.status(400).send(error) }) +app.get('/users/:secret?', (req, res) => { + exposedAPI.getUsers(req, res); +}); +app.get('/cv/:coin?', (req, res) => { + exposedAPI.getCoinValue(req, res); +}); +app.get('/rahulmr', (req, res) => { + res.status(200).send('JAI - @ Welcome to Smart Crypto \n' + new Date()).end(); }); - - function sendDialogflowResponse(res, result) { - //console.log(gapp.body_.originalRequest.data.user.userId) if (Util.m_platform != "google") { res.send(result) } - //console.log("result"+JSON.stringify(result)) - - // res.send({"messages": [ - // { - // "displayText": "Text response", - // "platform": "google", - // "textToSpeech": "A",//result.messages[0].subtitle, - // "type": "simple_response" - // } - // ]}) - - // gapp.ask(gapp.buildRichResponse() - // // Create a basic card and add it to the rich response - // .addSimpleResponse('Simple Response') - // .addBasicCard(gapp.buildBasicCard('Basic Card') - // .setTitle('Basica Card Simple Title') - // .addButton('Button', 'https://example.google.com/mathandprimes') - // .setImage('https://www.cryptocompare.com/media/20646/eth.png', 'Ethereum') - // .setImageDisplay('CROPPED') - // ) - // ); -} +} \ No newline at end of file