XeroAPI/xero-php-oauth2

How can I get the status of an API request?

Px-Factor opened this issue · 2 comments

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

  • Version [e.g. 2.8.1]

Not a bug, but neither a feature request...

In version 1 of the API it was possible to get the status of a request to the API by doing (for example, when creating a new contact):

$xeroOAuth = new XeroOAuth($signatures);
$xeroOAuth->request('POST', $xXeroOAuth->url('Contacts', 'core'), array(), $xml, 'json');
if ($response->Status == 'OK') {
    // Do something
} else {
    // Do something else
}

What would be the equivalent of this in version 2? Example code:

$contact = new \XeroAPI\XeroPHP\Models\Accounting\Contact;
$contact->setName('Contact name');

$contacts = new \XeroAPI\XeroPHP\Models\Accounting\Contacts;

$accountingApi = new \XeroAPI\XeroPHP\Api\AccountingApi(
    new \GuzzleHttp\Client(),
    $config
);
$apiResult = $accountingApi->createContacts('', $contacts);

How do I get the status from $apiResult? I have tried $apiResult->Status, $apiResult->getStatus() and $apiResult->GetStatus() and neither of them works...

Thanks!

Thanks SerKnight! That did the trick.