gsweet
Version:
Help with writing scripts to run against gSuite
1,356 lines (367 loc) • 16.5 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: sheets/sheetOps.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">Module: sheets/sheetOps.js</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
<div class="description"><p>Handles talking to the Google Drive API
<a href="https://spdx.org/licenses/GPL-3.0-or-later.html">GPL License Full Text</a></p></div>
<dl class="details">
<dt class="tag-author">Author:</dt>
<dd class="tag-author">
<ul>
<li><a href="mailto:tod-gentille@pluralsight.com">Tod Gentille</a></li>
</ul>
</dd>
<dt class="tag-license">License:</dt>
<dd class="tag-license"><ul class="dummy"><li>GPL-3.0-or-later</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sheets_sheetOps.js.html">sheets/sheetOps.js</a>, <a href="sheets_sheetOps.js.html#line2">line 2</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="~autoInit"><span class="type-signature">(inner) </span>autoInit<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
<p>just get the default service and use it</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sheets_sheetOps.js.html">sheets/sheetOps.js</a>, <a href="sheets_sheetOps.js.html#line26">line 26</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~getSheetGridProperties"><span class="type-signature">(async, inner) </span>getSheetGridProperties<span class="signature">(sheetInfo)</span><span class="type-signature"> → {Promise.<gridProperties>}</span></h4>
<div class="description">
<p>Get the grid properties which is an object with a rowCount and columnCount
property.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>sheetInfo</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sheets_sheetOps.js.html">sheets/sheetOps.js</a>, <a href="sheets_sheetOps.js.html#line149">line 149</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<gridProperties></span>
</dd>
</dl>
<h4 class="name" id="~getSheetProperties"><span class="type-signature">(async, inner) </span>getSheetProperties<span class="signature">(sheetId)</span><span class="type-signature"></span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>sheetId</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sheets_sheetOps.js.html">sheets/sheetOps.js</a>, <a href="sheets_sheetOps.js.html#line124">line 124</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~getSheetValues"><span class="type-signature">(async, inner) </span>getSheetValues<span class="signature">(sheetRange)</span><span class="type-signature"> → {Promise.<Array.<Array>>}</span></h4>
<div class="description">
<p>Get all the cells in the specified range. If a given row has no data in the
final cells for a row, the array for that row is shortened. If a row has no
data no array for that row is returned.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>sheetRange</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>range property should include name of tab <code>Tab1!A2:C6</code></p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sheets_sheetOps.js.html">sheets/sheetOps.js</a>, <a href="sheets_sheetOps.js.html#line102">line 102</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>an array of rows containing an array for each column of data (even if only one column).</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<Array.<Array>></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>getSheetValues({id:SOME_ID, range:TabName!A:I})</code></pre>
<h4 class="name" id="~init"><span class="type-signature">(inner) </span>init<span class="signature">(sheetService)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Set up this module with the object that allows access to the google sheet
calls. Typically from the value returned by sheetService.init(). When testing
a mocked object can be passed in. Only needs to be done once.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>sheetService</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>optional</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sheets_sheetOps.js.html">sheets/sheetOps.js</a>, <a href="sheets_sheetOps.js.html#line21">line 21</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~setRangeData"><span class="type-signature">(async, inner) </span>setRangeData<span class="signature">(sheetRangeData)</span><span class="type-signature"> → {Promise.<{config: {data: {values:Array.<Array>}}, data: {spreadsheetId:string, updatedRange:string, updatedRows:number, updatedColumns:number, updatedCells:number}}>}</span></h4>
<div class="description">
<p>Set a range of data in a target sheet with an array of arrays of data
By default each inner array is a row in the sheet with an element for each column
if a sparse array is sent the missing cells in the range are skipped
(i.e. they aren't overwritten)</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>sheetRangeData</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sheets_sheetOps.js.html">sheets/sheetOps.js</a>, <a href="sheets_sheetOps.js.html#line62">line 62</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>object with many props including config.data and data</p>
<pre class="prettyprint source"><code>{
config: {
...
data: {
values: [[2D array of data sent]]
}
...
},
data: {
spreadsheetId,
updatedRange,
updatedRows,
updatedColumns,
updatedCells ,
}
headers:{...}
status:number
statusText:string
}</code></pre><p>these properties can be useful for testing</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<{config: {data: {values:Array.<Array>}}, data: {spreadsheetId:string, updatedRange:string, updatedRows:number, updatedColumns:number, updatedCells:number}}></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>setRangeData({id:"longgoogleid",range:"Sheet1!A1", data:[["R1C1","R1C2"],["R2C1","R2C2"]]})</code></pre>
<h4 class="name" id="~setSheetCell"><span class="type-signature">(async, inner) </span>setSheetCell<span class="signature">(sheetRangeValue)</span><span class="type-signature"> → {Promise.<Object>}</span></h4>
<div class="description">
<p>Convenience function that will take a string or number primitive and wrap
it into a 2D array to write to the spreadsheet.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>sheetRangeValue</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>where the range property should specify a single cell</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sheets_sheetOps.js.html">sheets/sheetOps.js</a>, <a href="sheets_sheetOps.js.html#line88">line 88</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>see setRangeData for details on returned Object</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<Object></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>setSheetCell({id:SHEET_ID, range:Tab!A1, value:"SomeValue"})</code></pre>
<h3 class="subsection-title">Type Definitions</h3>
<h4 class="name" id="~gridProperties">gridProperties</h4>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">object</span>
</li>
</ul>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>isValid</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>rowCount</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>columnCount</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>message</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="sheets_sheetOps.js.html">sheets/sheetOps.js</a>, <a href="sheets_sheetOps.js.html#line136">line 136</a>
</li></ul></dd>
</dl>
</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>