Add split and classify document support to Client#19
Conversation
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.
There was a problem hiding this comment.
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
ClientSplitDocumentsTestandClientClassifyDocumentsTest - 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/ |
There was a problem hiding this comment.
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.'
| * 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/ |
| /** | ||
| * 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 |
There was a problem hiding this comment.
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'.
| * @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 |
| $file = fopen($file_path, 'r'); | ||
| $file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8'); |
There was a problem hiding this comment.
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.
| $file = fopen($file_path, 'r'); | ||
| $file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8'); |
There was a problem hiding this comment.
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.
| $file = fopen($file_path, 'r'); | ||
| $file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8'); |
There was a problem hiding this comment.
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.
| $file = fopen($file_path, 'r'); | ||
| $file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8'); |
There was a problem hiding this comment.
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.
| $file = fopen($file_path, 'r'); | ||
| $file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8'); |
There was a problem hiding this comment.
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.
| $file = fopen($file_path, 'r'); | ||
| $file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8'); |
There was a problem hiding this comment.
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.
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.