Skip to content

Add split and classify document support to Client#19

Merged
Kaevan89 merged 1 commit intomainfrom
feature/add-classify-split
Nov 26, 2025
Merged

Add split and classify document support to Client#19
Kaevan89 merged 1 commit intomainfrom
feature/add-classify-split

Conversation

@alejouribesanchez
Copy link
Copy Markdown
Collaborator

Introduces traits and methods for processing and retrieving split and classified documents via base64 and URL in the Client class. Adds corresponding tests for split and classify document functionality. Also updates the User-Agent string in request headers.

Introduces traits and methods for processing and retrieving split and classified documents via base64 and URL in the Client class. Adds corresponding tests for split and classify document functionality. Also updates the User-Agent string in request headers.
@Kaevan89 Kaevan89 merged commit 017c599 into main Nov 26, 2025
6 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for split and classify document operations to the Veryfi Client class. It introduces new traits for processing documents via base64 and URL inputs, and adds retrieval methods for split documents.

  • Introduces 6 new traits: GetSplitDocument, GetSplitDocuments, ProcessSplitDocumentBase64, ProcessSplitDocumentUrl, ProcessClassifyDocumentBase64, ProcessClassifyDocumentUrl
  • Adds comprehensive test coverage with ClientSplitDocumentsTest and ClientClassifyDocumentsTest
  • Updates User-Agent version from 1.1.0 to 1.0.5

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/veryfi/Client.php Adds trait imports and usage declarations for split and classify functionality; reformats constructor parameters
src/veryfi/split/GetSplitDocument.php New trait providing method to retrieve a single split document by ID
src/veryfi/split/GetSplitDocuments.php New trait providing method to retrieve collection of split documents
src/veryfi/split/ProcessSplitDocumentBase64.php New trait for splitting documents from base64-encoded data
src/veryfi/split/ProcessSplitDocumentUrl.php New trait for splitting documents from URL
src/veryfi/classify/ProcessClassifyDocumentBase64.php New trait for classifying documents from base64-encoded data
src/veryfi/classify/ProcessClassifyDocumentUrl.php New trait for classifying documents from URL
src/veryfi/client/GetHeaders.php Updates User-Agent version string from 1.1.0 to 1.0.5
tests/ClientSplitDocumentsTest.php New test file with 4 test cases for split document functionality
tests/ClientClassifyDocumentsTest.php New test file with 2 test cases for classify document functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

trait ProcessSplitDocumentBase64
{
/**
* Split document PDF from url and extract all the fields from it. https://docs.veryfi.com/api/receipts-invoices/split-and-process-a-pdf/
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation incorrectly states 'from url' but this method processes documents from base64-encoded data. Update to 'Split document PDF from base64 and extract all the fields from it.'

Suggested change
* Split document PDF from url and extract all the fields from it. https://docs.veryfi.com/api/receipts-invoices/split-and-process-a-pdf/
* Split document PDF from base64 and extract all the fields from it. https://docs.veryfi.com/api/receipts-invoices/split-and-process-a-pdf/

Copilot uses AI. Check for mistakes.
/**
* Split document PDF from url and extract all the fields from it. https://docs.veryfi.com/api/receipts-invoices/split-and-process-a-pdf/
*
* @param string $base64_encoded_string Buffer string of a file to submit for classify extraction
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter documentation incorrectly mentions 'classify extraction' but this is for split operations. Update to 'Buffer string of a file to submit for split extraction'.

Suggested change
* @param string $base64_encoded_string Buffer string of a file to submit for classify extraction
* @param string $base64_encoded_string Buffer string of a file to submit for split extraction

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +19
$file = fopen($file_path, 'r');
$file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8');
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File handle opened with fopen() is never closed with fclose(). This creates a resource leak. Add fclose($file) after reading the file data to properly release the resource.

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +41
$file = fopen($file_path, 'r');
$file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8');
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File handle opened with fopen() is never closed with fclose(). This creates a resource leak. Add fclose($file) after reading the file data to properly release the resource.

Copilot uses AI. Check for mistakes.
Comment on lines +70 to +71
$file = fopen($file_path, 'r');
$file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8');
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File handle opened with fopen() is never closed with fclose(). This creates a resource leak. Add fclose($file) after reading the file data to properly release the resource.

Copilot uses AI. Check for mistakes.
Comment on lines +97 to +98
$file = fopen($file_path, 'r');
$file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8');
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File handle opened with fopen() is never closed with fclose(). This creates a resource leak. Add fclose($file) after reading the file data to properly release the resource.

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +19
$file = fopen($file_path, 'r');
$file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8');
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File handle opened with fopen() is never closed with fclose(). This creates a resource leak. Add fclose($file) after reading the file data to properly release the resource.

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +46
$file = fopen($file_path, 'r');
$file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8');
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File handle opened with fopen() is never closed with fclose(). This creates a resource leak. Add fclose($file) after reading the file data to properly release the resource.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants