To take the idea covered in Getting lists as a restquery a little further, why not simple expose all the custom blister functions so they can be queried too. This means that you can use exactly the same lists, and have the same lookup, filtering and sorting capability as from the custom functions in GAS.
Page Content
hide
The Google Script API URL
https://script.google.com/macros/s/AKfycbzBskBK17poScDU9yHnfgmgPHyvgNejM3zxV7niGdhLeXPjw7Y4/exec
Parameters
These are passed on the URL as usual. Remember that everything is case sensitive, and not all functions need all parameters.
parameter | usage |
func | the name of any custom blister functions. For example, func=blisterData |
listName | the name of the list to get the data for. For example, listName=blister.airlines |
sortId | the listId to sort on, for example, sortId=carrier |
sortDescending | whether to sort descending or not |
listId | the listId to select, for example, listId=name |
idx | the position of the item, for example, idx=20 |
value | the value to lookup, for example value=UA |
returnListId | the listId of the data to return, for example, returnListId=name |
library | the name of the library to directory, for example, library=blister |
filters | the list of filterIDs and filterValue pairs to apply, separated by commas, for example, filters=carrier,UA |
Examples
[["currencies","List of currencies and exchange rates by country and ISO code"],["languageCodes","list of language codes by country"],["champagne","volume of champagne shipped"],["billboardhot100","billboard top 100"],["airlines","list of airlines and their flight codes"]]
[["2F"],["2J"],["2N"],["3M"],["3X"],["4Z"],["5T"],["6E"],["7D"],["7F"]]
Try some of the examples in Using blister custom functions as these type of rest queries.
The Code
is fairly trivial – all we are doing is calling existing functions
// Handle rest calls to custom blister queries function doGet(e) { return ContentService .createTextOutput(JSON.stringify(handleCalls(e))) .setMimeType(ContentService.MimeType.JSON); ; } function handleCalls(e) { //example ?func=blisterList&listName=blister.airlines&listId=name&filters=carrier,UA // emulate what the custom function would pass var p = e.parameter, fun = p.func, sortId = p.sortId || null, sortDescending = p.sortDescending || null, maxMatch = p.maxMatch || null, listId = p.listId || null, idx = p.idx || null, value = p.value || null, listName = p.listName || null, returnListId = p.returnListId || null, library=p.library|| null, filters = p.filters ? p.filters.split(",") : null; if (fun != 'blisterDirectory' && !listName) throw ("you must provide a listName"); switch (fun) { case 'blisterData': return blisterData.apply(null, stackArguments(filters,listName, sortId, sortDescending, maxMatch)); case 'blisterList': return blisterList.apply(null, stackArguments(filters,listName, listId, sortId, sortDescending, maxMatch)); case 'blisterIndex': return blisterIndex.apply(null, stackArguments(filters, listName, idx, listId, sortId, sortDescending)); case 'blisterMatch': return blisterMatch.apply(null, stackArguments( filters,listName, value, listId, sortId, sortDescending, maxMatch)); case 'blisterLookup': return blisterLookup.apply(null, stackArguments(filters, listName, value, listId, returnListId, sortId, sortDescending, maxMatch)); case 'blisterUnique': return blisterUnique.apply(null, stackArguments( filters,listName, listId, sortId, sortDescending, maxMatch)); case 'blisterHeaders': return blisterHeaders.apply(null, stackArguments(filters, listName, listId)); case 'blisterDescription': return blisterDescription.apply(null,stackArguments(filters, listName)); case 'blisterUpdateDate': return blisterUpdateDate.apply(null,stackArguments(filters, listName)); case 'blisterDirectory': return blisterDirectory.apply(null,stackArguments(filters,library)); default: throw (fun + ' is not a valid blister function (remember it is case sensitive)'); } } // kind of funky since we need to create a paramarray of optional arguments for filters function stackArguments () { // the first arg is the array to tag on at end - the rest are the arguments var a = Array.slice(arguments); // these are the regular arguments var b = a.slice(1); // these are the optional filter ones if (a[0]) { for (var i=0;i<a[0].length;i++) b.push(a[0][i]); } return b; }
All comments, suggestions, assistance, good lists are welcome as I develop this capability. You can get me on Google plus, Twitter or this forum.