gravity-form-rest-api
v0.1.10
Published
Gravity Form REST API v2 for JavaScript
Downloads
4
Readme
Gravity Form REST API v2
The Gravity Form REST API v2 for JavaScript, available for Node.js backends
Installing
The preferred way to install the Gravity Form REST API v2 for Node.js is to use the npm package manager for Node.js. Simply type the following into a terminal window:
npm install gravity-form-rest-api
Then within your application, you can reference to the SDK with the following:
require('gravity-form-rest-api');
Usage and Getting Started
const GFormAPI = require('gravity-form-rest-api');
const GForm = new GFormAPI(API_BASE_URL, API_KEY, API_SECRET_KEY);
function callback(err, res, body) {
if (err) throw new Error(err);
console.log(body);
}
Get all form entries
GForm.getEntries(YOUR_FORM_ID, null, callback);
Get single form entry
GForm.getEntries(YOUR_FORM_ID, YOUR_ENTRY_ID, callback);
Add new entry
const example_entry_fields = {
form_id: YOUR_FORM_ID,
date_created: '2020-04-30 12:08:23',
source_url: 'https://domain.local',
'1': '',
'2': 'Foo',
'3': 'Bar',
'4': '1234567890',
'5': '[email protected]',
};
GForm.addEntry(example_entry_fields, callback);
Update entry
const example_entry_fields = {
form_id: YOUR_FORM_ID,
date_created: '2020-04-30 12:08:23',
source_url: 'https://domain.local',
'1': '',
'2': 'Foo',
'3': 'Bar',
'4': '1234567890',
'5': '[email protected]',
};
GForm.updateEntry(YOUR_ENTRY_ID, example_entry_fields, callback);
Delete entry
GForm.deleteEntry(YOUR_ENTRY_ID, callback);
Send notifications
GForm.sendNotifications(YOUR_ENTRY_ID, callback);