XeroAPI / xero-php-oauth2

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

getContact and getContacts both returning "Contacts" array #145

Closed robroypt closed 4 years ago

robroypt commented 4 years ago

SDK

Describe the bug getContact() and getContacts() both return an array of type "Contacts".

To Reproduce

//Hard-coding ID in "Demo Company (AU)" using XeroAPI/xero-php-oauth2
$xeroContactId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";

$xeroContactV1 = $xeroAccountingAPI->getContact($xeroTenantId, $xeroContactId);

$xeroContactV2 = $xeroAccountingAPI->getContacts($xeroTenantId, $xeroContactId);

//both return an object of type XeroAPI\XeroPHP\Models\Accounting\Contacts

//to get a single XeroAPI\XeroPHP\Models\Accounting\Contact object you need to do one of the following
$xeroContactV3 = $xeroAccountingAPI->getContact($xeroTenantId, $xeroContactId)[0];
$xeroContactV4 = $xeroAccountingAPI->getContacts($xeroTenantId, $xeroContactId)[0];

Expected behavior getContact() should return a single Contact

SidneyAllen commented 4 years ago

@robroypt - Xero's API returns an array of Contacts when performing a GET and passing in a Contact Id.

https://developer.xero.com/documentation/api/contacts#GET

The SDK is behaving as expected in this scenario.