veryfi 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +3 -5
- data/.github/workflows/test.yml +3 -1
- data/.gitignore +1 -0
- data/Gemfile.lock +14 -7
- data/README.md +208 -3
- data/bin/release +3 -0
- data/coverage/coverage-badge.png +0 -0
- data/docs/_config.yml +1 -1
- data/docs/index.markdown +6 -6
- data/lib/veryfi/api/document.rb +2 -4
- data/lib/veryfi/api/line_item.rb +0 -1
- data/lib/veryfi/client.rb +1 -1
- data/lib/veryfi/request.rb +1 -1
- data/lib/veryfi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a8a7ef98c7b70d163aa1913799e26981c1a3297e510cf561c1ad7295791c037
|
4
|
+
data.tar.gz: 2fadf010651b719a5849c229f0db4ade66332dc93fc789e28ca7c76c4f53952a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1c27daa4725f3e8c112fbbb49aee4f0b724aede5135152c5879ae4bcfd6c2747764dbf891a02e0199a64511b99ca0499d70315a64dfa1859153c53617f780e3
|
7
|
+
data.tar.gz: e600661fdde8df1cfa89c7d804cb7a32a215a53e3d59522eeea8ed012a654c4f693ad85207efa532e5fc6d3f80efa32eda450d49c96fbd8510a8430027ef21a9
|
@@ -1,9 +1,7 @@
|
|
1
1
|
name: Release
|
2
|
-
|
3
2
|
on:
|
4
|
-
|
5
|
-
|
6
|
-
- main
|
3
|
+
release:
|
4
|
+
types: [created]
|
7
5
|
|
8
6
|
jobs:
|
9
7
|
publish:
|
@@ -22,5 +20,5 @@ jobs:
|
|
22
20
|
env:
|
23
21
|
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
24
22
|
RELEASE_COMMAND: bin/release
|
25
|
-
GIT_EMAIL:
|
23
|
+
GIT_EMAIL: support@veryfi.com
|
26
24
|
GIT_NAME: Github Action
|
data/.github/workflows/test.yml
CHANGED
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
veryfi (0.
|
4
|
+
veryfi (1.0.0)
|
5
5
|
base64 (~> 0.1)
|
6
6
|
faraday (~> 1.7)
|
7
7
|
openssl (~> 2.2)
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
addressable (2.8.0)
|
13
13
|
public_suffix (>= 2.0.2, < 5.0)
|
14
14
|
ast (2.4.2)
|
15
|
-
base64 (0.1.
|
15
|
+
base64 (0.1.1)
|
16
16
|
bundler-audit (0.9.0)
|
17
17
|
bundler (>= 1.2.0, < 3)
|
18
18
|
thor (~> 1.0)
|
@@ -21,29 +21,35 @@ GEM
|
|
21
21
|
rexml
|
22
22
|
diff-lcs (1.4.4)
|
23
23
|
docile (1.4.0)
|
24
|
-
faraday (1.
|
24
|
+
faraday (1.10.0)
|
25
25
|
faraday-em_http (~> 1.0)
|
26
26
|
faraday-em_synchrony (~> 1.0)
|
27
27
|
faraday-excon (~> 1.1)
|
28
|
-
faraday-httpclient (~> 1.0
|
28
|
+
faraday-httpclient (~> 1.0)
|
29
|
+
faraday-multipart (~> 1.0)
|
29
30
|
faraday-net_http (~> 1.0)
|
30
|
-
faraday-net_http_persistent (~> 1.
|
31
|
+
faraday-net_http_persistent (~> 1.0)
|
31
32
|
faraday-patron (~> 1.0)
|
32
33
|
faraday-rack (~> 1.0)
|
33
|
-
|
34
|
+
faraday-retry (~> 1.0)
|
34
35
|
ruby2_keywords (>= 0.0.4)
|
35
36
|
faraday-em_http (1.0.0)
|
36
37
|
faraday-em_synchrony (1.0.0)
|
37
38
|
faraday-excon (1.1.0)
|
38
39
|
faraday-httpclient (1.0.1)
|
40
|
+
faraday-multipart (1.0.3)
|
41
|
+
multipart-post (>= 1.2, < 3)
|
39
42
|
faraday-net_http (1.0.1)
|
40
43
|
faraday-net_http_persistent (1.2.0)
|
41
44
|
faraday-patron (1.0.0)
|
42
45
|
faraday-rack (1.0.0)
|
46
|
+
faraday-retry (1.0.3)
|
43
47
|
hashdiff (1.0.1)
|
48
|
+
ipaddr (1.2.4)
|
44
49
|
method_source (1.0.0)
|
45
50
|
multipart-post (2.1.1)
|
46
|
-
openssl (2.2.
|
51
|
+
openssl (2.2.1)
|
52
|
+
ipaddr
|
47
53
|
parallel (1.20.1)
|
48
54
|
parser (3.0.2.0)
|
49
55
|
ast (~> 2.4.1)
|
@@ -103,6 +109,7 @@ GEM
|
|
103
109
|
hashdiff (>= 0.4.0, < 2.0.0)
|
104
110
|
|
105
111
|
PLATFORMS
|
112
|
+
ruby
|
106
113
|
x86_64-darwin-19
|
107
114
|
x86_64-linux
|
108
115
|
|
data/README.md
CHANGED
@@ -3,14 +3,15 @@
|
|
3
3
|
![Veryfi Logo](https://cdn.veryfi.com/logos/veryfi-logo-wide-github.png)
|
4
4
|
|
5
5
|
[![Version](https://img.shields.io/gem/v/veryfi)](https://rubygems.org/gems/veryfi)
|
6
|
-
[![Test](https://github.com/
|
6
|
+
[![Test](https://github.com/veryfi/veryfi-ruby/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/veryfi/veryfi-ruby/actions/workflows/test.yml)
|
7
7
|
|
8
|
-
[![Coverage](https://raw.githubusercontent.com/
|
8
|
+
[![Coverage](https://raw.githubusercontent.com/veryfi/veryfi-ruby/main/coverage/coverage-badge.png)](https://raw.githubusercontent.com/veryfi/veryfi-ruby/main/coverage/coverage-badge.png)
|
9
9
|
|
10
10
|
## Table of Contents
|
11
11
|
|
12
12
|
- [Veryfi SDK for Ruby](#veryfi-sdk-for-ruby)
|
13
13
|
- [Table of Contents](#table-of-contents)
|
14
|
+
- [Example](#example)
|
14
15
|
- [Installation](#installation)
|
15
16
|
- [Getting Started](#getting-started)
|
16
17
|
- [Obtaining Client ID and user keys](#obtaining-client-id-and-user-keys)
|
@@ -23,6 +24,202 @@
|
|
23
24
|
|
24
25
|
**veryfi-ruby** is a Ruby gem for communicating with the [Veryfi OCR API](https://veryfi.com/api/)
|
25
26
|
|
27
|
+
## Example
|
28
|
+
|
29
|
+
Below is a sample script using <a href="https://www.veryfi.com" target="_blank">**Veryfi**</a> for OCR and extracting data from a document:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'veryfi'
|
33
|
+
|
34
|
+
veryfi_client = Veryfi::Client.new(
|
35
|
+
client_id: 'your_client_id',
|
36
|
+
client_secret: 'your_client_secret',
|
37
|
+
username: 'your_username',
|
38
|
+
api_key: 'your_password'
|
39
|
+
)
|
40
|
+
```
|
41
|
+
|
42
|
+
This submits a document for processing (3-5 seconds for a response)
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
params = {
|
46
|
+
file_path: './test/receipt.jpg',
|
47
|
+
auto_delete: true,
|
48
|
+
boost_mode: false,
|
49
|
+
async: false,
|
50
|
+
external_id: '123456789',
|
51
|
+
max_pages_to_process: 10,
|
52
|
+
tags: ['tag1'],
|
53
|
+
categories: [
|
54
|
+
'Advertising & Marketing',
|
55
|
+
'Automotive'
|
56
|
+
]
|
57
|
+
}
|
58
|
+
|
59
|
+
response = veryfi_client.document.process(params)
|
60
|
+
|
61
|
+
puts response
|
62
|
+
```
|
63
|
+
|
64
|
+
...or with a URL
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
params = {
|
68
|
+
file_url: 'https://raw.githubusercontent.com/veryfi/veryfi-python/master/tests/assets/receipt_public.jpg',
|
69
|
+
auto_delete: true,
|
70
|
+
boost_mode: false,
|
71
|
+
async: false,
|
72
|
+
external_id: '123456789',
|
73
|
+
max_pages_to_process: 10,
|
74
|
+
tags: ['tag1'],
|
75
|
+
categories: [
|
76
|
+
'Advertising & Marketing',
|
77
|
+
'Automotive'
|
78
|
+
]
|
79
|
+
}
|
80
|
+
|
81
|
+
response = veryfi_client.document.process_url(params)
|
82
|
+
|
83
|
+
puts response
|
84
|
+
```
|
85
|
+
|
86
|
+
This will produce the following response:
|
87
|
+
|
88
|
+
```json
|
89
|
+
{
|
90
|
+
"abn_number": "",
|
91
|
+
"account_number": "",
|
92
|
+
"bill_to_address": "2 Court Square\nNew York, NY 12210",
|
93
|
+
"bill_to_name": "John Smith",
|
94
|
+
"bill_to_vat_number": "",
|
95
|
+
"card_number": "",
|
96
|
+
"cashback": 0,
|
97
|
+
"category": "Repairs & Maintenance",
|
98
|
+
"created": "2021-06-28 19:20:02",
|
99
|
+
"currency_code": "USD",
|
100
|
+
"date": "2019-02-11 00:00:00",
|
101
|
+
"delivery_date": "",
|
102
|
+
"discount": 0,
|
103
|
+
"document_reference_number": "",
|
104
|
+
"document_title": "",
|
105
|
+
"document_type": "invoice",
|
106
|
+
"due_date": "2019-02-26",
|
107
|
+
"duplicate_of": 37055375,
|
108
|
+
"external_id": "",
|
109
|
+
"id": 37187909,
|
110
|
+
"img_file_name": "receipt.png",
|
111
|
+
"img_thumbnail_url": "https://scdn.veryfi.com/receipts/thumbnail.png",
|
112
|
+
"img_url": "https://scdn.veryfi.com/receipts/receipt.png",
|
113
|
+
"insurance": "",
|
114
|
+
"invoice_number": "US-001",
|
115
|
+
"is_duplicate": 1,
|
116
|
+
"line_items": [
|
117
|
+
{
|
118
|
+
"date": "",
|
119
|
+
"description": "Front and rear brake cables",
|
120
|
+
"discount": 0,
|
121
|
+
"id": 68004313,
|
122
|
+
"order": 0,
|
123
|
+
"price": 100,
|
124
|
+
"quantity": 1,
|
125
|
+
"reference": "",
|
126
|
+
"section": "",
|
127
|
+
"sku": "",
|
128
|
+
"tax": 0,
|
129
|
+
"tax_rate": 0,
|
130
|
+
"total": 100,
|
131
|
+
"type": "product",
|
132
|
+
"unit_of_measure": ""
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"date": "",
|
136
|
+
"description": "New set of pedal arms",
|
137
|
+
"discount": 0,
|
138
|
+
"id": 68004315,
|
139
|
+
"order": 1,
|
140
|
+
"price": 15,
|
141
|
+
"quantity": 2,
|
142
|
+
"reference": "",
|
143
|
+
"section": "",
|
144
|
+
"sku": "",
|
145
|
+
"tax": 0,
|
146
|
+
"tax_rate": 0,
|
147
|
+
"total": 30,
|
148
|
+
"type": "product",
|
149
|
+
"unit_of_measure": ""
|
150
|
+
},
|
151
|
+
{
|
152
|
+
"date": "",
|
153
|
+
"description": "Labor 3hrs",
|
154
|
+
"discount": 0,
|
155
|
+
"id": 68004316,
|
156
|
+
"order": 2,
|
157
|
+
"price": 5,
|
158
|
+
"quantity": 3,
|
159
|
+
"reference": "",
|
160
|
+
"section": "",
|
161
|
+
"sku": "",
|
162
|
+
"tax": 0,
|
163
|
+
"tax_rate": 0,
|
164
|
+
"total": 15,
|
165
|
+
"type": "service",
|
166
|
+
"unit_of_measure": ""
|
167
|
+
}
|
168
|
+
],
|
169
|
+
"notes": "",
|
170
|
+
"ocr_text": "\n\fEast Repair Inc.\n1912 Harvest Lane\nNew York, NY 12210\n\nBILL TO\t\tSHIP TO\tRECEIPT #\tUS-001\nJohn Smith\t\tJohn Smith\tRECEIPT DATE\t11/02/2019\n2 Court Square\t3787 Pineview Drive\n\tP.O.#\t2312/2019\nNew York, NY 12210\tCambridge, MA 12210\n\tDUE DATE\t26/02/2019\nReceipt Total\t\t\t$154.06\n\nQTY DESCRIPTION\t\t\tUNIT PRICE\tAMOUNT\n1\tFront and rear brake cables\t\t100.00\t100.00\n2\tNew set of pedal arms\t\t\t15.00\t30.00\n3\tLabor 3hrs\t\t\t\t5.00\t15.00\n\n\tSubtotal\t145.00\n\tSales Tax 6.25%\t9.06\n\nTERMS & CONDITIONS\nPayment is due within 15 days\nPlease make checks payable to: East Repair\n\tJohn Smith\n\tInc.\n",
|
171
|
+
"order_date": "",
|
172
|
+
"payment_display_name": "",
|
173
|
+
"payment_terms": "15 days",
|
174
|
+
"payment_type": "",
|
175
|
+
"phone_number": "",
|
176
|
+
"purchase_order_number": "2312/2019",
|
177
|
+
"rounding": 0,
|
178
|
+
"service_end_date": "",
|
179
|
+
"service_start_date": "",
|
180
|
+
"ship_date": "",
|
181
|
+
"ship_to_address": "3787 Pineview Drive\nCambridge, MA 12210",
|
182
|
+
"ship_to_name": "John Smith",
|
183
|
+
"shipping": 0,
|
184
|
+
"store_number": "",
|
185
|
+
"subtotal": 145,
|
186
|
+
"tax": 9.06,
|
187
|
+
"tax_lines": [
|
188
|
+
{
|
189
|
+
"base": 0,
|
190
|
+
"name": "Sales",
|
191
|
+
"order": 0,
|
192
|
+
"rate": 6.25,
|
193
|
+
"total": 9.06
|
194
|
+
}
|
195
|
+
],
|
196
|
+
"tip": 0,
|
197
|
+
"total": 154.06,
|
198
|
+
"total_weight": "",
|
199
|
+
"tracking_number": "",
|
200
|
+
"updated": "2021-06-28 19:20:03",
|
201
|
+
"vat_number": "",
|
202
|
+
"vendor": {
|
203
|
+
"address": "1912 Harvest Lane\nNew York, NY 12210",
|
204
|
+
"category": "Car Repair",
|
205
|
+
"email": "",
|
206
|
+
"fax_number": "",
|
207
|
+
"name": "East Repair",
|
208
|
+
"phone_number": "",
|
209
|
+
"raw_name": "East Repair Inc.",
|
210
|
+
"vendor_logo": "https://cdn.veryfi.com/logos/tmp/560806841.png",
|
211
|
+
"vendor_reg_number": "",
|
212
|
+
"vendor_type": "Car Repair",
|
213
|
+
"web": ""
|
214
|
+
},
|
215
|
+
"vendor_account_number": "",
|
216
|
+
"vendor_bank_name": "",
|
217
|
+
"vendor_bank_number": "",
|
218
|
+
"vendor_bank_swift": "",
|
219
|
+
"vendor_iban": ""
|
220
|
+
}
|
221
|
+
```
|
222
|
+
|
26
223
|
## Installation
|
27
224
|
|
28
225
|
```bash
|
@@ -42,7 +239,7 @@ If you don't have an account with Veryfi, please go ahead and register here: [ht
|
|
42
239
|
|
43
240
|
### Ruby API Client Library
|
44
241
|
|
45
|
-
The **veryfi-ruby** gem can be used to communicate with Veryfi API. All available functionality is described [in docs](https://
|
242
|
+
The **veryfi-ruby** gem can be used to communicate with Veryfi API. All available functionality is described [in docs](https://veryfi.github.io/veryfi-ruby/)
|
46
243
|
|
47
244
|
## Need help?
|
48
245
|
|
@@ -66,3 +263,11 @@ bin/setup
|
|
66
263
|
## Develop
|
67
264
|
|
68
265
|
`bin/ci` checks your specs and runs quality tools
|
266
|
+
|
267
|
+
## Release
|
268
|
+
|
269
|
+
1. Change version in `lib/veryfi/version.rb`
|
270
|
+
2. Run bundle - this should update `Gemfile.lock`
|
271
|
+
3. Commit changes and push to Github
|
272
|
+
4. On Github go to `Actions` -> `Release` -> and click `Run workflow` to trigger release
|
273
|
+
5. Workflow will publish gem to [Rubygems](https://rubygems.org/gems/veryfi) and also create a new tag in repository
|
data/bin/release
CHANGED
data/coverage/coverage-badge.png
CHANGED
Binary file
|
data/docs/_config.yml
CHANGED
@@ -23,7 +23,7 @@ email: support@veryfi.com
|
|
23
23
|
description: >- # this means to ignore newlines until "baseurl:"
|
24
24
|
Veryfi is a Ruby gem for communicating with the Veryfi OCR API
|
25
25
|
baseurl: "/veryfi-ruby" # the subpath of your site, e.g. /blog
|
26
|
-
url: "https://
|
26
|
+
url: "https://veryfi.github.io" # the base hostname & protocol for your site, e.g. http://example.com
|
27
27
|
github_username: veryfi
|
28
28
|
markdown: kramdown
|
29
29
|
# Build settings
|
data/docs/index.markdown
CHANGED
@@ -30,9 +30,9 @@ This submits a document for processing (3-5 seconds for a response)
|
|
30
30
|
```ruby
|
31
31
|
params = {
|
32
32
|
file_path: './test/receipt.jpg',
|
33
|
-
auto_delete:
|
34
|
-
boost_mode:
|
35
|
-
async:
|
33
|
+
auto_delete: true,
|
34
|
+
boost_mode: false,
|
35
|
+
async: false,
|
36
36
|
external_id: '123456789',
|
37
37
|
max_pages_to_process: 10,
|
38
38
|
tags: ['tag1'],
|
@@ -52,9 +52,9 @@ puts response
|
|
52
52
|
```ruby
|
53
53
|
params = {
|
54
54
|
file_url: "https://raw.githubusercontent.com/veryfi/veryfi-python/master/tests/assets/receipt_public.jpg",
|
55
|
-
auto_delete:
|
56
|
-
boost_mode:
|
57
|
-
async:
|
55
|
+
auto_delete: true,
|
56
|
+
boost_mode: false,
|
57
|
+
async: false,
|
58
58
|
external_id: "123456789",
|
59
59
|
max_pages_to_process: 10,
|
60
60
|
tags: ["tag1"],
|
data/lib/veryfi/api/document.rb
CHANGED
@@ -30,17 +30,15 @@ module Veryfi
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def all(params = {})
|
33
|
-
|
34
|
-
|
35
|
-
response.is_a?(Hash) ? [response] : response
|
33
|
+
request.get("/partner/documents/", params)
|
36
34
|
end
|
37
35
|
|
38
36
|
def process(raw_params)
|
39
37
|
params = setup_create_params(raw_params)
|
40
38
|
|
41
39
|
file_content = File.read(params[:file_path])
|
42
|
-
file_name = File.basename(params[:file_path], ".*")
|
43
40
|
file_data = Base64.encode64(file_content).gsub("\n", "")
|
41
|
+
file_name = params[:file_name] || File.basename(params[:file_path], ".*")
|
44
42
|
|
45
43
|
payload = params.reject { |k| k == :file_path }.merge(
|
46
44
|
file_name: file_name,
|
data/lib/veryfi/api/line_item.rb
CHANGED
data/lib/veryfi/client.rb
CHANGED
data/lib/veryfi/request.rb
CHANGED
data/lib/veryfi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: veryfi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Veryfi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|