Class: Veryfi::Api::Check

Inherits:
Object
  • Object
show all
Includes:
FilePayload, TagOperations
Defined in:
lib/veryfi/api/check.rb

Overview

Checks endpoints (/partner/checks/ and /partner/check-with-document/ for combined check + remittance extraction).

Constant Summary collapse

ENDPOINT =
"/partner/checks/"
REMITTANCE_ENDPOINT =
"/partner/check-with-document/"
ASYNC_ENDPOINT =
"/partner/checks/async"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TagOperations

#add_tag, #add_tags, #delete_tag, #delete_tags, #tags

Constructor Details

#initialize(request) ⇒ Check

Returns a new instance of Check.



20
21
22
# File 'lib/veryfi/api/check.rb', line 20

def initialize(request)
  @request = request
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



18
19
20
# File 'lib/veryfi/api/check.rb', line 18

def request
  @request
end

Instance Method Details

#all(params = {}) ⇒ Veryfi::Resource

List previously processed checks.

Parameters:

  • params (Hash) (defaults to: {})

    optional query-string parameters

Options Hash (params):

  • :created_date__gt (String)

    "YYYY-MM-DD HH:MM:SS" — strictly after

  • :created_date__gte (String)

    after or equal

  • :created_date__lt (String)

    strictly before

  • :created_date__lte (String)

    before or equal

  • :page (Integer) — default: 1
  • :page_size (Integer) — default: 50

Returns:



34
35
36
# File 'lib/veryfi/api/check.rb', line 34

def all(params = {})
  request.get(ENDPOINT, params)
end

#delete(id) ⇒ Veryfi::Resource

Delete a check.

Parameters:

  • id (Integer)

Returns:



112
113
114
# File 'lib/veryfi/api/check.rb', line 112

def delete(id)
  request.delete("#{ENDPOINT}#{id}/")
end

#get(id, params = {}) ⇒ Veryfi::Resource

Fetch a single check by id.

Parameters:

  • id (Integer)
  • params (Hash) (defaults to: {})

    optional query-string parameters

Returns:



43
44
45
# File 'lib/veryfi/api/check.rb', line 43

def get(id, params = {})
  request.get("#{ENDPOINT}#{id}/", params)
end

#process(raw_params) ⇒ Veryfi::Resource

Upload a check image and extract its fields.

Parameters:

  • raw_params (Hash)

Options Hash (raw_params):

  • :file_path (String)

    required. Local path.

  • :file_name (String) — default: basename of `:file_path`

Returns:



53
54
55
# File 'lib/veryfi/api/check.rb', line 53

def process(raw_params)
  request.post(ENDPOINT, build_file_payload(raw_params))
end

#process_async(raw_params) ⇒ Object

Async variant of #process — returns immediately while Veryfi processes the check in the background.



87
88
89
# File 'lib/veryfi/api/check.rb', line 87

def process_async(raw_params)
  request.post(ASYNC_ENDPOINT, build_file_payload(raw_params))
end

#process_url(raw_params) ⇒ Veryfi::Resource

URL variant of #process.

Parameters:

  • raw_params (Hash)

Options Hash (raw_params):

  • :file_url (String)

    single URL

  • :file_urls (Array<String>)

    list of URLs (alternative to :file_url)

Returns:



63
64
65
# File 'lib/veryfi/api/check.rb', line 63

def process_url(raw_params)
  request.post(ENDPOINT, raw_params.transform_keys(&:to_sym))
end

#process_url_async(raw_params) ⇒ Object

Async variant of #process_url.



92
93
94
# File 'lib/veryfi/api/check.rb', line 92

def process_url_async(raw_params)
  request.post(ASYNC_ENDPOINT, raw_params.transform_keys(&:to_sym))
end

#process_with_remittance(raw_params) ⇒ Veryfi::Resource

Process a check together with its remittance/stub document. Veryfi will OCR both halves and return a single combined response.

Parameters:

  • raw_params (Hash)

Options Hash (raw_params):

  • :file_path (String)

    required.

  • :file_name (String) — default: basename of `:file_path`

Returns:

See Also:



76
77
78
# File 'lib/veryfi/api/check.rb', line 76

def process_with_remittance(raw_params)
  request.post(REMITTANCE_ENDPOINT, build_file_payload(raw_params))
end

#process_with_remittance_url(raw_params) ⇒ Object

URL variant of #process_with_remittance.



81
82
83
# File 'lib/veryfi/api/check.rb', line 81

def process_with_remittance_url(raw_params)
  request.post(REMITTANCE_ENDPOINT, raw_params.transform_keys(&:to_sym))
end

#update(id, params) ⇒ Veryfi::Resource

Update writable fields on a processed check.

Examples:

client.check.update(check_id, notes: "needs review")

Parameters:

  • id (Integer)
  • params (Hash)

Returns:



104
105
106
# File 'lib/veryfi/api/check.rb', line 104

def update(id, params)
  request.put("#{ENDPOINT}#{id}/", params)
end