An open API service indexing awesome lists of open source software.

https://github.com/json2d/gapi-nano

a wrapper for Google API Client Library for using Google Apps Script REST Execution API
https://github.com/json2d/gapi-nano

Last synced: 9 months ago
JSON representation

a wrapper for Google API Client Library for using Google Apps Script REST Execution API

Awesome Lists containing this project

README

          

## Summary
This is a wrapper for the Google API Client Library, providing opinionated syntactic sugar for client authentication and making requests to a Google Apps Script via the REST Execution API

See: https://developers.google.com/apps-script/guides/rest/quickstart/js

## Basic Usage
In your html, include the browser build `gapi-nano.js` from the `dist` directory after `https://apis.google.com/js/api.js`

```html

```

Then in another script below that, pass in some options to `gapiNano.init` to get started

```html

var options = {
clientId: '[CLOUD PLATFORM CLIENT_ID]',
discoveryDocs: ["https://script.googleapis.com/$discovery/rest?version=v1"],
scope: '[SCOPE]',
scriptId: '[SCRIPT_ID]'
}

gapiNano.init(options,function(signedIn){
console.log("User signed in?", signedIn)

gapiNano.run('sum',{a:1,b:2}).then(function(result){
console.log('sum of 1 and 2 is', result)
})

})

```

## Functions



init(options, authListener)undefined


init - loads and authenticates gapi client using Auth2




run(fName, parameters)Promise


run - calls a function from the script specified by scriptId option during init()



## init(options, authListener) ⇒ undefined
`gapiNano.init` - loads and authenticates gapi client using Auth2

| Param | Type | Description |
| --- | --- | --- |
| options | object | Auth2 options, including clientId and scope |
| authListener | function | (optional) callback with a single boolean parameter, called whenever the authentication status changes |

## run(fName, parameters) ⇒ Promise
`gapiNano.run` - calls a function from the script specified by scriptId option during init()

**Returns**: Promise - a Promise object resolved with result of the function call

| Param | Type | Description |
| --- | --- | --- |
| fName | string | the name of the function |
| parameters | object | (optional) the arguments passed to the function |

## Building Changes
To rebuild `dist/gapi-nano.js` from `index.js`, use the npm task:
```
$ npm run dist
```
Of course this requires `browserify` to be installed globally:
```
$ npm install -g browserify
```