README.md in onfido-0.0.3 vs README.md in onfido-0.0.4
- old
+ new
@@ -1,12 +1,15 @@
# Onfido
A wrapper for Onfido's [API](https://onfido.com/documentation#introduction). You should always refer to the documentation for valid API calls.
[![Build Status](https://snap-ci.com/hvssle/onfido/branch/master/build_image)](https://snap-ci.com/hvssle/onfido/branch/master)
-[![Gem Version](https://badge.fury.io/rb/onfido.svg)](http://badge.fury.io/rb/onfido) [!['gitter room'][2]][1]
+[![Gem Version](https://badge.fury.io/rb/onfido.svg)](http://badge.fury.io/rb/onfido)
+[![Build Status](https://travis-ci.org/hvssle/onfido.svg?branch=master)](https://travis-ci.org/hvssle/onfido)
+[!['gitter room'][2]][1]
+
[1]: https://gitter.im/hvssle/onfido
[2]: https://badges.gitter.im/gitterHQ/developers.png
## Installation
@@ -25,17 +28,19 @@
$ gem install onfido
## Usage
-There are 3 configuration options for Onfido, including your `api_key`, throwing exceptions for failed responses and logging the requests. By default, `throws_exceptions` is set to `true`. If set to `false`, the response body will be returned instead.
+There are 5 configuration options for Onfido, including your `api_key`, throwing exceptions for failed responses and logging the requests. By default, `throws_exceptions` is set to `true`. If set to `false` and Onfido responds with a valid JSON body the response body will be returned instead.
```ruby
Onfido.configure do |config|
config.api_key = 'MY_API_KEY'
config.logger = Logger.new(STDOUT)
config.throws_exceptions = false
+ config.open_timeout = 30
+ config.read_timeout = 80
end
```
Assuming you have a valid key, you can conveniently make API calls by using an instance of the `API` class.
@@ -120,26 +125,46 @@
```ruby
api.address.all('SE1 4NG')
```
+### Pagination
+
+Currently, you can paginate over the *applicant* and *check* resources. However, since you can only create 1 check per applicant therefore paginating on the check resource might prove impractical.
+
+By default, both endpoints are fetching records the first 20 records. That is the maximum amount of records you can request per page.
+
+To paginate over *applicants*:
+```ruby
+api = Onfido::API.new
+api.applicant.all(page: 2, per_page: 10)
+```
+
+To paginate over *checks*:
+```
+api = Onfido::API.new
+api.check.all('applicant_id', page: 2, per_page: 10)
+```
+
## Error Handling
By default, Onfido will attempt to raise errors returned by the API automatically.
If you set the `throws_exceptions` to false, it will simply return the response body. This allows you to handle errors manually.
-If you rescue Onfido::RequestError, you are provided with the error message itself as well as the type of error, response code and fields that have errored. Here's how you might do that:
+If you rescue `Onfido::RequestError`, you are provided with the error message itself as well as the type of error, response code and fields that have errored. Here's how you might do that:
```ruby
def create_applicant
api.applicant.create(params)
rescue Onfido::RequestError => e
e.type # returns 'validation_error'
e.fields # returns {"email": {"messages": ["invalid format"]}
e.response_code # returns '401'
end
```
+
+You can also rescue `Onfido::ConnectionError`, which is raised whenever something goes wrong with the connection to Onfido - you may wish to automatically retry these requests.
### Roadmap
- Improve test coverage with more scenarios
- Add custom errors based on the response code.