Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jusx/node-wufoo
A Node.JS library for the Wufoo API.
https://github.com/jusx/node-wufoo
convenience-methods forms javascript node-wufoo wufoo wufoo-api wufoo-form
Last synced: 3 months ago
JSON representation
A Node.JS library for the Wufoo API.
- Host: GitHub
- URL: https://github.com/jusx/node-wufoo
- Owner: jusx
- License: mit
- Created: 2013-05-10T06:49:05.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-02-15T05:09:12.000Z (almost 7 years ago)
- Last Synced: 2024-08-11T11:24:52.952Z (5 months ago)
- Topics: convenience-methods, forms, javascript, node-wufoo, wufoo, wufoo-api, wufoo-form
- Language: JavaScript
- Homepage:
- Size: 46.9 KB
- Stars: 13
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Build](https://circleci.com/gh/jusx/node-wufoo.svg?style=shield&circle-token=3c6bf745453828aa4cc23daf7befe363287e0b97)
[![npm version](https://img.shields.io/npm/v/wufoo.svg)](https://www.npmjs.com/package/wufoo)# Node-Wufoo
Node-Wufoo is a [Wufoo API](http://www.wufoo.com/docs/api/v3/) wrapper for [node.js](http://nodejs.org/). It simplifies working with the Wufoo API and provides an abstraction layer.
## Installation
$ npm install wufoo
## Usage
Each API returns it's own set of objects which is all documented on [Wufoo.com](http://www.wufoo.com/docs/api/v3/) for reference.
The required node version is `8.0.0` and above for all releases above `v1.2.x`.
### Example
```javascript
var Wufoo = require("wufoo");
var wufoo = new Wufoo("fishbowl", "AOI6-LFKL-VM1Q-IEX9");wufoo.getForms(function(err, forms) {
// do something with your forms here.
});// get a specific form given the id.
wufoo.getForm("idofForm", function(err, form){
// do something with your form here.
});wufoo.getFormEntries("idofForm", function(err, entries) {
// do something with your entries here.
});// pass in optional query parameters
var optionalQuery = {pretty: true}wufoo.getForms(optionalQuery, function(err, forms) {
// do something with your forms here.
});// get a specific form given the id and pass in optional query parameters
wufoo.getForm("idofForm", optionalQuery, function(err, forms) {
// do something with your forms here.
});wufoo.getFormEntries("idofForm", optionalQuery, function(err, entries) {
// do something with your entries here.
});
```### Forms
Get all the forms for an account.
getForms
returns an array ofForm
objects. You can also callgetForm
to get a specificForm
.```javascript
wufoo.getForms(function(err, forms) {
console.log(forms[0].hash);
console.log(forms[0].name);
console.log(forms[0].description);
// do something here.
});// get a specific form given the id.
wufoo.getForm("idofForm", function(err, form){
// do something here.
});// pass in optional query parameters
var optionalQuery = {pretty: true}wufoo.getForms(optionalQuery, function(err, forms) {
console.log(forms[0].hash);
console.log(forms[0].name);
console.log(forms[0].description);
// do something here.
});// get a specific form given the id and pass in optional query parameters
wufoo.getForm("idofForm", optionalQuery, function(err, forms) {
// do something here.
});```
Convenience methods are provided to get entries, fields and entry count for a
Form
:```javascript
form.getEntries(function(err, entries) {
// do something here.
});form.getEntriesCount(function(err, count) {
// do something here.
console.log("There are " + count + " number of entries");
});form.getFields(function(err, fields) {
// do something here.
});// pass in optional query parameters
var optionalQuery = {pretty: true}form.getEntries(optionalQuery, function(err, entries) {
// do something here.
});form.getEntriesCount(optionalQuery, function(err, count) {
// do something here.
console.log("There are " + count + " number of entries");
});form.getFields(optionalQuery, function(err, fields) {
// do something here.
});
```### Entries
Get all the entries for a form or report.
getFormEntries
andgetReportEntries
returns an array ofEntry
objects.```javascript
wufoo.getFormEntries("formid", function(err, entries) {
// do something here.
});wufoo.getReportEntries("reportid", function(err, entries) {
// do something here.
});// pass in optional query parameters
var optionalQuery = {pretty: true}wufoo.getFormEntries("formid", optionalQuery, function(err, entries) {
// do something here.
});wufoo.getReportEntries("reportid", optionalQuery, function(err, entries) {
// do something here.
});```
### Reports
Get all the reports for an account.
getReports
returns an array ofReport
objects.```javascript
wufoo.getReports(function(err, reports) {
// do something here
});// get a specific form given the id.
wufoo.getReport("idofReport", function(err, report){
// do something here.
});// pass in optional query parameters
var optionalQuery = {pretty: true}wufoo.getReports(optionalQuery, function(err, reports) {
// do something here
});// get a specific form given the id.
wufoo.getReport("idofReport", optionalQuery, function(err, report){
// do something here.
});```
Convenience methods are provided to get entries, fields and entry count for a Report:```javascript
report.getEntries(function(err, entries) {
// do something here.
});report.getEntriesCount(function(err, count) {
// do something here.
console.log("There are " + count + " number of entries");
});report.getFields(function(err, fields) {
// do something here.
});// pass in optional query parameters
var optionalQuery = {pretty: true}report.getEntries(optionalQuery, function(err, entries) {
// do something here.
});report.getEntriesCount(optionalQuery, function(err, count) {
// do something here.
console.log("There are " + count + " number of entries");
});report.getFields(optionalQuery, function(err, fields) {
// do something here.
});
```### Fields
Get all the reports for a form.getFields
returns an array ofField
objects.```javascript
wufoo.getFields("formid", function(err, fields) {
// do something here.
});// pass in optional query parameters
var optionalQuery = {pretty: true}wufoo.getFields("formid", optionalQuery, function(err, fields) {
// do something here.
});```
### Widgets
Get all the widgets for a report.getWidgets
returns an array ofWidget
objects.```javascript
wufoo.getWidgets("reportid", function(err, widgets) {
// do something here.
});// pass in optional query parameters
var optionalQuery = {pretty: true}wufoo.getWidgets("reportid", optionalQuery, function(err, widgets) {
// do something here.
});```
### Comments
Get all the comments for a form.getComments
returns an array ofComment
objects.```javascript
wufoo.getComments("formid", function(err, comments) {
// do something here.
});// pass in optional query parameters
var optionalQuery = {pretty: true}wufoo.getComments("formid", optionalQuery, function(err, comments) {
// do something here.
});```
Alternatively if all you need is the amount of comments for a form you can call
getCommentCount
:
```javascriptwufoo.getCommentCount("formid", function(err, count) {
// do something here.
});// pass in optional query parameters
var optionalQuery = {pretty: true}wufoo.getCommentCount("formid", optionalQuery, function(err, count) {
// do something here.
});```
### WebHooks
Add a [WebHook](http://www.wufoo.com/docs/api/v3/webhooks/put/) for a form:```javascript
wufoo.webhook().add("formid", "http://localhost:3000", function(err, hashid) {
// store the webhook hashid somewhere in case we want to delete them later.
})// pass in optional options
var options = {url: "http://abc.com/webhook", handshakeKey: "hand-shaking", metadata: true}
wufoo.webhook().add("formid", options, function(err, hashid) {
// store the webhook hashid somewhere in case we want to delete them later.
db.put("WebHooks", {formid:form.hash, key:hashid});
})
```Delete the WebHook. [More info](http://www.wufoo.com/docs/api/v3/webhooks/delete/):
```javascript
wufoo.webhook().delete("formid", "webhookHashId", function(err, success) {
if (!success) {
// do something.
}})
```
Helper methods are also provided on the
Form
object:```javascript
form.addWebhook("http://localhost:3000", function(err, hashid) {
// store the webhook hashid somewhere in case we want to delete them later.
})form.deleteWebhook("webhookHashId", function(err, success) {
if (!success) {
// do something.
}})
```
### Promises
Every single API documented above have an alternate version that supports promises. For the preferred method of using promises or await/async instead of callbacks append `Async` to the end of the function name. For example, the following are all valid:- `from.addWebhookAsync`
- `wufoo.getCommentCountAsync`
- `wufoo.getWidgetsAsync`And so on. Calling `wufoo.getCommentCountAsync` will be as follows:
```js
wufoo.getCommentCount("formid")
.then ((count) => {
console.log(count);
})
.catch((err) => {
console.log(err);
});```
## Contributions
Please fork it. Add new features or fix bugs and do a pull request. Tests should be included:
- Fork it
- Create your feature branch (git checkout -b feature-new-stuff
).
- Commit your changes (git commit -am 'Added some feature'
).
- Push to the branch (git push origin feature-new-stuff
).
- Create new Pull Request.### Testing
Be sure to have [mocha](http://mochajs.org/) installed. Run the entire test suite from the root directory of the project by running the command:```
$ mocha
```
or```
$ npm test
```## Future Versions
Node-Wufoo implements all of the Wufoo RESTful API except the following:- Updating Entries ([POST API](http://www.wufoo.com/docs/api/v3/entries/post/)).
- [Login](http://www.wufoo.com/docs/api/v3/login/).Implementation and support of the above will be included in future versions. Contributions welcome!