heroku-client
Advanced tools
Comparing version 0.3.3 to 0.4.0
{ | ||
"name": "heroku-client", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"description": "A wrapper for the Heroku v3 API", | ||
@@ -5,0 +5,0 @@ "main": "./lib/heroku.js", |
@@ -13,56 +13,47 @@ # heroku-client [![Build Status](https://travis-ci.org/jclem/node-heroku-client.png?branch=master)](https://travis-ci.org/jclem/node-heroku-client) | ||
`heroku-client` works by providing functions that return proxy objects for | ||
interacting with different resources through the Heroku API. | ||
To begin, require the Heroku module and create a client, passing in an API | ||
token: | ||
```javascript | ||
/* | ||
* `heroku-client` works by providing functions that return proxy objects for | ||
* interacting with different resources through the Heroku API. | ||
* | ||
* To begin, require the Heroku module and create a client, passing in an API | ||
* token: | ||
*/ | ||
var Heroku = require('heroku-client'), | ||
heroku = new Heroku({ token: process.env.HEROKU_API_TOKEN }); | ||
``` | ||
The simplest example is listing a user's apps. First, we call `heroku.apps()`, | ||
which returns a proxy object to the /apps endpoint, then we call `list()` to | ||
actually perform the API call: | ||
/* | ||
* The simplest example is listing a user's apps. First, we call `heroku.apps()`, | ||
* which returns a proxy object to the /apps endpoint, then we call `list()` to | ||
* actually perform the API call: | ||
*/ | ||
```javascript | ||
heroku.apps().list(function (err, apps) { | ||
// `apps` is a parsed JSON response from the API | ||
}); | ||
``` | ||
The advantage of using proxy objects is that they are reusable. Let's get the | ||
info for the user's app "my-app", get the dynos for the app, and | ||
remove a collaborator: | ||
/* | ||
* The advantage of using proxy objects is that they are reusable. Let's get the | ||
* info for the user's app "my-app", then get the dynos for the app, then | ||
* remove a collaborator: | ||
*/ | ||
```javascript | ||
var app = heroku.apps('my-app'); | ||
app.info(function (err, app) { | ||
// Details about the `app` | ||
}); | ||
app.dynos().list(function (err, dynos) { | ||
// List of the app's `dynos` | ||
}); | ||
app.collaborators('user@example.com').delete(function (err, collaborator) { | ||
// The `collaborator` has been removed unless `err` | ||
}); | ||
``` | ||
Requests that require a body are easy, as well. Let's add a collaborator to | ||
the user's app "another-app": | ||
/* | ||
* Requests that require a body are easy, as well. Let's add a collaborator to | ||
* the user's app "another-app": | ||
*/ | ||
```javascript | ||
var app = heroku.apps('another-app'), | ||
@@ -72,5 +63,3 @@ user = { email: 'new-user@example.com' }; | ||
app.collaborators().create({ user: user }, function (err, collaborator) { | ||
// `collaborator` is the newly added collaborator unless `err` | ||
}); | ||
@@ -77,0 +66,0 @@ ``` |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96404
13
2480
115