calcinai / xero-php

A php library for the Xero API, with a cleaner OAuth interface and ORM-like abstraction.
MIT License
357 stars 256 forks source link

Does Filtering work on Qutoes? #902

Closed jointine-john closed 7 months ago

jointine-john commented 7 months ago

I'm trying to pull only Quotes that have been accepted.

$xeroQuotes = $xero->load(Quote::class) ->where('Status', Quote::QUOTE_STATUS_ACCEPTED) ->execute();

But all quotes are returned regardless of status

calcinai commented 7 months ago

Hi @jointine-john - do you know if this works in the API previewer, or do the docs suggest filtering should work in this way?

jointine-john commented 7 months ago

The Xero docs say you should be able to filter on status. My test account has only has quotes with a status of SENT. I've tried the API Explorer and if I filter on ACCEPTED, no results are returned.

Using the example I provided, all quotes are returned.

calcinai commented 7 months ago

So annoyingly, some endpoints and parameters in the Xero API are expected within a where parameter, and others directly in the uri. I suspect if you swap ->where for ->setParameter() it'll work.

jointine-john commented 7 months ago

Thanks, tried that this morning and it works great

$xeroQuotes = $xero->load(Quote::class)
            ->setParameter('DateFrom', '2023-11-03')
            ->setParameter('Status', Quote::QUOTE_STATUS_ACCEPTED)
            ->execute();