Class: Veryfi::Api::AnyDocument
- Inherits:
-
Object
- Object
- Veryfi::Api::AnyDocument
- Includes:
- FilePayload, TagOperations
- Defined in:
- lib/veryfi/api/any_document.rb
Overview
Any Document (a-doc) endpoints (/partner/any-documents/).
An A-Doc is a custom document type, defined by a blueprint you
configure in Veryfi. Every "process" call must therefore include a
:blueprint_name.
Constant Summary collapse
- ENDPOINT =
"/partner/any-documents/"- ASYNC_ENDPOINT =
"/partner/any-documents/async"
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#all(params = {}) ⇒ Veryfi::Resource
List previously processed A-Docs.
-
#delete(id) ⇒ Veryfi::Resource
Delete an A-Doc.
-
#get(id, params = {}) ⇒ Veryfi::Resource
Fetch a single A-Doc by id.
-
#initialize(request) ⇒ AnyDocument
constructor
A new instance of AnyDocument.
-
#process(raw_params) ⇒ Veryfi::Resource
Upload a file and extract its fields using the given blueprint.
-
#process_async(raw_params) ⇒ Object
Same as #process but asynchronous — returns immediately with a
"status": "processing"payload while Veryfi runs the extraction in the background. -
#process_url(raw_params) ⇒ Veryfi::Resource
Process an A-Doc from a public URL.
-
#process_url_async(raw_params) ⇒ Object
URL variant of #process_async.
-
#update(id, params) ⇒ Veryfi::Resource
Update writable fields on a processed A-Doc.
Methods included from TagOperations
#add_tag, #add_tags, #delete_tag, #delete_tags, #tags
Constructor Details
#initialize(request) ⇒ AnyDocument
Returns a new instance of AnyDocument.
21 22 23 |
# File 'lib/veryfi/api/any_document.rb', line 21 def initialize(request) @request = request end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
19 20 21 |
# File 'lib/veryfi/api/any_document.rb', line 19 def request @request end |
Instance Method Details
#all(params = {}) ⇒ Veryfi::Resource
List previously processed A-Docs.
35 36 37 |
# File 'lib/veryfi/api/any_document.rb', line 35 def all(params = {}) request.get(ENDPOINT, params) end |
#delete(id) ⇒ Veryfi::Resource
Delete an A-Doc.
118 119 120 |
# File 'lib/veryfi/api/any_document.rb', line 118 def delete(id) request.delete("#{ENDPOINT}#{id}/") end |
#get(id, params = {}) ⇒ Veryfi::Resource
Fetch a single A-Doc by id.
44 45 46 |
# File 'lib/veryfi/api/any_document.rb', line 44 def get(id, params = {}) request.get("#{ENDPOINT}#{id}/", params) end |
#process(raw_params) ⇒ Veryfi::Resource
Upload a file and extract its fields using the given blueprint.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/veryfi/api/any_document.rb', line 55 def process(raw_params) params = raw_params.transform_keys(&:to_sym) blueprint_name = params.delete(:blueprint_name) file_path = params.delete(:file_path) file_name = params.delete(:file_name) payload = file_payload(file_path, file_name).merge(blueprint_name: blueprint_name).merge(params) request.post(ENDPOINT, payload) end |
#process_async(raw_params) ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/veryfi/api/any_document.rb', line 86 def process_async(raw_params) params = raw_params.transform_keys(&:to_sym) blueprint_name = params.delete(:blueprint_name) file_path = params.delete(:file_path) file_name = params.delete(:file_name) payload = file_payload(file_path, file_name).merge(blueprint_name: blueprint_name).merge(params) request.post(ASYNC_ENDPOINT, payload) end |
#process_url(raw_params) ⇒ Veryfi::Resource
Process an A-Doc from a public URL.
73 74 75 76 77 78 |
# File 'lib/veryfi/api/any_document.rb', line 73 def process_url(raw_params) params = raw_params.transform_keys(&:to_sym) params[:file_name] ||= File.basename(params[:file_url]) if params[:file_url] request.post(ENDPOINT, params) end |
#process_url_async(raw_params) ⇒ Object
URL variant of #process_async.
98 99 100 101 102 103 |
# File 'lib/veryfi/api/any_document.rb', line 98 def process_url_async(raw_params) params = raw_params.transform_keys(&:to_sym) params[:file_name] ||= File.basename(params[:file_url]) if params[:file_url] request.post(ASYNC_ENDPOINT, params) end |
#update(id, params) ⇒ Veryfi::Resource
Update writable fields on a processed A-Doc.
110 111 112 |
# File 'lib/veryfi/api/any_document.rb', line 110 def update(id, params) request.put("#{ENDPOINT}#{id}/", params) end |