Commit 57a673d3 by Adri Van Houdt Committed by GitHub

Merge pull request #17 from Mango-information-systems/master

Added documentation and tests for batch endpoint of the API
parents d17f4a5a 72d0337a
......@@ -317,6 +317,33 @@ fullcontact.company.domain('fullcontact.com', null, 'https://mycallbackurl.com',
});
```
### Batch
API requests can be grouped and sent into a single request.
#### fullcontact.multi();
Activates batch processing mode. The `multi` method returns a new `FullContact` API instance that's internally set to `queuing`. So all api endpoints you would hit are queued until you call the `exec` method.
As per the [batch Process endpoint specs](https://www.fullcontact.com/developer/docs/batch/), up to 20 requests can be grouped in a batch.
#### fullcontact.exec();
Sends the batch request.
Example:
````js
var multi = fullcontact.multi();
multi.person.facebook('arnout.kazemier', fn);
multi.person.facebook('john.appleseed', fn);
multi.exec(function (err) {
console.log(err);
})
````
## Testing
The CI testing happens with a free api key that has limits to the calls it can do to FullContact. If you see the tests fail make sure it is because of failing tests not exeeding rate limit.
......
describe('FullContact.Batch', function () {
'use strict';
var FullContact = require('../');
var chai = require('chai');
chai.config.includeStack = true;
//
// The API key we use for testing.
//
var key = process.env.API_KEY;
if (!key) {
throw new Error('Please provide your API using the API_KEY env variable.');
}
//
// Some of the requests take a really long time, so set a really long timeout
//
this.timeout(20000);
//
// Create a multi API instance
//
var multi = new FullContact(key).multi();
describe('#multi', function () {
it('batches two requests', function (done) {
multi.person.twitter('observe_it');
multi.person.twitter('jack');
multi.exec(done);
});
it('provides the proper casing');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment