gsweet
Version:
Help with writing scripts to run against gSuite
101 lines (77 loc) • 3.07 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: sheets/sheetService.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: sheets/sheetService.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* @file Creat the Google drive service needed to hit the Drive API
* @author Tod Gentille
* @requires NPM:googleapis
* @requires ../googleAuthHelper
* @module
*/
const {google} = require('googleapis')
const authHelper = require('../googleAuthHelper')
/** holds the sheetService created by init()
* @type {Object}
*/
let _sheetService = undefined
/**
* This needs to be called just once.
* The results of this function are stored in `_sheetService`.
* If no service is passed to init it grabs the default Google Sheet Service.
* Passing the service in makes it easy to do unit testing since a Fake can
* be passed in.
* @returns {Object} - the service. Typically not needed by caller.
*/
const init = (sheetService = undefined) => {
if (sheetService !== undefined) {
_sheetService = sheetService
}
else {
// if we don't have one, get the default
if (_sheetService === undefined) {
_sheetService = getSheetServiceDefault()
}
}
return _sheetService
}
/**
* Get the default Google Sheet API service.
* @returns {Object} the actual Google Sheet Service
*/
const getSheetServiceDefault = () => {
const auth = authHelper.getGoogleSheetAuth()
return google.sheets({version: 'v4', auth})
}
module.exports = {
init,
getSheetServiceDefault,
}</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="Drive_driveOps.module_test.html">test</a></li><li><a href="module-drive_driveOps.html">drive/driveOps</a></li><li><a href="module-Drive_driveOps%2520Integration%2520Tests.html">Drive/driveOps Integration Tests</a></li><li><a href="module-drive_driveService.html">drive/driveService</a></li><li><a href="module-Sheet_sheetOps%2520Integration%2520Tests.html">Sheet/sheetOps Integration Tests</a></li><li><a href="sheets_sheetOps.module_js.html">sheets/sheetOps.js</a></li><li><a href="sheets_sheetService.module_js.html">sheets/sheetService.js</a></li><li><a href="-_sheetOps.module_test.html">test</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat May 11 2019 23:52:27 GMT-0700 (Pacific Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>