veryfi 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 71ed0e3845f85312d16f9821240b9e04bb86bbeb0637a25970251543472d9edc
4
+ data.tar.gz: 5daffbc243cc62df5bfbb4d18d72a5741850ddc59be6ba970f3f2f098db03f56
5
+ SHA512:
6
+ metadata.gz: ee64c026cd35bde32a2d116c5d2bfc9ee5e3581b3d096540b3c98688e6e94e161b2c7cf7cb342e862de7785dcb311864822e7563cebf4f6b0114535da2248d32
7
+ data.tar.gz: fe14f1092b352c8b20a64fc61d92f5c450d9189abeeb0d325ab1acf1069732fb1a1d34eb6bb12ed54536eef1c1dd7eeec0922c13dcae8d09d8939b6fe93375d3
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+
20
+ .env
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,76 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ DisplayCopNames: true
5
+ Exclude:
6
+ - bin/**/*
7
+ - tmp/**/*
8
+ - .bundle/**/*
9
+ - veryfi.gemspec
10
+
11
+ Style/Documentation:
12
+ Description: 'Document classes and non-namespace modules.'
13
+ Enabled: false
14
+
15
+ Style/MethodCalledOnDoEndBlock:
16
+ Enabled: true
17
+
18
+ Style/CollectionMethods:
19
+ Enabled: true
20
+
21
+ Style/SymbolArray:
22
+ Description: 'Use %i or %I for arrays of symbols.'
23
+ Enabled: true
24
+
25
+ Style/StringLiterals:
26
+ EnforcedStyle: double_quotes
27
+
28
+ Layout/LineLength:
29
+ Description: 'Limit lines to 120 characters.'
30
+ Max: 120
31
+
32
+ Layout/EndAlignment:
33
+ EnforcedStyleAlignWith: variable
34
+ SupportedStylesAlignWith:
35
+ - keyword
36
+ - variable
37
+
38
+ Layout/ParameterAlignment:
39
+ EnforcedStyle: with_fixed_indentation
40
+ SupportedStyles:
41
+ - with_first_parameter
42
+ - with_fixed_indentation
43
+
44
+ Layout/SpaceAroundMethodCallOperator:
45
+ Enabled: true
46
+
47
+ Lint/RaiseException:
48
+ Enabled: false
49
+
50
+ Lint/StructNewOverride:
51
+ Enabled: false
52
+
53
+ Metrics/ParameterLists:
54
+ Max: 7
55
+
56
+ Metrics/BlockLength:
57
+ Exclude:
58
+ - "spec/**/*"
59
+
60
+ Naming/MemoizedInstanceVariableName:
61
+ EnforcedStyleForLeadingUnderscores: required
62
+
63
+ Style/HashEachMethods:
64
+ Enabled: true
65
+
66
+ Style/HashTransformKeys:
67
+ Enabled: false
68
+
69
+ Style/HashTransformValues:
70
+ Enabled: false
71
+
72
+ Style/ExponentialNotation:
73
+ Enabled: false
74
+
75
+ Style/FrozenStringLiteralComment:
76
+ Enabled: true
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.2
@@ -0,0 +1,53 @@
1
+ version: v1.0
2
+ name: ruby-base
3
+
4
+ agent:
5
+ machine:
6
+ type: e1-standard-2
7
+ os_image: ubuntu1804
8
+
9
+ execution_time_limit:
10
+ hours: 1
11
+
12
+ auto_cancel:
13
+ queued:
14
+ when: 'true'
15
+
16
+ fail_fast:
17
+ cancel:
18
+ when: 'true'
19
+
20
+ global_job_config:
21
+ prologue:
22
+ commands:
23
+ - checkout
24
+ - cache restore
25
+
26
+ blocks:
27
+ - name: Setup
28
+ task:
29
+ jobs:
30
+ - name: Setup
31
+ commands:
32
+ - bundle install
33
+ - cache store
34
+
35
+ - name: Quality
36
+ task:
37
+ jobs:
38
+ - name: Quality
39
+ commands:
40
+ - bundle install
41
+ - bin/quality
42
+
43
+ - name: Test
44
+ task:
45
+ prologue:
46
+ commands:
47
+ - sem-version ruby 2.6.5
48
+ - bundle install
49
+
50
+ jobs:
51
+ - name: Specs
52
+ commands:
53
+ - bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in veryfi.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,108 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ veryfi (0.0.0)
5
+ faraday (~> 1.7)
6
+ openssl (~> 2.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.8.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ ast (2.4.0)
14
+ bundler-audit (0.6.1)
15
+ bundler (>= 1.2.0, < 3)
16
+ thor (~> 0.18)
17
+ coderay (1.1.3)
18
+ crack (0.4.5)
19
+ rexml
20
+ diff-lcs (1.3)
21
+ faraday (1.7.1)
22
+ faraday-em_http (~> 1.0)
23
+ faraday-em_synchrony (~> 1.0)
24
+ faraday-excon (~> 1.1)
25
+ faraday-httpclient (~> 1.0.1)
26
+ faraday-net_http (~> 1.0)
27
+ faraday-net_http_persistent (~> 1.1)
28
+ faraday-patron (~> 1.0)
29
+ faraday-rack (~> 1.0)
30
+ multipart-post (>= 1.2, < 3)
31
+ ruby2_keywords (>= 0.0.4)
32
+ faraday-em_http (1.0.0)
33
+ faraday-em_synchrony (1.0.0)
34
+ faraday-excon (1.1.0)
35
+ faraday-httpclient (1.0.1)
36
+ faraday-net_http (1.0.1)
37
+ faraday-net_http_persistent (1.2.0)
38
+ faraday-patron (1.0.0)
39
+ faraday-rack (1.0.0)
40
+ hashdiff (1.0.1)
41
+ jaro_winkler (1.5.4)
42
+ method_source (1.0.0)
43
+ multipart-post (2.1.1)
44
+ openssl (2.2.0)
45
+ parallel (1.19.1)
46
+ parser (2.7.1.1)
47
+ ast (~> 2.4.0)
48
+ pry (0.14.1)
49
+ coderay (~> 1.1)
50
+ method_source (~> 1.0)
51
+ public_suffix (4.0.6)
52
+ rainbow (3.0.0)
53
+ rake (13.0.6)
54
+ rexml (3.2.5)
55
+ rspec (3.9.0)
56
+ rspec-core (~> 3.9.0)
57
+ rspec-expectations (~> 3.9.0)
58
+ rspec-mocks (~> 3.9.0)
59
+ rspec-core (3.9.1)
60
+ rspec-support (~> 3.9.1)
61
+ rspec-expectations (3.9.1)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.9.0)
64
+ rspec-its (1.3.0)
65
+ rspec-core (>= 3.0.0)
66
+ rspec-expectations (>= 3.0.0)
67
+ rspec-mocks (3.9.1)
68
+ diff-lcs (>= 1.2.0, < 2.0)
69
+ rspec-support (~> 3.9.0)
70
+ rspec-support (3.9.2)
71
+ rubocop (0.82.0)
72
+ jaro_winkler (~> 1.5.1)
73
+ parallel (~> 1.10)
74
+ parser (>= 2.7.0.1)
75
+ rainbow (>= 2.2.2, < 4.0)
76
+ rexml
77
+ ruby-progressbar (~> 1.7)
78
+ unicode-display_width (>= 1.4.0, < 2.0)
79
+ rubocop-rspec (1.38.1)
80
+ rubocop (>= 0.68.1)
81
+ ruby-progressbar (1.10.1)
82
+ ruby2_keywords (0.0.5)
83
+ thor (0.20.3)
84
+ unicode-display_width (1.7.0)
85
+ vcr (6.0.0)
86
+ webmock (3.14.0)
87
+ addressable (>= 2.8.0)
88
+ crack (>= 0.3.2)
89
+ hashdiff (>= 0.4.0, < 2.0.0)
90
+
91
+ PLATFORMS
92
+ ruby
93
+
94
+ DEPENDENCIES
95
+ bundler
96
+ bundler-audit
97
+ pry
98
+ rake
99
+ rspec
100
+ rspec-its
101
+ rubocop
102
+ rubocop-rspec
103
+ vcr
104
+ veryfi!
105
+ webmock
106
+
107
+ BUNDLED WITH
108
+ 1.17.2
data/README.md ADDED
@@ -0,0 +1,253 @@
1
+ # Veryfi SDK for Ruby
2
+
3
+ ![Veryfi Logo](https://cdn.veryfi.com/logos/veryfi-logo-wide-github.png)
4
+
5
+ ## Table of Contents
6
+
7
+ - [Veryfi SDK for Ruby](#veryfi-sdk-for-ruby)
8
+ - [Table of Contents](#table-of-contents)
9
+ - [Installation](#installation)
10
+ - [Getting Started](#getting-started)
11
+ - [Obtaining Client ID and user keys](#obtaining-client-id-and-user-keys)
12
+ - [Ruby API Client Library](#ruby-api-client-library)
13
+ - [Extracting Data](#extracting-data)
14
+ - [Response](#response)
15
+ - [Updating a document](#updating-a-document)
16
+ - [Need help?](#need-help)
17
+ - [Learn more at our blog](#learn-more-at-our-blog)
18
+ - [Tutorial Video](#tutorial-video)
19
+ - [For Developers](#for-developers)
20
+ - [Install](#install)
21
+ - [Quality tools](#quality-tools)
22
+ - [Develop](#develop)
23
+
24
+ **veryfi** is a Ruby gem for communicating with the [Veryfi OCR API](https://veryfi.com/api/)
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ gem install veryfi
30
+ ```
31
+
32
+ Or add to your Gemfile:
33
+ ```ruby
34
+ gem 'veryfi'
35
+ ```
36
+
37
+ ## Getting Started
38
+
39
+ ### Obtaining Client ID and user keys
40
+
41
+ If you don't have an account with Veryfi, please go ahead and register here: [https://hub.veryfi.com/signup/api/](https://hub.veryfi.com/signup/api/)
42
+
43
+ ### Ruby API Client Library
44
+
45
+ The **veryfi** gem can be used to communicate with Veryfi API. All available functionality is described here: <https://veryfi.github.io/veryfi-ruby/Client.html>
46
+
47
+ Below is a sample script using **Veryfi** for OCR and extracting data from a document:
48
+
49
+ ### Extracting Data
50
+
51
+ ```ruby
52
+ require 'veryfi'
53
+
54
+ veryfi_client = Veryfi::Client.new(
55
+ client_id: 'your_client_id',
56
+ client_secret: 'your_client_secret',
57
+ username: 'your_username',
58
+ api_key: 'your_password'
59
+ )
60
+
61
+ categories = ['Grocery', 'Utilities', 'Travel'];
62
+ file_path = './test/receipt.png';
63
+ ```
64
+
65
+ This submits a document for processing (3-5 seconds for a response)
66
+
67
+ ```ruby
68
+ response = veryfi_client.process_document(file_path, categories)
69
+
70
+ puts response
71
+ ```
72
+
73
+ ...or with a URL
74
+
75
+ ```ruby
76
+ response = veryfi_client.process_document_url(url, external_id)
77
+
78
+ puts response
79
+ ```
80
+
81
+ ### Response
82
+
83
+ ```json
84
+ {
85
+ "abn_number": "",
86
+ "account_number": "",
87
+ "bill_to_address": "2 Court Square\nNew York, NY 12210",
88
+ "bill_to_name": "John Smith",
89
+ "bill_to_vat_number": "",
90
+ "card_number": "",
91
+ "cashback": 0,
92
+ "category": "Repairs & Maintenance",
93
+ "created": "2021-06-28 19:20:02",
94
+ "currency_code": "USD",
95
+ "date": "2019-02-11 00:00:00",
96
+ "delivery_date": "",
97
+ "discount": 0,
98
+ "document_reference_number": "",
99
+ "document_title": "",
100
+ "document_type": "invoice",
101
+ "due_date": "2019-02-26",
102
+ "duplicate_of": 37055375,
103
+ "external_id": "",
104
+ "id": 37187909,
105
+ "img_file_name": "receipt.png",
106
+ "img_thumbnail_url": "https://scdn.veryfi.com/receipts/thumbnail.png",
107
+ "img_url": "https://scdn.veryfi.com/receipts/receipt.png",
108
+ "insurance": "",
109
+ "invoice_number": "US-001",
110
+ "is_duplicate": 1,
111
+ "line_items": [
112
+ {
113
+ "date": "",
114
+ "description": "Front and rear brake cables",
115
+ "discount": 0,
116
+ "id": 68004313,
117
+ "order": 0,
118
+ "price": 100,
119
+ "quantity": 1,
120
+ "reference": "",
121
+ "section": "",
122
+ "sku": "",
123
+ "tax": 0,
124
+ "tax_rate": 0,
125
+ "total": 100,
126
+ "type": "product",
127
+ "unit_of_measure": ""
128
+ },
129
+ {
130
+ "date": "",
131
+ "description": "New set of pedal arms",
132
+ "discount": 0,
133
+ "id": 68004315,
134
+ "order": 1,
135
+ "price": 15,
136
+ "quantity": 2,
137
+ "reference": "",
138
+ "section": "",
139
+ "sku": "",
140
+ "tax": 0,
141
+ "tax_rate": 0,
142
+ "total": 30,
143
+ "type": "product",
144
+ "unit_of_measure": ""
145
+ },
146
+ {
147
+ "date": "",
148
+ "description": "Labor 3hrs",
149
+ "discount": 0,
150
+ "id": 68004316,
151
+ "order": 2,
152
+ "price": 5,
153
+ "quantity": 3,
154
+ "reference": "",
155
+ "section": "",
156
+ "sku": "",
157
+ "tax": 0,
158
+ "tax_rate": 0,
159
+ "total": 15,
160
+ "type": "service",
161
+ "unit_of_measure": ""
162
+ }
163
+ ],
164
+ "notes": "",
165
+ "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",
166
+ "order_date": "",
167
+ "payment_display_name": "",
168
+ "payment_terms": "15 days",
169
+ "payment_type": "",
170
+ "phone_number": "",
171
+ "purchase_order_number": "2312/2019",
172
+ "rounding": 0,
173
+ "service_end_date": "",
174
+ "service_start_date": "",
175
+ "ship_date": "",
176
+ "ship_to_address": "3787 Pineview Drive\nCambridge, MA 12210",
177
+ "ship_to_name": "John Smith",
178
+ "shipping": 0,
179
+ "store_number": "",
180
+ "subtotal": 145,
181
+ "tax": 9.06,
182
+ "tax_lines": [
183
+ {
184
+ "base": 0,
185
+ "name": "Sales",
186
+ "order": 0,
187
+ "rate": 6.25,
188
+ "total": 9.06
189
+ }
190
+ ],
191
+ "tip": 0,
192
+ "total": 154.06,
193
+ "total_weight": "",
194
+ "tracking_number": "",
195
+ "updated": "2021-06-28 19:20:03",
196
+ "vat_number": "",
197
+ "vendor": {
198
+ "address": "1912 Harvest Lane\nNew York, NY 12210",
199
+ "category": "Car Repair",
200
+ "email": "",
201
+ "fax_number": "",
202
+ "name": "East Repair",
203
+ "phone_number": "",
204
+ "raw_name": "East Repair Inc.",
205
+ "vendor_logo": "https://cdn.veryfi.com/logos/tmp/560806841.png",
206
+ "vendor_reg_number": "",
207
+ "vendor_type": "Car Repair",
208
+ "web": ""
209
+ },
210
+ "vendor_account_number": "",
211
+ "vendor_bank_name": "",
212
+ "vendor_bank_number": "",
213
+ "vendor_bank_swift": "",
214
+ "vendor_iban": ""
215
+ }
216
+ ```
217
+
218
+ ### Updating a document
219
+
220
+ ```ruby
221
+ ```
222
+
223
+ ## Need help?
224
+
225
+ If you run into any issue or need help installing or using the library, please contact support@veryfi.com.
226
+
227
+ If you found a bug in this library or would like new features added, then open an issue or pull requests against this repo!
228
+
229
+ ### [Learn more at our blog](https://www.veryfi.com/ruby/)
230
+
231
+ ## Tutorial Video
232
+
233
+ TBD
234
+ <!-- [![Veryfi Tutorial]()]() -->
235
+
236
+ ---
237
+
238
+ # For Developers
239
+
240
+ ## Install
241
+
242
+ ```bash
243
+ bin/setup
244
+ ```
245
+
246
+ ## Quality tools
247
+
248
+ * `bin/quality` based on [RuboCop](https://github.com/bbatsov/rubocop)
249
+ * `.rubocop.yml` describes active checks
250
+
251
+ ## Develop
252
+
253
+ `bin/build` checks your specs and runs quality tools
data/bin/autospec ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'autospec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'autospec')
data/bin/build ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env sh
2
+
3
+ set -e
4
+
5
+ bin/quality
6
+ bin/rspec
data/bin/bundle-audit ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle-audit' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("bundler-audit", "bundle-audit")
data/bin/ci ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env sh
2
+
3
+ set -e
4
+
5
+ bin/quality
6
+ bin/rspec spec
data/bin/console ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby -Ilib
2
+
3
+ require "bundler/setup"
4
+
5
+ # include here main library file
6
+ # require "main-file"
7
+
8
+ require "irb"
9
+ IRB.start
data/bin/quality ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env sh
2
+
3
+ set -e
4
+
5
+ bin/rubocop
6
+ bin/bundle-audit update
7
+ bin/bundle-audit
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/rubocop ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rubocop", "rubocop")
data/bin/setup ADDED
@@ -0,0 +1,11 @@
1
+ #!/bin/sh
2
+ # Make sure local dependencies are met.
3
+
4
+ cd "$(dirname $0)"/..
5
+
6
+ gem install bundler --conservative
7
+
8
+ rm -f .bundle/config
9
+
10
+ bundle check --path .bundle > /dev/null 2>&1 ||
11
+ bundle install --path=.bundle
data/lib/.keep ADDED
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Veryfi
4
+ module Api
5
+ class Document
6
+ attr_reader :request
7
+
8
+ def initialize(request)
9
+ @request = request
10
+ end
11
+
12
+ def all(params = {})
13
+ response = request.get("/partner/documents/", params)
14
+
15
+ Array(response)
16
+ end
17
+
18
+ def get(id, params = {})
19
+ request.get("/partner/documents/#{id}", params)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Veryfi
4
+ class Client
5
+ CATEGORIES = [
6
+ "Advertising & Marketing",
7
+ "Automotive",
8
+ "Bank Charges & Fees",
9
+ "Legal & Professional Services",
10
+ "Insurance",
11
+ "Meals & Entertainment",
12
+ "Office Supplies & Software",
13
+ "Taxes & Licenses",
14
+ "Travel",
15
+ "Rent & Lease",
16
+ "Repairs & Maintenance",
17
+ "Payroll",
18
+ "Utilities",
19
+ "Job Supplies",
20
+ "Grocery"
21
+ ].freeze
22
+
23
+ attr_reader :request
24
+
25
+ def initialize(
26
+ client_id:,
27
+ client_secret:,
28
+ username:,
29
+ api_key:,
30
+ base_url: "https://api.veryfi.com/api/",
31
+ api_version: "v7",
32
+ timeout: 120
33
+ )
34
+ @request = Veryfi::Request.new(client_id, client_secret, username, api_key, base_url, api_version, timeout)
35
+ end
36
+
37
+ def document
38
+ @_document ||= Veryfi::Api::Document.new(request)
39
+ end
40
+
41
+ def api_url
42
+ request.api_url
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require "faraday"
5
+ require "json"
6
+
7
+ module Veryfi
8
+ class Request
9
+ attr_reader :client_id, :client_secret, :username, :api_key, :base_url, :api_version, :timeout
10
+
11
+ def initialize(
12
+ client_id,
13
+ client_secret,
14
+ username,
15
+ api_key,
16
+ base_url,
17
+ api_version,
18
+ timeout
19
+ )
20
+ @client_id = client_id
21
+ @client_secret = client_secret
22
+ @username = username
23
+ @api_key = api_key
24
+ @base_url = base_url
25
+ @api_version = api_version
26
+ @timeout = timeout
27
+ end
28
+
29
+ def get(path, params)
30
+ url = [api_url, path].join
31
+ headers = generate_headers(params)
32
+ response = Faraday.get(url, params, headers)
33
+ JSON.parse(response.body)
34
+ end
35
+
36
+ def api_url
37
+ @_api_url ||= [base_url, api_version].join
38
+ end
39
+
40
+ private
41
+
42
+ def generate_headers(params = {})
43
+ return default_headers if client_secret.nil?
44
+
45
+ timestamp = DateTime.now.strftime("%Q")
46
+ signature = generate_signature(params, timestamp)
47
+
48
+ default_headers.merge(
49
+ "X-Veryfi-Request-Timestamp": timestamp,
50
+ "X-Veryfi-Request-Signature": signature
51
+ )
52
+ end
53
+
54
+ def default_headers(has_files: false)
55
+ {
56
+ "User-Agent": "Ruby Veryfi-Ruby/0.1.0",
57
+ "Accept": "application/json",
58
+ "Content-Type": has_files ? "application/x-www-form-urlencoded" : "application/json",
59
+ "Client-Id": client_id,
60
+ "Authorization": "apikey #{username}:#{api_key}"
61
+ }
62
+ end
63
+
64
+ def generate_signature(params, timestamp)
65
+ Veryfi::Signature.new(client_secret, params, timestamp).to_base64
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "openssl"
4
+ require "Base64"
5
+
6
+ module Veryfi
7
+ class Signature
8
+ attr_reader :secret, :params, :timestamp
9
+
10
+ def initialize(secret, params, timestamp)
11
+ @secret = secret
12
+ @params = params
13
+ @timestamp = timestamp
14
+ end
15
+
16
+ def to_base64
17
+ Base64.encode64(digest).strip
18
+ end
19
+
20
+ # private
21
+
22
+ def digest
23
+ OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new("sha256"), secret, payload)
24
+ end
25
+
26
+ def payload
27
+ "timestamp:#{timestamp}," + params.to_a.map { |i| "#{i[0]}:#{i[1]}" }.join(",")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Veryfi
4
+ VERSION = "0.0.0"
5
+ end
data/lib/veryfi.rb ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Veryfi
4
+ autoload :VERSION, "veryfi/version"
5
+ autoload :Signature, "veryfi/signature"
6
+ autoload :Request, "veryfi/request"
7
+
8
+ module Api
9
+ autoload :Document, "veryfi/api/document"
10
+ end
11
+
12
+ autoload :Client, "veryfi/client"
13
+ end
data/veryfi.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "veryfi/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "veryfi"
9
+ spec.version = Veryfi::VERSION
10
+ spec.authors = ["Veryfi"]
11
+ spec.email = ["support@veryfi.com"]
12
+
13
+ spec.summary = "Veryfi SDK for Ruby"
14
+
15
+ spec.homepage = "https://rubygems.org/gems/veryfi"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+ spec.license = "MIT"
24
+
25
+ spec.add_dependency "faraday", "~> 1.7"
26
+ spec.add_dependency "openssl", "~> 2.2"
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.17"
29
+ spec.add_development_dependency "bundler-audit", "~> 0.6"
30
+ spec.add_development_dependency "pry", "~> 0.14"
31
+ spec.add_development_dependency "rake", "~> 13.0"
32
+ spec.add_development_dependency "rspec", "~> 3.9"
33
+ spec.add_development_dependency "rspec-its", "~> 1.3"
34
+ spec.add_development_dependency "rubocop", "~> 0.82"
35
+ spec.add_development_dependency "rubocop-rspec", "~> 1.38"
36
+ spec.add_development_dependency "vcr", "~> 6.0"
37
+ spec.add_development_dependency "webmock", "~> 3.14"
38
+ end
metadata ADDED
@@ -0,0 +1,236 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: veryfi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Veryfi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-08-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: openssl
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.17'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.17'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler-audit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.14'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.14'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '13.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '13.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.9'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.9'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-its
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.3'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.3'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.82'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.82'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.38'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.38'
153
+ - !ruby/object:Gem::Dependency
154
+ name: vcr
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '6.0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '6.0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: webmock
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '3.14'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '3.14'
181
+ description:
182
+ email:
183
+ - support@veryfi.com
184
+ executables: []
185
+ extensions: []
186
+ extra_rdoc_files: []
187
+ files:
188
+ - ".gitignore"
189
+ - ".rspec"
190
+ - ".rubocop.yml"
191
+ - ".ruby-version"
192
+ - ".semaphore/semaphore.yml"
193
+ - Gemfile
194
+ - Gemfile.lock
195
+ - README.md
196
+ - bin/autospec
197
+ - bin/build
198
+ - bin/bundle-audit
199
+ - bin/ci
200
+ - bin/console
201
+ - bin/quality
202
+ - bin/rspec
203
+ - bin/rubocop
204
+ - bin/setup
205
+ - lib/.keep
206
+ - lib/veryfi.rb
207
+ - lib/veryfi/api/document.rb
208
+ - lib/veryfi/client.rb
209
+ - lib/veryfi/request.rb
210
+ - lib/veryfi/signature.rb
211
+ - lib/veryfi/version.rb
212
+ - veryfi.gemspec
213
+ homepage: https://rubygems.org/gems/veryfi
214
+ licenses:
215
+ - MIT
216
+ metadata: {}
217
+ post_install_message:
218
+ rdoc_options: []
219
+ require_paths:
220
+ - lib
221
+ required_ruby_version: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - ">="
224
+ - !ruby/object:Gem::Version
225
+ version: '0'
226
+ required_rubygems_version: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ">="
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ requirements: []
232
+ rubygems_version: 3.1.4
233
+ signing_key:
234
+ specification_version: 4
235
+ summary: Veryfi SDK for Ruby
236
+ test_files: []