Skip to content

Commit

Permalink
Add missing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
alejouribesanchez committed Dec 4, 2024
1 parent 241ce90 commit 6647c6e
Show file tree
Hide file tree
Showing 24 changed files with 235 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/veryfi/documents/lineitems/AddLineItem.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
namespace veryfi\documents\lineitems;
use veryfi\LineItem;

trait AddLineItem
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace veryfi;
namespace veryfi\documents\lineitems;


use Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace veryfi;
namespace veryfi\documents\lineitems;


use Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace veryfi;
namespace veryfi\documents\lineitems;

/**
* Model of Shared Line Item.
Expand Down
1 change: 0 additions & 1 deletion src/veryfi/documents/lineitems/UpdateLineItem.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
namespace veryfi\documents\lineitems;
use veryfi\LineItemUpdate;

trait UpdateLineItem
{
Expand Down
2 changes: 1 addition & 1 deletion src/veryfi/w2s/DeleteW2.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait DeleteW2
* @param array $kwargs Additional request parameters
* @return string Data extracted from the document.
*/
public function delete_w2_document(string $document_id, array $kwargs = []): string
public function delete_w2(string $document_id, array $kwargs = []): string
{
$endpoint_name = "/w2s/{$document_id}/";
$request_arguments = array_merge(['id' => $document_id], $kwargs);
Expand Down
2 changes: 1 addition & 1 deletion src/veryfi/w2s/GetW2.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait GetW2
* @param array $kwargs Additional request parameters
* @return string Data extracted from the document.
*/
public function get_w2_document(string $document_id, array $kwargs = []): string
public function get_w2(string $document_id, array $kwargs = []): string
{
$endpoint_name = "/w2s/{$document_id}/";
$request_arguments = array_merge(['id' => $document_id], $kwargs);
Expand Down
2 changes: 1 addition & 1 deletion src/veryfi/w2s/GetW2s.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait GetW2s
* @param array $kwargs Additional request parameters
* @return string An array of JSON with all W2 documents.
*/
public function get_w2_documents(int $page = null, array $kwargs = []): string
public function get_w2(int $page = null, array $kwargs = []): string
{
$endpoint_name = '/w2s/';
$request_arguments = array_merge([
Expand Down
2 changes: 1 addition & 1 deletion src/veryfi/w2s/ProcessW2.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trait ProcessW2
* @param array $kwargs Additional request parameters.
* @return string Data extracted from the document.
*/
public function process_w2_document(string $file_path,
public function process_w2(string $file_path,
bool $auto_delete = false,
int $max_pages_to_process = 1,
array $kwargs = array()): string
Expand Down
2 changes: 1 addition & 1 deletion src/veryfi/w2s/ProcessW2Base64.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trait ProcessW2Base64
* @param array $kwargs Additional request parameters.
* @return string Data extracted from the document.
*/
public function process_w2_document_base64(string $file_path,
public function process_w2_base64(string $file_path,
bool $auto_delete = false,
int $max_pages_to_process = 1,
array $kwargs = array()): string
Expand Down
2 changes: 1 addition & 1 deletion src/veryfi/w2s/ProcessW2Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trait ProcessW2Url
* @param array $kwargs Additional request parameters
* @return string Data extracted from the document
*/
public function process_w2_document_from_url(string $file_name, string $file_url, array $file_urls = null, bool $auto_delete = false, int $max_pages_to_process = 1, array $kwargs = []): string
public function process_w2_from_url(string $file_name, string $file_url, array $file_urls = null, bool $auto_delete = false, int $max_pages_to_process = 1, array $kwargs = []): string
{
$endpoint_name = "/w2s/";
$request_arguments = array_merge([
Expand Down
13 changes: 12 additions & 1 deletion src/veryfi/w8bene/DeleteW8BENE.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,16 @@
namespace veryfi\w8bene;
trait DeleteW8BENE
{

/**
* Delete a W-8BEN-E from Veryfi. https://docs.veryfi.com/api/w-8ben-e/delete-a-w-8-ben-e/
* @param string $document_id The ID of the document you'd like to retrieve.
* @param array $kwargs Additional request parameters
* @return string Data extracted from the document.
*/
public function delete_w8bene(string $document_id, array $kwargs = []): string
{
$endpoint_name = "/w-8ben-e/{$document_id}/";
$request_arguments = array_merge(['id' => $document_id], $kwargs);
return $this->request('DELETE', $endpoint_name, $request_arguments);
}
}
14 changes: 13 additions & 1 deletion src/veryfi/w8bene/GetW8BENE.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,17 @@
namespace veryfi\w8bene;
trait GetW8BENE
{

/**
* Get a W-8BEN-E document. https://docs.veryfi.com/api/w-8ben-e/get-a-w-8-ben-e/
*
* @param string $document_id The ID of the document you'd like to retrieve.
* @param array $kwargs Additional request parameters
* @return string Data extracted from the document.
*/
public function get_w8bene(string $document_id, array $kwargs = []): string
{
$endpoint_name = "/w-8ben-e/{$document_id}/";
$request_arguments = array_merge(['id' => $document_id], $kwargs);
return $this->request('GET', $endpoint_name, $request_arguments);
}
}
12 changes: 11 additions & 1 deletion src/veryfi/w8bene/GetW8BENEs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,15 @@
namespace veryfi\w8bene;
trait GetW8BENEs
{

/**
* Get all W-8BEN-E documents.https://docs.veryfi.com/api/w-8ben-e/get-w-8-ben-es/
*
* @param array $kwargs Additional request parameters
* @return string An array of JSON with all W2 documents.
*/
public function get_w8benes(array $kwargs = []): string
{
$endpoint_name = '/w-8ben-e/';
return $this->request('GET', $endpoint_name, $kwargs);
}
}
26 changes: 25 additions & 1 deletion src/veryfi/w8bene/ProcessW8BENE.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,29 @@
namespace veryfi\w8bene;
trait ProcessW8BENE
{

/**
* Process a W-8BEN-E document. https://docs.veryfi.com/api/w-8ben-e/process-a-w-8-ben-e/
* @param string $file_path Path on disk to a file to submit for data extraction.
* @param bool $bounding_boxes Return bounding box and bounding region for extracted fields.
* @param bool $confidence_details Return the score and OCR score fields in the document response.
* @param array $kwargs Additional request parameters.
* @return string Data extracted from the document.
*/
public function process_w8bene(string $file_path,
bool $bounding_boxes = false,
bool $confidence_details = false,
array $kwargs = array()): string
{
$endpoint_name = '/w-8ben-e/';
$file_name = pathinfo($file_path, PATHINFO_BASENAME);
$file_type = mime_content_type($file_path);
$request_arguments = array(
'file_name' => $file_name,
'file' => new CURLFile($file_path, $file_type, $file_name),
'bounding_boxes' => $bounding_boxes,
'confidence_details' => $confidence_details
);
$request_arguments = array_replace($request_arguments, $kwargs);
return $this->request('POST', $endpoint_name, $request_arguments, true);
}
}
29 changes: 28 additions & 1 deletion src/veryfi/w8bene/ProcessW8BENEBase64.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,32 @@
namespace veryfi\w8bene;
trait ProcessW8BENEBase64
{

/**
* Process a W-8BEN-E document. https://docs.veryfi.com/api/w-8ben-e/process-a-w-8-ben-e/
* @param string $file_path Path on disk to a file to submit for data extraction.
* @param bool $bounding_boxes Return bounding box and bounding region for extracted fields.
* @param bool $confidence_details Return the score and OCR score fields in the document response.
* @param array $kwargs Additional request parameters.
* @return string Data extracted from the document.
*/
public function process_w8bene_base64(string $file_path,
bool $bounding_boxes = false,
bool $confidence_details = false,
array $kwargs = array()): string
{
$endpoint_name = '/w-8ben-e/';
$file_name = pathinfo($file_path, PATHINFO_BASENAME);
$file = fopen($file_path, 'rb');
$file_data = base64_encode(fread($file, filesize($file_path)));
$file_type = mime_content_type($file_path);
$base64_with_hint = "data:$file_type;base64," . $file_data;
$request_arguments = array(
'file_name' => $file_name,
'file_data' => $base64_with_hint,
'bounding_boxes' => $bounding_boxes,
'confidence_details' => $confidence_details
);
$request_arguments = array_replace($request_arguments, $kwargs);
return $this->request('POST', $endpoint_name, $request_arguments);
}
}
18 changes: 18 additions & 0 deletions src/veryfi/w8bene/ProcessW8BENEUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,23 @@
namespace veryfi\w8bene;
trait ProcessW8BENEUrl
{
/**
* Process a W-8BEN-E document. https://docs.veryfi.com/api/w-8ben-e/process-a-w-8-ben-e/
* @param string $file_url Publicly accessible URL to a file
* @param boolean $bounding_boxes Return bounding box and bounding region for extracted fields
* @param boolean $confidence_details Return the score and OCR score fields in the document response
* @param array $kwargs Additional request parameters
* @return string Data extracted from the document
*/
public function process_w8bene_from_url(string $file_url, bool $bounding_boxes = false, bool $confidence_details = false, array $kwargs = []): string
{
$endpoint_name = "/w-8ben-e/";
$request_arguments = array_merge([
'file_url' => $file_url,
'bounding_boxes' => $bounding_boxes,
'confidence_details' => $confidence_details
], $kwargs);

return $this->request("POST", $endpoint_name, $request_arguments);
}
}
14 changes: 13 additions & 1 deletion src/veryfi/w9s/DeleteW9.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,17 @@
namespace veryfi\w9s;
trait DeleteW9
{

/**
* DELETE a W9 document. https://docs.veryfi.com/api/w9s/delete-a-w-9/
*
* @param string $document_id The ID of the document you'd like to retrieve.
* @param array $kwargs Additional request parameters
* @return string Data extracted from the document.
*/
public function delete_w9(string $document_id, array $kwargs = []): string
{
$endpoint_name = "/w9s/{$document_id}/";
$request_arguments = array_merge(['id' => $document_id], $kwargs);
return $this->request('DELETE', $endpoint_name, $request_arguments);
}
}
14 changes: 13 additions & 1 deletion src/veryfi/w9s/GetW9.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,17 @@
namespace veryfi\w9s;
trait GetW9
{

/**
* Get a W9 document. https://docs.veryfi.com/api/w9s/get-a-w-9/
*
* @param string $document_id The ID of the document you'd like to retrieve.
* @param array $kwargs Additional request parameters
* @return string Data extracted from the document.
*/
public function get_w9(string $document_id, array $kwargs = []): string
{
$endpoint_name = "/w9s/{$document_id}/";
$request_arguments = array_merge(['id' => $document_id], $kwargs);
return $this->request('GET', $endpoint_name, $request_arguments);
}
}
12 changes: 11 additions & 1 deletion src/veryfi/w9s/GetW9s.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,15 @@
namespace veryfi\w9s;
trait GetW9s
{

/**
* Get all W9 documents. https://docs.veryfi.com/api/w9s/get-w-9-s/
*
* @param array $kwargs Additional request parameters
* @return string An array of JSON with all W2 documents.
*/
public function get_w9s(array $kwargs = []): string
{
$endpoint_name = '/w9s/';
return $this->request('GET', $endpoint_name, $kwargs);
}
}
29 changes: 28 additions & 1 deletion src/veryfi/w9s/ProcessW9.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
<?php
namespace veryfi\w9s;
use CURLFile;

trait ProcessW9
{

/**
* Process a W9 document from a file path and extract all fields from it. https://docs.veryfi.com/api/w9s/process-a-w-9/
*
* @param string $file_path Path on disk to a file to submit for data extraction.
* @param bool $auto_delete Delete this document from Veryfi after data has been extracted.
* @param int $max_pages_to_process The number of pages to process for the document.
* @param array $kwargs Additional request parameters.
* @return string Data extracted from the document.
*/
public function process_w9(string $file_path,
bool $auto_delete = false,
int $max_pages_to_process = 1,
array $kwargs = array()): string
{
$endpoint_name = '/w9s/';
$file_name = pathinfo($file_path, PATHINFO_BASENAME);
$file_type = mime_content_type($file_path);
$request_arguments = array(
'file_name' => $file_name,
'file' => new CURLFile($file_path, $file_type, $file_name),
'auto_delete' => $auto_delete,
'max_pages_to_process' => $max_pages_to_process
);
$request_arguments = array_replace($request_arguments, $kwargs);
return $this->request('POST', $endpoint_name, $request_arguments);
}
}
30 changes: 29 additions & 1 deletion src/veryfi/w9s/ProcessW9Base64.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,33 @@
namespace veryfi\w9s;
trait ProcessW9Base64
{

/**
* Process a W9 document from a file path and extract all fields from it. https://docs.veryfi.com/api/w9s/process-a-w-9/
*
* @param string $file_path Path on disk to a file to submit for data extraction.
* @param bool $auto_delete Delete this document from Veryfi after data has been extracted.
* @param int $max_pages_to_process The number of pages to process for the document.
* @param array $kwargs Additional request parameters.
* @return string Data extracted from the document.
*/
public function process_w9_base64(string $file_path,
bool $auto_delete = false,
int $max_pages_to_process = 1,
array $kwargs = array()): string
{
$endpoint_name = '/w9s/';
$file_name = pathinfo($file_path, PATHINFO_BASENAME);
$file = fopen($file_path, 'rb');
$file_data = base64_encode(fread($file, filesize($file_path)));
$file_type = mime_content_type($file_path);
$base64_with_hint = "data:$file_type;base64," . $file_data;
$request_arguments = array(
'file_name' => $file_name,
'file_data' => $base64_with_hint,
'auto_delete' => $auto_delete,
'max_pages_to_process' => $max_pages_to_process
);
$request_arguments = array_replace($request_arguments, $kwargs);
return $this->request('POST', $endpoint_name, $request_arguments);
}
}
23 changes: 23 additions & 0 deletions src/veryfi/w9s/ProcessW9Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,28 @@
namespace veryfi\w9s;
trait ProcessW9Url
{
/**
* Process a W9 document from a URL and extract all fields from it. https://docs.veryfi.com/api/w9s/process-a-w-9/
*
* @param string $file_name The file name including the extension
* @param string $file_url Publicly accessible URL to a file
* @param array|null $file_urls List of publicly accessible URLs to multiple files
* @param boolean $auto_delete Delete this document from Veryfi after data has been extracted
* @param int $max_pages_to_process The number of pages to process for the document
* @param array $kwargs Additional request parameters
* @return string Data extracted from the document
*/
public function process_w9_from_url(string $file_name, string $file_url, array $file_urls = null, bool $auto_delete = false, int $max_pages_to_process = 1, array $kwargs = []): string
{
$endpoint_name = "/w9s/";
$request_arguments = array_merge([
'file_name' => $file_name,
'auto_delete' => $auto_delete,
'file_url' => $file_url,
'file_urls' => $file_urls,
'max_pages_to_process' => $max_pages_to_process
], $kwargs);

return $this->request("POST", $endpoint_name, $request_arguments);
}
}
Loading

0 comments on commit 6647c6e

Please sign in to comment.