Class: Veryfi::Api::Classify
- Inherits:
-
Object
- Object
- Veryfi::Api::Classify
- Includes:
- FilePayload
- Defined in:
- lib/veryfi/api/classify.rb
Overview
Document classification endpoint (/partner/classify/).
Given a file and an optional set of candidate document types, returns Veryfi's best guess at what kind of document it is (invoice, receipt, w-2, …) along with confidence scores.
Constant Summary collapse
- ENDPOINT =
"/partner/classify/"
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#initialize(request) ⇒ Classify
constructor
A new instance of Classify.
-
#process(raw_params) ⇒ Veryfi::Resource
Upload a local file for classification.
-
#process_url(raw_params) ⇒ Veryfi::Resource
URL variant of #process.
Constructor Details
#initialize(request) ⇒ Classify
Returns a new instance of Classify.
19 20 21 |
# File 'lib/veryfi/api/classify.rb', line 19 def initialize(request) @request = request end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
17 18 19 |
# File 'lib/veryfi/api/classify.rb', line 17 def request @request end |
Instance Method Details
#process(raw_params) ⇒ Veryfi::Resource
Upload a local file for classification.
31 32 33 34 35 36 37 38 39 |
# File 'lib/veryfi/api/classify.rb', line 31 def process(raw_params) params = raw_params.transform_keys(&:to_sym) file_path = params.delete(:file_path) file_name = params.delete(:file_name) payload = file_payload(file_path, file_name).merge(params) request.post(ENDPOINT, payload) end |
#process_url(raw_params) ⇒ Veryfi::Resource
URL variant of #process.
48 49 50 |
# File 'lib/veryfi/api/classify.rb', line 48 def process_url(raw_params) request.post(ENDPOINT, raw_params.transform_keys(&:to_sym)) end |