1.2.0 • Published 6 years ago

wufoo v1.2.0

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

Build

Node-Wufoo

Node-Wufoo is a Wufoo API wrapper for node.js. 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 for reference.

Example

   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 of Form objects. You can also call getForm to get a specific Form.

   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:

   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 and getReportEntries returns an array of Entry objects.

   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 of Report objects.

   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:

   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 of Field objects.

   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 of Widget objects.

   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 of Comment objects.

   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:

   wufoo.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 for a form:

  
   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:

   wufoo.webhook().delete("formid", "webhookHashId", function(err, success) {
     if (!success) {
       // do something.
     }
      
   })
   

Helper methods are also provided on the Form object:

   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.
     }

   })

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 installed. Run the entire test suite from the root directory of the project:

$ mocha

Future Versions

Node-Wufoo implements almost all of the Wufoo RESTful API except the following:

Implementation and support of the above will be included in future versions.

1.1.1

6 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago