Link to the entire work done on the app: Github Commits
Link to the module: Hawkular Android Client
Link to project proposal: Android Client Improvents proposal
'use strict'; | |
const fs = require('fs'); | |
const http = require('http'); | |
const https = require('https'); | |
const express = require('express'); | |
const unirest = require('unirest'); | |
const bodyParser = require('body-parser'); | |
const server = express(); | |
const radius = 10000; |
function getRestuarantList(request, response, query, lat, lon){ // hits the zomato API | |
var req = unirest("GET", "https://developers.zomato.com/api/v2.1/search?count="+numberOfResults+"&lat="+lat+"&lon="+lon+"&radius="+radius+"&q=" + query) | |
req.header("Accept", 'application/json').header('user-key', api_key).end(function(res){ | |
if(res.error) { | |
res.setHeader('Content-Type', 'application/json'); | |
res.send(JSON.stringify({ | |
"speech" : "Error. Can you try it again ? ", | |
"displayText" : "Error. Can you try it again ? " | |
})); | |
} |
function getLocation(request, response, query){ | |
response.setHeader('Content-Type', 'application/json'); | |
response.send(JSON.stringify({ | |
"payload": { | |
"google": { | |
"expectUserResponse": true, | |
"richResponse": { | |
"items": [ | |
{ | |
"simpleResponse": { |
server.post('/FindResturant', (request, response) => { | |
if(equest.body.queryResult.action == 'findmyfood')// if the request comes from findMyFood intent | |
{ | |
if(request.body.originalDetectIntentRequest.payload.device){ // check if we have user's location | |
var lat = request.body.originalDetectIntentRequest.payload.device.location.coordinates.latitude; | |
var lon = request.body.originalDetectIntentRequest.payload.device.location.coordinates.longitude; | |
var query = request.body.queryResult.parameters.cusine; | |
getRestuarantList(request, response, query, lat, lon); | |
} |
Link to the entire work done on the app: Github Commits
Link to the module: Hawkular Android Client
Link to project proposal: Android Client Improvents proposal