Client
in package
Veryfi-sdk for php
Tags
Table of Contents
- CATEGORIES = ['Advertising & Marketing', 'Automotive', 'Bank Charges & Fees', 'Legal & Professional Services', 'Insurance', 'Meals & Entertainment', 'Office Supplies & Software', 'Taxes & Licenses', 'Travel', 'Rent & Lease', 'Repairs & Maintenance', 'Payroll', 'Utilities', 'Job Supplies', 'Grocery']
- Default categories to process document.
- $api_key : string
- Api key provided by Veryfi.
- $api_timeout : int
- Api timeout to call Veryfi API by default 120.
- $api_version : string
- Api version to use Veryfi by default 'v7'
- $base_url : string
- Base url of Veryfi by default 'https://api.veryfi.com/api/'.
- $client_id : string
- Client id provided by Veryfi.
- $client_secret : string
- Client secret provided by Veryfi.
- $username : string
- Username provided by Veryfi.
- $extend_url : string
- Base URL to Veryfi API.
- $headers : array<string|int, mixed>
- Associative array of headers.
- __construct() : mixed
- Constructor of Veryfi client
- add_line_item() : string
- Add a new line item on an existing document
- delete_document() : string
- Delete Document from Veryfi.
- delete_line_item() : string
- Delete an existing line item on an existing document.
- delete_line_items() : string
- Delete all line items on an existing document.
- get_document() : string
- Retrieve document by ID.
- get_documents() : string
- Get list of documents.
- get_line_item() : string
- Retrieve a line item for existing document by ID.
- get_line_items() : string
- Retrieve all line items for a document.
- process_document() : string
- Process a document and extract all the fields from it.
- process_document_url() : string
- Process Document from url and extract all the fields from it.
- update_document() : string
- Update data for a previously processed document, including almost any field like `vendor`, `date`, `notes` and etc.
- update_line_item() : string
- Update an existing line item on an existing document.
- verify_signature() : bool
- Verify the signature from a webhook.
- exec_curl() : string
- generate_signature() : string
- Generate unique signature for payload params.
- get_headers() : array<string|int, mixed>
- Prepares the headers needed for a request.
- get_url() : string
- Get API Base URL with API Version.
- request() : string
- Submit the HTTP request.
Constants
CATEGORIES
Default categories to process document.
public
array<string|int, mixed>
CATEGORIES
= ['Advertising & Marketing', 'Automotive', 'Bank Charges & Fees', 'Legal & Professional Services', 'Insurance', 'Meals & Entertainment', 'Office Supplies & Software', 'Taxes & Licenses', 'Travel', 'Rent & Lease', 'Repairs & Maintenance', 'Payroll', 'Utilities', 'Job Supplies', 'Grocery']
static.
Properties
$api_key
Api key provided by Veryfi.
public
string
$api_key
$api_timeout
Api timeout to call Veryfi API by default 120.
public
int
$api_timeout
$api_version
Api version to use Veryfi by default 'v7'
public
string
$api_version
$base_url
Base url of Veryfi by default 'https://api.veryfi.com/api/'.
public
string
$base_url
$client_id
Client id provided by Veryfi.
public
string
$client_id
$client_secret
Client secret provided by Veryfi.
public
string
$client_secret
$username
Username provided by Veryfi.
public
string
$username
$extend_url
Base URL to Veryfi API.
private
string
$extend_url
$headers
Associative array of headers.
private
array<string|int, mixed>
$headers
Methods
__construct()
Constructor of Veryfi client
public
__construct(string $client_id, string $client_secret, string $username, string $api_key[, string $base_url = 'https://api.veryfi.com/api/' ][, string $api_version = 'v8' ][, int $api_timeout = 120 ]) : mixed
Parameters
- $client_id : string
-
Client id provided by Veryfi.
- $client_secret : string
-
Client secret provided by Veryfi.
- $username : string
-
Username provided by Veryfi.
- $api_key : string
-
Api key provided by Veryfi.
- $base_url : string = 'https://api.veryfi.com/api/'
-
Base url of Veryfi by default 'https://api.veryfi.com/api/',
- $api_version : string = 'v8'
-
Api version to use Veryfi, currently 'v8
- $api_timeout : int = 120
-
Api timeout for call Veryfi api, by default 120
Return values
mixed —add_line_item()
Add a new line item on an existing document
public
add_line_item(int $document_id, AddLineItem $payload) : string
Parameters
- $document_id : int
-
ID of the document you'd like to update
- $payload : AddLineItem
-
line item object to add
Return values
string —Added line item data
delete_document()
Delete Document from Veryfi.
public
delete_document(int $document_id) : string
Parameters
- $document_id : int
-
ID of the document you'd like to delete.
Return values
string —A JSON response.
delete_line_item()
Delete an existing line item on an existing document.
public
delete_line_item(int $document_id, int $line_item_id) : string
Parameters
- $document_id : int
-
ID of the document you'd like to delete
- $line_item_id : int
-
ID of the line item you'd like to delete
Return values
string —A JSON response.
delete_line_items()
Delete all line items on an existing document.
public
delete_line_items(int $document_id) : string
Parameters
- $document_id : int
-
ID of the document you'd like to delete
Return values
string —A JSON response.
get_document()
Retrieve document by ID.
public
get_document(int $document_id) : string
Parameters
- $document_id : int
-
ID of the document you'd like to retrieve.
Return values
string —A Json of data extracted from the Document.
get_documents()
Get list of documents.
public
get_documents() : string
Return values
string —A JSON with list of processes documents and metadata.
get_line_item()
Retrieve a line item for existing document by ID.
public
get_line_item(int $document_id, int $line_item_id) : string
Parameters
- $document_id : int
-
ID of the document you'd like to retrieve
- $line_item_id : int
-
ID of the line item you'd like to retrieve
Return values
string —Line item extracted from the document as string
get_line_items()
Retrieve all line items for a document.
public
get_line_items(int $document_id) : string
Parameters
- $document_id : int
-
ID of the document you'd like to retrieve
Return values
string —List of line items extracted from the document as string
process_document()
Process a document and extract all the fields from it.
public
process_document(string $file_path[, array<string|int, mixed>|array<string|int, string> $categories = self::CATEGORIES ][, bool $delete_after_processing = false ][, array<string|int, mixed> $additional_request_parameters = array() ]) : string
Parameters
- $file_path : string
-
Path on disk to a file to submit for data extraction.
- $categories : array<string|int, mixed>|array<string|int, string> = self::CATEGORIES
-
Array of categories Veryfi can use to categorize the document.
- $delete_after_processing : bool = false
-
Delete this document from Veryfi after data has been extracted.
- $additional_request_parameters : array<string|int, mixed> = array()
-
Additional request parameters.
Return values
string —Data extracted from the document.
process_document_url()
Process Document from url and extract all the fields from it.
public
process_document_url([string|null $file_url = null ][, array<string|int, mixed>|null $file_urls = null ][, array<string|int, mixed>|null $categories = null ][, bool $delete_after_processing = false ], int $boost_mode[, string|null $external_id = null ][, int|null $max_pages_to_process = null ][, array<string|int, mixed> $additional_request_parameters = array() ]) : string
Parameters
- $file_url : string|null = null
-
Required if file_urls isn't specified. Publicly accessible URL to a file, e.g. "https://cdn.example.com/receipt.jpg".
- $file_urls : array<string|int, mixed>|null = null
-
Required if file_url isn't specifies. List of publicly accessible URLs to multiple files, e.g. ['https://cdn.example.com/receipt1.jpg', 'https://cdn.example.com/receipt2.jpg']
- $categories : array<string|int, mixed>|null = null
-
Array of categories to use when categorizing the document
- $delete_after_processing : bool = false
-
Delete this/these document(s) from Veryfi after data has been extracted
- $boost_mode : int
-
Flag that tells Veryfi whether boost mode should be enabled. When set to 1, Veryfi will skip data enrichment steps, but will process the document faster. Default value for this flag is 0.
- $external_id : string|null = null
-
Optional custom document identifier. Use this if you would like to assign your own ID to documents.
- $max_pages_to_process : int|null = null
-
When sending a long document to Veryfi for processing, this parameter controls how many pages of the document will be read and processed, starting from page 1.
- $additional_request_parameters : array<string|int, mixed> = array()
-
Additional request parameters.
Return values
string —Data extracted from the document.
update_document()
Update data for a previously processed document, including almost any field like `vendor`, `date`, `notes` and etc.
public
update_document(int $document_id, array<string|int, mixed> $fields_to_update) : string
$parameters = array('notes' => 'see me');
veryfi_client->update_document(id, $parameters);
Parameters
- $document_id : int
-
ID of the document you'd like to update.
- $fields_to_update : array<string|int, mixed>
-
Fields to update.
Return values
string —A document json with updated fields, if fields are writable. Otherwise a document with unchanged fields.
update_line_item()
Update an existing line item on an existing document.
public
update_line_item(int $document_id, int $line_item_id, UpdateLineItem $payload) : string
Parameters
- $document_id : int
-
ID of the document you'd like to update
- $line_item_id : int
-
ID of the line item you'd like to update
- $payload : UpdateLineItem
-
line item object to update
Return values
string —Line item data with updated fields, if fields are writable. Otherwise line item data with unchanged fields.
verify_signature()
Verify the signature from a webhook.
public
static verify_signature(array<string|int, mixed> $payload_params, string $client_secret, string $client_signature) : bool
Parameters
- $payload_params : array<string|int, mixed>
-
the payload params returned by the webhook.
- $client_secret : string
-
your client secret.
- $client_signature : string
-
x-veryfi-signature header.
Return values
bool —returns true if the signature is valid else false.
exec_curl()
protected
exec_curl(mixed $curl) : string
Parameters
- $curl : mixed
Return values
string —generate_signature()
Generate unique signature for payload params.
private
generate_signature(array<string|int, mixed> $payload_params, string $timestamp) : string
Parameters
- $payload_params : array<string|int, mixed>
-
Associative array params to be sent to API request.
- $timestamp : string
-
Unix string timestamp.
Return values
string —Unique signature generated using the client_secret and the payload.
get_headers()
Prepares the headers needed for a request.
private
get_headers() : array<string|int, mixed>
Return values
array<string|int, mixed> —Associative array with headers.
get_url()
Get API Base URL with API Version.
private
get_url() : string
Return values
string —Base URL to Veryfi API.
request()
Submit the HTTP request.
private
request(string $http_verb, string $endpoint_name, array<string|int, mixed> $request_arguments) : string
Parameters
- $http_verb : string
-
HTTP method.
- $endpoint_name : string
-
Endpoint name such as 'documents', 'users', etc.
- $request_arguments : array<string|int, mixed>
-
Associative array payload to send to Veryfi.
Return values
string —A JSON of the response data.