XeroAPI / xero-php-oauth2

Xero PHP SDK for oAuth 2 generated from Xero API OpenAPI Spec 3.0
MIT License
92 stars 66 forks source link

Accounting API getInvoices fails when where condition results in no rows returned #356

Open atf2 opened 3 months ago

atf2 commented 3 months ago

SDK you're using (please complete the following information):

Describe the bug A call to getInvoices throws an exception if the where condition results in no rows being returned. This was not the case in V5

e.g. $accountingApi = new \XeroAPI\XeroPHP\Api\AccountingApi( new \GuzzleHttp\Client(), $xeroApiAuthorisation->getConfig() ); $r = $accountingApi()->getInvoices( $xeroApiAuthorisation->tenantId(), null, "1 = 2", null, null, null, null, null, 1 ); $arr = $r->getInvoices();

Results

To Reproduce Run the following code:

$accountingApi = new \XeroAPI\XeroPHP\Api\AccountingApi( new \GuzzleHttp\Client(), $xeroApiAuthorisation->getConfig() ); $r = $accountingApi()->getInvoices( $xeroApiAuthorisation->tenantId(), null, "1 = 2", null, null, null, null, null, 1 ); $arr = $r->getInvoices();

An exception is throw in the call from the second line "$r = ..." with the message "( ! ) InvalidArgumentException: invalid length for $invoices when calling GetInvoicesResponse., number of items must be greater than or equal to 1. in {edited}\vendor\xeroapi\xero-php-oauth2\lib\Models\Accounting\GetInvoicesResponse.php on line 399"

The trace ends: XeroAPI\XeroPHP\Api\AccountingApi->getInvoicesWithHttpInfo( $xero_tenant_id = 'cd1a68e0-d5aa-479d-a86c-1a81ded061ff', $if_modified_since = NULL, $where = '1 = 2', $order = NULL, $ids = NULL, $invoice_numbers = NULL, $contact_ids = NULL, $statuses = NULL, $page = 1, $include_archived = NULL, $created_by_my_app = NULL, $unitdp = NULL, $summary_only = FALSE, $page_size = NULL ) | ...\AccountingApi.php:34315 XeroAPI\XeroPHP\AccountingObjectSerializer::deserialize( $data = '{\r\n "Id": "6426bbb0-b18d-4afa-a595-c58b310660c9",\r\n "Status": "OK",\r\n "ProviderName": "Oatlands Test",\r\n "DateTimeUTC": "\/Date(1720196319232)\/",\r\n "Invoices": []\r\n}', $class = '\XeroAPI\XeroPHP\Models\Accounting\GetInvoicesResponse', $httpHeaders = [] ) | ...\AccountingApi.php:34376 XeroAPI\XeroPHP\Models\Accounting\GetInvoicesResponse->setInvoices( $invoices = [] ) | ...\AccountingObjectSerializer.php:358

Expected behavior $r is set to a getInvoicesResponse object containing an empty array of invoices.

Additional context This works as expected in V4.0.0 and v5.0.0

github-actions[bot] commented 3 months ago

PETOSS-463

github-actions[bot] commented 3 months ago

Thanks for raising an issue, a ticket has been created to track your request