Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Merge pull request #298 from zapier/allow-cli-access-to-request
Browse files Browse the repository at this point in the history
Allow cli access to request
  • Loading branch information
buildmaster authored Apr 16, 2018
2 parents 56502a6 + 6408745 commit 9c6225c
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 6 deletions.
44 changes: 42 additions & 2 deletions README-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ Your auth definition would look something like this:
[insert-file:./snippets/oauth2.js]
```

> Note - For OAuth, `authentication.oauth2Config.authorizeUrl`, `authentication.oauth2Config.getAccessToken`, and `authentication.oauth2Config.refreshAccessToken` will have the provided fields in `bundle.inputData` instead of `bundle.authData` because `bundle.authData` will only have "previously existing" values, which will be empty the first time the Zap runs.
> Note - For OAuth, `authentication.oauth2Config.authorizeUrl`, `authentication.oauth2Config.getAccessToken`, and `authentication.oauth2Config.refreshAccessToken` will have the provided fields in `bundle.inputData` instead of `bundle.authData` because `bundle.authData` will only have "previously existing" values, which will be empty the first time the Zap runs. Also note that `authentication.oauth2Config.getAccessToken` has access to the users return values in `rawRequest` and `cleanedRequest` should you need to extract other values (for example from the query string)

## Resources
Expand Down Expand Up @@ -609,7 +609,7 @@ This object holds the user's auth details and the data for the API requests.
| limit | `-1` | the number of items to fetch. `-1` indicates there's no limit (which will almost always be the case) |
| page | `0` | used in [paging](#paging) to uniquely identify which page of results should be returned |

**`bundle.meta.zap.id` is only available in the `performSubscribe` and `performUnsubscribe` methods**
> `bundle.meta.zap.id` is only available in the `performSubscribe` and `performUnsubscribe` methods
The user's Zap ID is available during the [subscribe and unsubscribe](https://zapier.github.io/zapier-platform-schema/build/schema.html#basichookoperationschema) methods.

Expand Down Expand Up @@ -637,6 +637,46 @@ module.exports = {
};
```

### `bundle.rawRequest`
> `bundle.rawRequest` is only available in the `perform` for web hooks and `getAccessToken` for oauth authentication methods
`bundle.rawRequest` holds raw information about the HTTP request that triggered the `perform` method or that represents the users browser request that triggered the `getAccessToken` call:

```
{
method: 'POST',
querystring: 'foo=bar&baz=qux',
headers: {
'Content-Type': 'application/json'
},
content: '{"hello": "world"}'
}
```



### `bundle.cleanedRequest`
> `bundle.cleanedRequest` is only available in the `perform` for web hooks and `getAccessToken` for oauth authentication methods
`bundle.cleanedRequest` will return a formatted and parsed version of the request. Some or all of the following will be available:

```
{
method: 'POST',
querystring: {
foo: 'bar',
baz: 'qux'
},
headers: {
'Content-Type': 'application/json'
},
content: {
hello: 'world'
}
}
```


## Environment

Apps can define environment variables that are available when the app's code executes. They work just like environment
Expand Down
46 changes: 44 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Zapier is a platform for creating integrations and workflows. This CLI is your g
* [`bundle.inputData`](#bundleinputdata)
* [`bundle.inputDataRaw`](#bundleinputdataraw)
* [`bundle.meta`](#bundlemeta)
* [`bundle.rawRequest`](#bundlerawrequest)
* [`bundle.cleanedRequest`](#bundlecleanedrequest)
- [Environment](#environment)
* [Defining Environment Variables](#defining-environment-variables)
* [Accessing Environment Variables](#accessing-environment-variables)
Expand Down Expand Up @@ -693,7 +695,7 @@ module.exports = App;

```

> Note - For OAuth, `authentication.oauth2Config.authorizeUrl`, `authentication.oauth2Config.getAccessToken`, and `authentication.oauth2Config.refreshAccessToken` will have the provided fields in `bundle.inputData` instead of `bundle.authData` because `bundle.authData` will only have "previously existing" values, which will be empty the first time the Zap runs.
> Note - For OAuth, `authentication.oauth2Config.authorizeUrl`, `authentication.oauth2Config.getAccessToken`, and `authentication.oauth2Config.refreshAccessToken` will have the provided fields in `bundle.inputData` instead of `bundle.authData` because `bundle.authData` will only have "previously existing" values, which will be empty the first time the Zap runs. Also note that `authentication.oauth2Config.getAccessToken` has access to the users return values in `rawRequest` and `cleanedRequest` should you need to extract other values (for example from the query string)

## Resources
Expand Down Expand Up @@ -1187,7 +1189,7 @@ This object holds the user's auth details and the data for the API requests.
| limit | `-1` | the number of items to fetch. `-1` indicates there's no limit (which will almost always be the case) |
| page | `0` | used in [paging](#paging) to uniquely identify which page of results should be returned |

**`bundle.meta.zap.id` is only available in the `performSubscribe` and `performUnsubscribe` methods**
> `bundle.meta.zap.id` is only available in the `performSubscribe` and `performUnsubscribe` methods
The user's Zap ID is available during the [subscribe and unsubscribe](https://zapier.github.io/zapier-platform-schema/build/schema.html#basichookoperationschema) methods.

Expand Down Expand Up @@ -1215,6 +1217,46 @@ module.exports = {
};
```

### `bundle.rawRequest`
> `bundle.rawRequest` is only available in the `perform` for web hooks and `getAccessToken` for oauth authentication methods
`bundle.rawRequest` holds raw information about the HTTP request that triggered the `perform` method or that represents the users browser request that triggered the `getAccessToken` call:

```
{
method: 'POST',
querystring: 'foo=bar&baz=qux',
headers: {
'Content-Type': 'application/json'
},
content: '{"hello": "world"}'
}
```



### `bundle.cleanedRequest`
> `bundle.cleanedRequest` is only available in the `perform` for web hooks and `getAccessToken` for oauth authentication methods
`bundle.cleanedRequest` will return a formatted and parsed version of the request. Some or all of the following will be available:

```
{
method: 'POST',
querystring: {
foo: 'bar',
baz: 'qux'
},
headers: {
'Content-Type': 'application/json'
},
content: {
hello: 'world'
}
}
```


## Environment

Apps can define environment variables that are available when the app's code executes. They work just like environment
Expand Down
71 changes: 69 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ <h2 class="docs-header__platform-title">Developer Platform</h2>
<li><a href="#bundleinputdata"><code>bundle.inputData</code></a></li>
<li><a href="#bundleinputdataraw"><code>bundle.inputDataRaw</code></a></li>
<li><a href="#bundlemeta"><code>bundle.meta</code></a></li>
<li><a href="#bundlerawrequest"><code>bundle.rawRequest</code></a></li>
<li><a href="#bundlecleanedrequest"><code>bundle.cleanedRequest</code></a></li>
</ul>
</li>
<li><a href="#environment">Environment</a><ul>
Expand Down Expand Up @@ -484,6 +486,8 @@ <h2 id="table-of-contents">Table of Contents</h2>
<li><a href="#bundleinputdata"><code>bundle.inputData</code></a></li>
<li><a href="#bundleinputdataraw"><code>bundle.inputDataRaw</code></a></li>
<li><a href="#bundlemeta"><code>bundle.meta</code></a></li>
<li><a href="#bundlerawrequest"><code>bundle.rawRequest</code></a></li>
<li><a href="#bundlecleanedrequest"><code>bundle.cleanedRequest</code></a></li>
</ul>
</li>
<li><a href="#environment">Environment</a><ul>
Expand Down Expand Up @@ -1463,7 +1467,7 @@ <h3 id="oauth2">OAuth2</h3>
<div class="row-height">
<div class="col-md-5 col-sm-12 col-height docs-primary">
<blockquote>
<p>Note - For OAuth, <code>authentication.oauth2Config.authorizeUrl</code>, <code>authentication.oauth2Config.getAccessToken</code>, and <code>authentication.oauth2Config.refreshAccessToken</code> will have the provided fields in <code>bundle.inputData</code> instead of <code>bundle.authData</code> because <code>bundle.authData</code> will only have &quot;previously existing&quot; values, which will be empty the first time the Zap runs.</p>
<p>Note - For OAuth, <code>authentication.oauth2Config.authorizeUrl</code>, <code>authentication.oauth2Config.getAccessToken</code>, and <code>authentication.oauth2Config.refreshAccessToken</code> will have the provided fields in <code>bundle.inputData</code> instead of <code>bundle.authData</code> because <code>bundle.authData</code> will only have &quot;previously existing&quot; values, which will be empty the first time the Zap runs. Also note that <code>authentication.oauth2Config.getAccessToken</code> has access to the users return values in <code>rawRequest</code> and <code>cleanedRequest</code> should you need to extract other values (for example from the query string)</p>
</blockquote>
</div>
<div class="col-md-7 col-sm-12 col-height is-empty docs-code">
Expand Down Expand Up @@ -2355,7 +2359,9 @@ <h3 id="bundlemeta"><code>bundle.meta</code></h3>
</div><div class="row">
<div class="row-height">
<div class="col-md-5 col-sm-12 col-height docs-primary">
<p><strong><code>bundle.meta.zap.id</code> is only available in the <code>performSubscribe</code> and <code>performUnsubscribe</code> methods</strong></p><p>The user&apos;s Zap ID is available during the <a href="https://zapier.github.io/zapier-platform-schema/build/schema.html#basichookoperationschema">subscribe and unsubscribe</a> methods.</p><p>For example - you could do:</p>
<blockquote>
<p><code>bundle.meta.zap.id</code> is only available in the <code>performSubscribe</code> and <code>performUnsubscribe</code> methods</p>
</blockquote><p>The user&apos;s Zap ID is available during the <a href="https://zapier.github.io/zapier-platform-schema/build/schema.html#basichookoperationschema">subscribe and unsubscribe</a> methods.</p><p>For example - you could do:</p>
</div>
<div class="col-md-7 col-sm-12 col-height docs-code">
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> subscribeHook = <span class="hljs-function">(<span class="hljs-params">z, bundle</span>) =&gt;</span> {
Expand All @@ -2377,6 +2383,67 @@ <h3 id="bundlemeta"><code>bundle.meta</code></h3>
performSubscribe: subscribeHook,
<span class="hljs-comment">// ...</span>
};
</code></pre>
</div>
</div>
</div><div class="row">
<div class="row-height">
<div class="col-md-5 col-sm-12 col-height docs-primary">
<h3 id="bundlerawrequest"><code>bundle.rawRequest</code></h3>
</div>
<div class="col-md-7 col-sm-12 col-height is-empty docs-code">

</div>
</div>
</div><div class="row">
<div class="row-height">
<div class="col-md-5 col-sm-12 col-height docs-primary">
<blockquote>
<p><code>bundle.rawRequest</code> is only available in the <code>perform</code> for web hooks and <code>getAccessToken</code> for oauth authentication methods</p>
</blockquote><p><code>bundle.rawRequest</code> holds raw information about the HTTP request that triggered the <code>perform</code> method or that represents the users browser request that triggered the <code>getAccessToken</code> call:</p>
</div>
<div class="col-md-7 col-sm-12 col-height docs-code">
<pre><code>{
method: &apos;POST&apos;,
querystring: &apos;foo=bar&amp;baz=qux&apos;,
headers: {
&apos;Content-Type&apos;: &apos;application/json&apos;
},
content: &apos;{&quot;hello&quot;: &quot;world&quot;}&apos;
}
</code></pre>
</div>
</div>
</div><div class="row">
<div class="row-height">
<div class="col-md-5 col-sm-12 col-height docs-primary">
<h3 id="bundlecleanedrequest"><code>bundle.cleanedRequest</code></h3>
</div>
<div class="col-md-7 col-sm-12 col-height is-empty docs-code">

</div>
</div>
</div><div class="row">
<div class="row-height">
<div class="col-md-5 col-sm-12 col-height docs-primary">
<blockquote>
<p><code>bundle.cleanedRequest</code> is only available in the <code>perform</code> for web hooks and <code>getAccessToken</code> for oauth authentication methods</p>
</blockquote><p><code>bundle.cleanedRequest</code> will return a formatted and parsed version of the request. Some or all of the following will be available:</p>
</div>
<div class="col-md-7 col-sm-12 col-height docs-code">
<pre><code>{
method: &apos;POST&apos;,
querystring: {
foo: &apos;bar&apos;,
baz: &apos;qux&apos;
},
headers: {
&apos;Content-Type&apos;: &apos;application/json&apos;
},
content: {
hello: &apos;world&apos;
}
}
</code></pre>
</div>
</div>
Expand Down

0 comments on commit 9c6225c

Please sign in to comment.