Files
probot.github.io/api/4.0.0/Context.html
2017-12-13 10:15:20 -06:00

913 lines
13 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Context - Documentation</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="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<li class="nav-link nav-home-link"><a href="index.html">Home</a></li><li class="nav-heading">Classes</li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="Context.html">Context</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Context.html#config">config</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Context.html#issue">issue</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Context.html#repo">repo</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="Robot.html">Robot</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Robot.html#on">on</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Robot.html#route">route</a></span></li><li class="nav-heading"><a href="global.html">Globals</a></li>
</nav>
<div id="main">
<h1 class="page-title">Context</h1>
<section>
<header>
<h2>
Context
</h2>
<div class="class-description"><p>Helpers for extracting information from the webhook event, which can be
passed to GitHub API calls.</p></div>
</header>
<article>
<div class="container-overview">
<div class="section-method">
<h2>Constructor</h2>
<h4 class="name" id="Context"><span class="type-signature"></span>new Context<span class="signature">()</span><span class="type-signature"></span></h4>
<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>github</code></td>
<td class="type">
<span class="param-type"><code><a href="global.html#github">github</a></code></span>
</td>
<td class="description last"><p>An authenticated GitHub API client</p></td>
</tr>
<tr>
<td class="name"><code>payload</code></td>
<td class="type">
<span class="param-type"><code><a href="global.html#payload">payload</a></code></span>
</td>
<td class="description last"><p>The webhook event payload</p></td>
</tr>
<tr>
<td class="name"><code>log</code></td>
<td class="type">
<span class="param-type"><code><a href="global.html#logger">logger</a></code></span>
</td>
<td class="description last"><p>A logger</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="context.js.html">context.js</a>, <a href="context.js.html#line12">line 12</a>
</li></ul></dd>
</dl>
</div>
</div>
<h3 class="subsection-title">Members</h3>
<div class="section-members">
<h4 class="name" id="isBot"><span class="type-signature"></span>isBot<span class="type-signature"> :boolean</span></h4>
<div class="description">
<p>Returns a boolean if the actor on the event was a bot.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="context.js.html">context.js</a>, <a href="context.js.html#line63">line 63</a>
</li></ul></dd>
</dl>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type"><code>boolean</code></span>
</li>
</ul>
</div>
<h3 class="subsection-title">Methods</h3>
<div class="section-method">
<h4 class="name" id="config"><span class="type-signature"></span>config<span class="signature">(fileName, defaultConfig<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;Object>}</span></h4>
<div class="description">
<p>Reads the app configuration from the given YAML file in the <code>.github</code>
directory of the repository.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="context.js.html">context.js</a>, <a href="context.js.html#line100">line 100</a>
</li></ul></dd>
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>fileName</code></td>
<td class="type">
<span class="param-type"><code>string</code></span>
</td>
<td class="attributes">
</td>
<td class="description last">
<p>Name of the YAML file in the <code>.github</code> directory</p>
</td>
</tr>
<tr>
<td class="name"><code>defaultConfig</code></td>
<td class="type">
<span class="param-type"><code>object</code></span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">
<p>An object of default config options</p>
</td>
</tr>
</tbody>
</table>
<div class="section-returns">
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type:
</dt>
<dd>
<span class="param-type"><code>Promise.&lt;Object></code></span>
</dd>
</dl>
<div class="param-desc">
<ul>
<li>Configuration object read from the file</li>
</ul>
</div>
</div>
<div class="section-examples">
<h5>Examples</h5>
<p class="code-caption">Contents of <code>.github/myapp.yml</code>.</p>
<pre class="prettyprint"><code>close: true
comment: Check the specs on the rotary girder.</code></pre>
<p class="code-caption">App that reads from <code>.github/myapp.yml</code>.</p>
<pre class="prettyprint"><code>// Load config from .github/myapp.yml in the repository
const config = await context.config('myapp.yml')
if (config.close) {
context.github.issues.comment(context.issue({body: config.comment}))
context.github.issues.edit(context.issue({state: 'closed'}))
}</code></pre>
<p class="code-caption">Using a <code>defaultConfig</code> object.</p>
<pre class="prettyprint"><code>// Load config from .github/myapp.yml in the repository and combine with default config
const config = await context.config('myapp.yml', {comment: 'Make sure to check all the specs.'})
if (config.close) {
context.github.issues.comment(context.issue({body: config.comment}));
context.github.issues.edit(context.issue({state: 'closed'}))
}</code></pre>
</div>
</div>
<div class="section-method">
<h4 class="name" id="issue"><span class="type-signature"></span>issue<span class="signature">(object<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Return the <code>owner</code>, <code>repo</code>, and <code>number</code> params for making API requests
against an issue or pull request. The object passed in will be merged with
the repo params.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="context.js.html">context.js</a>, <a href="context.js.html#line52">line 52</a>
</li></ul></dd>
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>object</code></td>
<td class="type">
<span class="param-type"><code>object</code></span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">
<p>Params to be merged with the issue params.</p>
</td>
</tr>
</tbody>
</table>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>const params = context.issue({body: 'Hello World!'})
// Returns: {owner: 'username', repo: 'reponame', number: 123, body: 'Hello World!'}</code></pre>
</div>
</div>
<div class="section-method">
<h4 class="name" id="repo"><span class="type-signature"></span>repo<span class="signature">(object<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Return the <code>owner</code> and <code>repo</code> params for making API requests against a
repository.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="context.js.html">context.js</a>, <a href="context.js.html#line31">line 31</a>
</li></ul></dd>
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>object</code></td>
<td class="type">
<span class="param-type"><code>object</code></span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">
<p>Params to be merged with the repo params.</p>
</td>
</tr>
</tbody>
</table>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>const params = context.repo({path: '.github/stale.yml'})
// Returns: {owner: 'username', repo: 'reponame', path: '.github/stale.yml'}</code></pre>
</div>
</div>
</article>
</section>
</div>
<br class="clear">
<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Dec 13 2017 10:15:16 GMT-0600 (CST) using the Minami theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>