veryfi 3.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +1 -1
- data/.github/workflows/test.yml +1 -1
- data/.gitignore +4 -1
- data/.rubocop.yml +5 -1
- data/.ruby-version +1 -1
- data/.yardopts +10 -0
- data/Gemfile.lock +55 -56
- data/README.md +530 -2
- data/Rakefile +21 -0
- data/lib/veryfi/api/any_document.rb +123 -0
- data/lib/veryfi/api/bank_statement.rb +114 -0
- data/lib/veryfi/api/bank_statement_split.rb +66 -0
- data/lib/veryfi/api/business_card.rb +84 -0
- data/lib/veryfi/api/check.rb +127 -0
- data/lib/veryfi/api/classify.rb +53 -0
- data/lib/veryfi/api/document.rb +117 -0
- data/lib/veryfi/api/document_tag.rb +43 -0
- data/lib/veryfi/api/file_payload.rb +23 -0
- data/lib/veryfi/api/line_item.rb +55 -0
- data/lib/veryfi/api/pdf_split.rb +75 -0
- data/lib/veryfi/api/tag.rb +14 -0
- data/lib/veryfi/api/tag_operations.rb +63 -0
- data/lib/veryfi/api/tax_line.rb +71 -0
- data/lib/veryfi/api/w2.rb +90 -0
- data/lib/veryfi/api/w2_split.rb +68 -0
- data/lib/veryfi/api/w8.rb +90 -0
- data/lib/veryfi/api/w9.rb +92 -0
- data/lib/veryfi/client.rb +61 -17
- data/lib/veryfi/configuration.rb +28 -0
- data/lib/veryfi/error.rb +98 -12
- data/lib/veryfi/request.rb +32 -13
- data/lib/veryfi/resource.rb +102 -0
- data/lib/veryfi/version.rb +1 -1
- data/lib/veryfi.rb +64 -0
- data/veryfi.gemspec +24 -2
- metadata +40 -8
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Veryfi
|
|
4
|
+
# A lightweight, dependency-free wrapper around an API response payload.
|
|
5
|
+
#
|
|
6
|
+
# `Resource` inherits from `Hash`, so anything that already treats the
|
|
7
|
+
# response as a hash keeps working unchanged:
|
|
8
|
+
#
|
|
9
|
+
# response["id"] # => 44691518
|
|
10
|
+
# response.dig("vendor", "name")
|
|
11
|
+
# response.is_a?(Hash) # => true
|
|
12
|
+
# JSON.pretty_generate(response)
|
|
13
|
+
#
|
|
14
|
+
# In addition, every key is also accessible as a method, recursively:
|
|
15
|
+
#
|
|
16
|
+
# response.id # => 44691518
|
|
17
|
+
# response.vendor.name # => "East Repair"
|
|
18
|
+
# response.line_items.first.description
|
|
19
|
+
# response.is_duplicate? # => truthiness of self["is_duplicate"]
|
|
20
|
+
#
|
|
21
|
+
# Nested hashes are wrapped into Resources, and arrays of hashes become
|
|
22
|
+
# arrays of Resources. Other values (strings, numbers, booleans, nil)
|
|
23
|
+
# pass through untouched. Both string (`"id"`) and symbol (`:id`) keys
|
|
24
|
+
# work transparently.
|
|
25
|
+
class Resource < ::Hash
|
|
26
|
+
# Wrap any value coming back from the API. Hashes become Resources,
|
|
27
|
+
# arrays are mapped recursively, and everything else passes through.
|
|
28
|
+
#
|
|
29
|
+
# @param value [Object] raw value from `JSON.parse`
|
|
30
|
+
# @return [Object] wrapped value
|
|
31
|
+
def self.wrap(value)
|
|
32
|
+
return value if value.is_a?(Resource)
|
|
33
|
+
|
|
34
|
+
case value
|
|
35
|
+
when ::Hash then new(value)
|
|
36
|
+
when ::Array then value.map { |v| wrap(v) }
|
|
37
|
+
else value
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def initialize(hash = {})
|
|
42
|
+
super()
|
|
43
|
+
hash.each_pair { |key, value| self[key.to_s] = Resource.wrap(value) }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def [](key)
|
|
47
|
+
super(key.to_s)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# rubocop:disable Style/ArgumentsForwarding -- keep explicit forwarding for clarity and Ruby 3.0 portability
|
|
51
|
+
def fetch(key, *args, &block)
|
|
52
|
+
super(key.to_s, *args, &block)
|
|
53
|
+
end
|
|
54
|
+
# rubocop:enable Style/ArgumentsForwarding
|
|
55
|
+
|
|
56
|
+
def key?(key)
|
|
57
|
+
super(key.to_s)
|
|
58
|
+
end
|
|
59
|
+
alias has_key? key?
|
|
60
|
+
alias include? key?
|
|
61
|
+
alias member? key?
|
|
62
|
+
|
|
63
|
+
# Returns a plain (unwrapped) `Hash` representation, recursively.
|
|
64
|
+
# Useful when you need to hand the data off to something that explicitly
|
|
65
|
+
# expects a plain Hash (e.g. some serializers).
|
|
66
|
+
#
|
|
67
|
+
# @return [Hash]
|
|
68
|
+
def to_h
|
|
69
|
+
each_with_object({}) do |(key, value), memo|
|
|
70
|
+
memo[key] = unwrap(value)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
alias to_hash to_h
|
|
74
|
+
|
|
75
|
+
def respond_to_missing?(name, include_private = false)
|
|
76
|
+
string_name = name.to_s.chomp("?")
|
|
77
|
+
key?(string_name) || super
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def method_missing(name, *args, &block)
|
|
81
|
+
string_name = name.to_s
|
|
82
|
+
bare_name = string_name.chomp("?")
|
|
83
|
+
|
|
84
|
+
if args.empty? && block.nil? && key?(bare_name)
|
|
85
|
+
value = self[bare_name]
|
|
86
|
+
string_name.end_with?("?") ? !value.nil? && value != false : value
|
|
87
|
+
else
|
|
88
|
+
super
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
|
|
94
|
+
def unwrap(value)
|
|
95
|
+
case value
|
|
96
|
+
when Resource then value.to_h
|
|
97
|
+
when ::Array then value.map { |v| v.is_a?(Resource) ? v.to_h : v }
|
|
98
|
+
else value
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
data/lib/veryfi/version.rb
CHANGED
data/lib/veryfi.rb
CHANGED
|
@@ -4,14 +4,78 @@ module Veryfi
|
|
|
4
4
|
autoload :VERSION, "veryfi/version"
|
|
5
5
|
autoload :Signature, "veryfi/signature"
|
|
6
6
|
autoload :Request, "veryfi/request"
|
|
7
|
+
autoload :Resource, "veryfi/resource"
|
|
7
8
|
autoload :Error, "veryfi/error"
|
|
9
|
+
autoload :Configuration, "veryfi/configuration"
|
|
8
10
|
|
|
9
11
|
module Api
|
|
12
|
+
autoload :FilePayload, "veryfi/api/file_payload"
|
|
13
|
+
autoload :TagOperations, "veryfi/api/tag_operations"
|
|
14
|
+
|
|
10
15
|
autoload :Document, "veryfi/api/document"
|
|
11
16
|
autoload :LineItem, "veryfi/api/line_item"
|
|
17
|
+
autoload :TaxLine, "veryfi/api/tax_line"
|
|
12
18
|
autoload :Tag, "veryfi/api/tag"
|
|
13
19
|
autoload :DocumentTag, "veryfi/api/document_tag"
|
|
20
|
+
|
|
21
|
+
autoload :AnyDocument, "veryfi/api/any_document"
|
|
22
|
+
autoload :BankStatement, "veryfi/api/bank_statement"
|
|
23
|
+
autoload :BankStatementSplit, "veryfi/api/bank_statement_split"
|
|
24
|
+
autoload :BusinessCard, "veryfi/api/business_card"
|
|
25
|
+
autoload :Check, "veryfi/api/check"
|
|
26
|
+
autoload :Classify, "veryfi/api/classify"
|
|
27
|
+
autoload :PdfSplit, "veryfi/api/pdf_split"
|
|
28
|
+
autoload :W2, "veryfi/api/w2"
|
|
29
|
+
autoload :W2Split, "veryfi/api/w2_split"
|
|
30
|
+
autoload :W8, "veryfi/api/w8"
|
|
31
|
+
autoload :W9, "veryfi/api/w9"
|
|
14
32
|
end
|
|
15
33
|
|
|
16
34
|
autoload :Client, "veryfi/client"
|
|
35
|
+
|
|
36
|
+
class << self
|
|
37
|
+
# Process-wide configuration, used by {Veryfi.client} as defaults when
|
|
38
|
+
# constructing the shared client. You can still call
|
|
39
|
+
# `Veryfi::Client.new(...)` directly to bypass this entirely.
|
|
40
|
+
#
|
|
41
|
+
# @example
|
|
42
|
+
# Veryfi.configure do |c|
|
|
43
|
+
# c.client_id = ENV.fetch("VERYFI_CLIENT_ID")
|
|
44
|
+
# c.client_secret = ENV.fetch("VERYFI_CLIENT_SECRET")
|
|
45
|
+
# c.username = ENV.fetch("VERYFI_USERNAME")
|
|
46
|
+
# c.api_key = ENV.fetch("VERYFI_API_KEY")
|
|
47
|
+
# end
|
|
48
|
+
#
|
|
49
|
+
# Veryfi.client.document.process(file_path: "./receipt.jpg")
|
|
50
|
+
#
|
|
51
|
+
# @yieldparam config [Veryfi::Configuration]
|
|
52
|
+
# @return [Veryfi::Configuration]
|
|
53
|
+
def configure
|
|
54
|
+
yield(configuration) if block_given?
|
|
55
|
+
configuration
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# @return [Veryfi::Configuration] the global configuration object.
|
|
59
|
+
def configuration
|
|
60
|
+
@_configuration ||= Veryfi::Configuration.new
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Process-wide memoized {Veryfi::Client} built from {.configuration}.
|
|
64
|
+
# Resets if you re-{.configure} the SDK after first use.
|
|
65
|
+
#
|
|
66
|
+
# @return [Veryfi::Client]
|
|
67
|
+
def client
|
|
68
|
+
@_client = nil if @_last_configuration_hash && @_last_configuration_hash != configuration.to_h
|
|
69
|
+
@_last_configuration_hash = configuration.to_h
|
|
70
|
+
@_client ||= Veryfi::Client.new(**configuration.to_h.compact)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Drop the memoized {.client} and {.configuration}. Mostly useful in tests.
|
|
74
|
+
# @return [void]
|
|
75
|
+
def reset!
|
|
76
|
+
@_configuration = nil
|
|
77
|
+
@_client = nil
|
|
78
|
+
@_last_configuration_hash = nil
|
|
79
|
+
end
|
|
80
|
+
end
|
|
17
81
|
end
|
data/veryfi.gemspec
CHANGED
|
@@ -27,9 +27,11 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
".rubocop.yml",
|
|
28
28
|
".ruby-version",
|
|
29
29
|
".semaphore/semaphore.yml",
|
|
30
|
+
".yardopts",
|
|
30
31
|
"Gemfile",
|
|
31
32
|
"Gemfile.lock",
|
|
32
33
|
"README.md",
|
|
34
|
+
"Rakefile",
|
|
33
35
|
"bin/autospec",
|
|
34
36
|
"bin/bundle-audit",
|
|
35
37
|
"bin/ci",
|
|
@@ -48,13 +50,29 @@ Gem::Specification.new do |spec|
|
|
|
48
50
|
"docs/index.markdown",
|
|
49
51
|
"lib/.keep",
|
|
50
52
|
"lib/veryfi.rb",
|
|
53
|
+
"lib/veryfi/api/any_document.rb",
|
|
54
|
+
"lib/veryfi/api/bank_statement.rb",
|
|
55
|
+
"lib/veryfi/api/bank_statement_split.rb",
|
|
56
|
+
"lib/veryfi/api/business_card.rb",
|
|
57
|
+
"lib/veryfi/api/check.rb",
|
|
58
|
+
"lib/veryfi/api/classify.rb",
|
|
51
59
|
"lib/veryfi/api/document.rb",
|
|
52
60
|
"lib/veryfi/api/document_tag.rb",
|
|
61
|
+
"lib/veryfi/api/file_payload.rb",
|
|
53
62
|
"lib/veryfi/api/line_item.rb",
|
|
63
|
+
"lib/veryfi/api/pdf_split.rb",
|
|
54
64
|
"lib/veryfi/api/tag.rb",
|
|
65
|
+
"lib/veryfi/api/tag_operations.rb",
|
|
66
|
+
"lib/veryfi/api/tax_line.rb",
|
|
67
|
+
"lib/veryfi/api/w2.rb",
|
|
68
|
+
"lib/veryfi/api/w2_split.rb",
|
|
69
|
+
"lib/veryfi/api/w8.rb",
|
|
70
|
+
"lib/veryfi/api/w9.rb",
|
|
55
71
|
"lib/veryfi/client.rb",
|
|
72
|
+
"lib/veryfi/configuration.rb",
|
|
56
73
|
"lib/veryfi/error.rb",
|
|
57
74
|
"lib/veryfi/request.rb",
|
|
75
|
+
"lib/veryfi/resource.rb",
|
|
58
76
|
"lib/veryfi/signature.rb",
|
|
59
77
|
"lib/veryfi/version.rb",
|
|
60
78
|
"veryfi.gemspec"
|
|
@@ -65,10 +83,13 @@ Gem::Specification.new do |spec|
|
|
|
65
83
|
spec.require_paths = ["lib"]
|
|
66
84
|
spec.license = "MIT"
|
|
67
85
|
|
|
86
|
+
spec.required_ruby_version = ">= 3.0"
|
|
87
|
+
|
|
68
88
|
spec.add_dependency "base64", "~> 0.1"
|
|
69
89
|
spec.add_dependency "openssl", ">= 2.2", "< 4.1"
|
|
70
90
|
|
|
71
|
-
|
|
91
|
+
# Faraday 2.14.1 is the floor of the CVE-2026-25765-fixed 2.x line.
|
|
92
|
+
spec.add_dependency "faraday", ">= 2.14.1", "< 3.0"
|
|
72
93
|
|
|
73
94
|
spec.add_development_dependency "bundler", "~> 2.4"
|
|
74
95
|
spec.add_development_dependency "bundler-audit", "~> 0.9"
|
|
@@ -77,11 +98,12 @@ Gem::Specification.new do |spec|
|
|
|
77
98
|
spec.add_development_dependency "rspec", "~> 3.9"
|
|
78
99
|
spec.add_development_dependency "rspec-its", "~> 1.3"
|
|
79
100
|
spec.add_development_dependency "rubocop", "~> 1.65"
|
|
101
|
+
spec.add_development_dependency "rubocop-rake", "~> 0.6"
|
|
80
102
|
spec.add_development_dependency "rubocop-rspec", "~> 3.0"
|
|
81
103
|
spec.add_development_dependency "simplecov", "~> 0.21"
|
|
82
104
|
spec.add_development_dependency "simplecov-badge", "~> 2.0"
|
|
83
105
|
spec.add_development_dependency "vcr", "~> 6.0"
|
|
84
106
|
spec.add_development_dependency "webmock", "~> 3.14"
|
|
85
107
|
spec.add_development_dependency "rexml", "~> 3.4.4"
|
|
86
|
-
spec.add_development_dependency "
|
|
108
|
+
spec.add_development_dependency "yard", "~> 0.9"
|
|
87
109
|
end
|
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:
|
|
4
|
+
version: 4.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Veryfi
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -50,7 +50,7 @@ dependencies:
|
|
|
50
50
|
requirements:
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
53
|
+
version: 2.14.1
|
|
54
54
|
- - "<"
|
|
55
55
|
- !ruby/object:Gem::Version
|
|
56
56
|
version: '3.0'
|
|
@@ -60,7 +60,7 @@ dependencies:
|
|
|
60
60
|
requirements:
|
|
61
61
|
- - ">="
|
|
62
62
|
- !ruby/object:Gem::Version
|
|
63
|
-
version:
|
|
63
|
+
version: 2.14.1
|
|
64
64
|
- - "<"
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
66
|
version: '3.0'
|
|
@@ -162,6 +162,20 @@ dependencies:
|
|
|
162
162
|
- - "~>"
|
|
163
163
|
- !ruby/object:Gem::Version
|
|
164
164
|
version: '1.65'
|
|
165
|
+
- !ruby/object:Gem::Dependency
|
|
166
|
+
name: rubocop-rake
|
|
167
|
+
requirement: !ruby/object:Gem::Requirement
|
|
168
|
+
requirements:
|
|
169
|
+
- - "~>"
|
|
170
|
+
- !ruby/object:Gem::Version
|
|
171
|
+
version: '0.6'
|
|
172
|
+
type: :development
|
|
173
|
+
prerelease: false
|
|
174
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
175
|
+
requirements:
|
|
176
|
+
- - "~>"
|
|
177
|
+
- !ruby/object:Gem::Version
|
|
178
|
+
version: '0.6'
|
|
165
179
|
- !ruby/object:Gem::Dependency
|
|
166
180
|
name: rubocop-rspec
|
|
167
181
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -247,19 +261,19 @@ dependencies:
|
|
|
247
261
|
- !ruby/object:Gem::Version
|
|
248
262
|
version: 3.4.4
|
|
249
263
|
- !ruby/object:Gem::Dependency
|
|
250
|
-
name:
|
|
264
|
+
name: yard
|
|
251
265
|
requirement: !ruby/object:Gem::Requirement
|
|
252
266
|
requirements:
|
|
253
267
|
- - "~>"
|
|
254
268
|
- !ruby/object:Gem::Version
|
|
255
|
-
version: '
|
|
269
|
+
version: '0.9'
|
|
256
270
|
type: :development
|
|
257
271
|
prerelease: false
|
|
258
272
|
version_requirements: !ruby/object:Gem::Requirement
|
|
259
273
|
requirements:
|
|
260
274
|
- - "~>"
|
|
261
275
|
- !ruby/object:Gem::Version
|
|
262
|
-
version: '
|
|
276
|
+
version: '0.9'
|
|
263
277
|
description:
|
|
264
278
|
email:
|
|
265
279
|
- support@veryfi.com
|
|
@@ -274,9 +288,11 @@ files:
|
|
|
274
288
|
- ".rubocop.yml"
|
|
275
289
|
- ".ruby-version"
|
|
276
290
|
- ".semaphore/semaphore.yml"
|
|
291
|
+
- ".yardopts"
|
|
277
292
|
- Gemfile
|
|
278
293
|
- Gemfile.lock
|
|
279
294
|
- README.md
|
|
295
|
+
- Rakefile
|
|
280
296
|
- bin/autospec
|
|
281
297
|
- bin/bundle-audit
|
|
282
298
|
- bin/ci
|
|
@@ -295,13 +311,29 @@ files:
|
|
|
295
311
|
- docs/index.markdown
|
|
296
312
|
- lib/.keep
|
|
297
313
|
- lib/veryfi.rb
|
|
314
|
+
- lib/veryfi/api/any_document.rb
|
|
315
|
+
- lib/veryfi/api/bank_statement.rb
|
|
316
|
+
- lib/veryfi/api/bank_statement_split.rb
|
|
317
|
+
- lib/veryfi/api/business_card.rb
|
|
318
|
+
- lib/veryfi/api/check.rb
|
|
319
|
+
- lib/veryfi/api/classify.rb
|
|
298
320
|
- lib/veryfi/api/document.rb
|
|
299
321
|
- lib/veryfi/api/document_tag.rb
|
|
322
|
+
- lib/veryfi/api/file_payload.rb
|
|
300
323
|
- lib/veryfi/api/line_item.rb
|
|
324
|
+
- lib/veryfi/api/pdf_split.rb
|
|
301
325
|
- lib/veryfi/api/tag.rb
|
|
326
|
+
- lib/veryfi/api/tag_operations.rb
|
|
327
|
+
- lib/veryfi/api/tax_line.rb
|
|
328
|
+
- lib/veryfi/api/w2.rb
|
|
329
|
+
- lib/veryfi/api/w2_split.rb
|
|
330
|
+
- lib/veryfi/api/w8.rb
|
|
331
|
+
- lib/veryfi/api/w9.rb
|
|
302
332
|
- lib/veryfi/client.rb
|
|
333
|
+
- lib/veryfi/configuration.rb
|
|
303
334
|
- lib/veryfi/error.rb
|
|
304
335
|
- lib/veryfi/request.rb
|
|
336
|
+
- lib/veryfi/resource.rb
|
|
305
337
|
- lib/veryfi/signature.rb
|
|
306
338
|
- lib/veryfi/version.rb
|
|
307
339
|
- veryfi.gemspec
|
|
@@ -317,7 +349,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
317
349
|
requirements:
|
|
318
350
|
- - ">="
|
|
319
351
|
- !ruby/object:Gem::Version
|
|
320
|
-
version: '0'
|
|
352
|
+
version: '3.0'
|
|
321
353
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
322
354
|
requirements:
|
|
323
355
|
- - ">="
|