Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
atf2 opened this issue Jul 5, 2024 · 2 comments

Comments

@atf2
Copy link

atf2 commented Jul 5, 2024

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

  • Version 6.0.0

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

Copy link

github-actions bot commented Jul 5, 2024

PETOSS-463

Copy link

github-actions bot commented Jul 5, 2024

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

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

No branches or pull requests

1 participant