auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
const UT = require("unixtimejs");
// get current unixtime:
//var ut = UT.now(); // eg: 1517433903
// unixtime -> UTCString
var utcString = UT.toUTCString(event.body.reported_at/1000); // "Wed, 31 Jan 2018 21:25:03 GMT"
console.dir(utcString);
return utcString
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
const { toFahrenheitFmt } = require('celsius');
//var Ftemp = toFahrenheitFmt(event.body.decoded.payload.temperature); // 97
var Ftemp = toFahrenheitFmt(steps.trigger.event.body.decoded.payload.temperature); // 97
//console.dir(event.body.decoded.payload)
console.dir(Ftemp)
return Ftemp
//toFahrenheit(36.68, 3); // 98.024
//toFahrenheit('-40.691 degrees C', 5); // -41.24380
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, auths) => {
}
const fetch = require('node-fetch');
//const key = process.env.HERE_API_KEY; // this is how Raymond got the API key, but this didn't work for me
const key = auths.here.apikey // get the api key
// Console output for debugging
//console.log("key = ");
//console.log(key);
//console.log("auths.here.apikey = ")
//console.log(auths.here.apikey)
// Raymond's code to access Dropbox files
//if(steps.trigger.event['.tag'] !== 'file') $end('wrong type = ' + steps.trigger.event['.tag']);
//let loc = steps.trigger.event.media_info.metadata.location.latitude + ',' +
// steps.trigger.event.media_info.metadata.location.longitude;
// Read lat and longitude from Trigger event
let loc = steps.trigger.event.body.decoded.payload.latitude + ',' +
steps.trigger.event.body.decoded.payload.longitude;
console.log(loc);
let url = `https://revgeocode.search.hereapi.com/v1/revgeocode?apikey=${key}&at=${loc}`;
//console.log(url); //debugging - verify there is an API Key in the URL
let resp = await fetch(url);
//return resp
let data = await resp.json();
console.log(data.items[0]);
return data.items[0];
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
var geo = require('node-geo-distance');
// from https://www.npmjs.com/package/node-geo-distance
// there isn't much documentation, but I think the function is returning a distance in meters
//white house
//var coord1 = {
// latitude: 38.8977330,
// longitude: -77.0365310
//}
// Washington Monument
//var coord2 = {
// latitude: 38.8894840,
// longitude: -77.0352790
//}
// Hotspot
var coord1 = {
latitude: event.body.hotspots[0].lat,
longitude: event.body.hotspots[0].long
}
// BOL
var coord2 = {
latitude: steps.trigger.event.body.decoded.payload.latitude,
longitude: steps.trigger.event.body.decoded.payload.longitude
}
console.log(event.body.hotspots[0].lat);
console.log(event.body.hotspots[0].long);
geo.vincenty(coord1, coord2, function(dist) {
console.log(dist);
});
// -> .8 miles from Washinton Monument to White House accorinding to Google, which is about 1287 meters
var vincentyDist = geo.vincentySync(coord1, coord2);
console.log(vincentyDist);
console.log(vincentyDist/1609.34);
return vincentyDist/1609.34; // choose to return the vincentyDist, could have returned the haverstineDist instead as both are giving close results
// convert meters to miles - i.e. 1609.34 meters in a mile
geo.haversine(coord1, coord2, function(dist) {
console.log(dist);
});
var haversineDist = geo.haversineSync(coord1, coord2);
console.log(haversineDist);
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
// from here: https://github.com/cmoncrief/geodist
var geodist = require('geodist')
//console.dir(Array.isArray(event.body.hotspots));
//console.dir(event.body.hotspots.toString());
//console.dir(event.body.hotspots.valueOf());
//console.dir(event.body.hotspots[0].lat);
//console.dir(event.body.hotspots[0].long);
//console.dir(steps.trigger.event.body.decoded.payload.latitude);
//console.dir(steps.trigger.event.body.decoded.payload.longitude);
//var dist = geodist({lat: 41.85, lon: -87.65}, {lat: 33.7489, lon: -84.3881})
// => 587
//var dist = geodist({lat: event.body.hotspots[0].lat, lon: event.body.hotspots[0].long}, {lat: steps.trigger.event.body.decoded.payload.latitude, lon: steps.trigger.event.body.decoded.payload.longitude})
var dist = geodist({lat: event.body.hotspots[0].lat, lon: event.body.hotspots[0].long}, {lat: steps.trigger.event.body.decoded.payload.latitude, lon: steps.trigger.event.body.decoded.payload.longitude}, {exact: true, unit: 'mi'})
// specify to return the result in mlles and the exact result
return dist;
//console.log(dist)
// => 587
Enter the data to insert into each column. Click + to add columns in structured mode, or turn structured mode off
to enter array of column values as an expression — e.g., {{[1,2,3]}}
The spreadsheet ID can be extracted from its URL. E.g., the spreadsheet ID in the URL docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 is abc1234567
.
Enter the name of the tab in the spreadsheet where you want to add data. The default name for a new sheet is Sheet1
.
async
(params, auths) => {
}
const { columns } = params
// validate input
if (!columns || !columns.length) {
throw new Error("Please enter an array of elements in the `Columns` parameter above")
} else if (!Array.isArray(columns)) {
throw new Error("Column data is not an array. Please enter an array of elements in the `Columns` parameter above.")
} else if (Array.isArray(columns[0])) {
throw new Error("Column data is a multi-dimensional array. A one-dimensional is expected. If you're trying to send multiple rows to Google Sheets, search for the action to add multiple rows to Sheets, or try modifying the code for this step.")
}
const config = {
method: "post",
url: `https://sheets.googleapis.com/v4/spreadsheets/${params.spreadsheetId}/values/${params.sheetName}:append`,
params: {
includeValuesInResponse: true,
valueInputOption: "USER_ENTERED"
},
headers: {
Authorization: `Bearer ${auths.google_sheets.oauth_access_token}`,
},
data: {
values: [columns],
}
}
return (await require("@pipedreamhq/platform").axios(this, config)).updates