const alivefyi = require('alivefyi');
/**
* listen for user inputs
*/
alivefyi.subscribe((data) => {
console.log('received', data);
if(data.terms.indexOf('Machine Zone')) {
publishAddress();
}
});
/**
* publish to data to user
*/
function publishAddress() {
alivefyi.publish(result);
}
function getGoogleUrl(location) {
const info = `${location.address.streetAddress},+${location.address.addressLocality},+${location.address.addressRegion}+${location.address.postalCode}/@${location.geo.latitude},${location.geo.longitude}`;
const result = info.replace('+', '%2B').replace(/\s/gm, '+');
return `https://www.google.com/maps/place/${result}`;
}
const ADDRESS = {
"@type": "Place",
_pid: 'Test',
name: `Machine Zone`,
description: ``,
address: {
"@type": "PostalAddress",
streetAddress: '1050 County Hwy G3',
addressLocality: 'Palo Alto',
addressRegion: 'CA',
postalCode: '94304',
addressCounty: 'US',
},
geo: {
"@type": "GeoCoordinates",
"latitude": 37.4191419,
"longitude": -122.1465053,
},
data: {
coupons: [],
}
}
ADDRESS.url = getGoogleUrl(ADDRESS);