https://github.com/jetrockets/perfect_audit
PerfectAudit Ruby API wrapper
https://github.com/jetrockets/perfect_audit
api-client api-wrapper perfectaudit ruby ruby-gem
Last synced: 10 months ago
JSON representation
PerfectAudit Ruby API wrapper
- Host: GitHub
- URL: https://github.com/jetrockets/perfect_audit
- Owner: jetrockets
- License: mit
- Created: 2018-03-20T08:46:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-06-08T12:30:53.000Z (about 3 years ago)
- Last Synced: 2025-08-20T22:55:51.666Z (10 months ago)
- Topics: api-client, api-wrapper, perfectaudit, ruby, ruby-gem
- Language: Ruby
- Homepage: https://www.perfectaudit.com
- Size: 66.4 KB
- Stars: 4
- Watchers: 7
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# PerfectAudit
[](https://badge.fury.io/rb/perfect_audit)
[](https://travis-ci.org/jetrockets/perfect_audit)
[](https://codeclimate.com/github/jetrockets/perfect_audit/maintainability)
[](https://codeclimate.com/github/jetrockets/perfect_audit/test_coverage)
Perfect Audit API wrapper.
[https://ocrolus.com/api-docs/](https://ocrolus.com/api-docs/)
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'perfect_audit'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install perfect_audit
## Configuration
``` ruby
PerfectAudit.configure do |config|
config.client_id = 'your_client_id'
config.client_secret = 'your_client_secret'
end
```
## Exception Handling
If PerfectAudit will return anything different from 200 OK status code, `PerfectAudit::Error` will be raised. It contains `#message` and `#code` returned from API.
For example with invalid credentials you will receive:
``` ruby
PerfectAudit.books.all
#=> PerfectAudit::Error: Email and/or password not found [1306]
```
And if you will try to find a Book that does not exist, you will receive:
``` ruby
PerfectAudit.books.find(82087)
#=> PerfectAudit::Error: Book not found [1401]
```
## Usage
### Books Repository
Get books list for your account
``` ruby
PerfectAudit.books.all
#=> [#, ...]
```
Create a book
``` ruby
# Create a book with name=Test
PerfectAudit.books.create('Test')
#=> #
# Create a book with name=Test which is public
PerfectAudit.books.create('Test', true)
#=> #
```
Find book by ID
``` ruby
PerfectAudit.books.find(100)
#=> #
```
Delete a book
``` ruby
# To delete a book you can use either its ID or instance
PerfectAudit.books.delete(100)
#=> true
book = PerfectAudit.books.find(100)
PerfectAudit.books.delete(book)
#=> true
```
Export book to Excel
``` ruby
book = PerfectAudit.books.find(100)
File.write('./book.xlsx', PerfectAudit.books.to_excel(book))
```
### Documents Repository
Upload document to a book
``` ruby
# To upload documents to a book you can use book ID or its instance and File
PerfectAudit.documents.create(100, File.open('./document.pdf'))
#=> true
book = PerfectAudit.books.find(100)
PerfectAudit.documents.create(book, File.open('./document.pdf'))
#=> true
```
## Credits
Sponsored by [JetRockets](http://www.jetrockets.pro).

## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).