zendesk / zendesk_api_client_php

Official Zendesk API v2 client library for PHP
336 stars 259 forks source link

Get full list of users. #386

Closed ghost closed 6 years ago

ghost commented 6 years ago

If you call the following function it returns maximum 100 users:

$users = $client->users()->findAll();

I need to get all users in the system. I tried extending the endpoints:

public function findAll(array $params = [])
    {
        if (isset($params['organization_id'])) {
            $this->endpoint = "organizations/{$params['organization_id']}/users.json";
        } elseif (isset($params['group_id'])) {
            $this->endpoint = 'groups/' . $params['group_id'] . '/users.json';
        } else {
            $this->endpoint = 'users.json';
        }

        return $this->traitFindAll($params);
    }

To:

public function findAll(array $params = [])
    {
        if (isset($params['organization_id'])) {
            $this->endpoint = "organizations/{$params['organization_id']}/users.json";
        } elseif (isset($params['group_id'])) {
            $this->endpoint = 'groups/' . $params['group_id'] . '/users.json';
        } elseif (isset($params['page_id'])) {
            $this->endpoint = 'users.json?page=' . $params['page_id'];
        } else {
            $this->endpoint = 'users.json';
        }

        return $this->traitFindAll($params);
    }

And passing in the page_id but no luck. Any thoughts on how you can get all pages of users? I am happy to do it in a loop and collect 100 at a time I just need to make sure I get everyone in the system.

ghost commented 6 years ago

Pagination, derrr