Weble / ZohoBooksApi

40 stars 39 forks source link

Filters is not working #45

Closed ProgrammerZ closed 4 years ago

ProgrammerZ commented 4 years ago

Everything is working, except the filters, they are ignored, including pages.

$res = $zohoBooks->invoices->getList(['status' => 'unpaid', 'page' => 3, 'per_page' => 200]);
$res = $zohoBooks->contacts->getList(['email' => 'name@domain.com']);
ProgrammerZ commented 4 years ago

Since I'm absolutely new to Zoho Books, not sure what was before in API, but it seems I have found the issue. The parameters for List need to go to query.

protected function getHttpClientOptions(array $data = [], array $rawData = []): array
{
    $json = ['JSONString' => json_encode($data)];
    $query = array_merge(['organization_id' => $this->getOrganizationId()], $rawData);
    return array_merge([
        'query'       => $query,
        'form_params' => $json,
        'headers'     => ['Authorization' => 'Zoho-oauthtoken ' . $this->oAuthClient->getAccessToken()]
    ]);
}
Skullbock commented 4 years ago

Hi @ProgrammerZ can you state which version of the SDK are you on?

Thanks!

ProgrammerZ commented 4 years ago

@Skullbock 4.0.0

Skullbock commented 4 years ago

Gonna test this tomorrow and let You know 👌🏻

Skullbock commented 4 years ago

Hi @ProgrammerZ i've release 4.1.0 that fixes this issue, alongside a test that prevents this from happening again.

https://github.com/Weble/ZohoBooksApi/commit/208b7d520b83dda030a41da86881cf592323f226

Please take note also of how the filters work in zoho books: https://www.zoho.com/books/api/v3/#Contacts_List_Contacts

By default, it does an exact match ;)

ProgrammerZ commented 4 years ago

@Skullbock Thank you for your hard work, really appreciate that!

Skullbock commented 4 years ago

Feel free to pr any change you see fit to this library 👌🏻