public function fetchAll(ApiInterface $api, $method, array $parameters = [])
    {
        // get the perPage from the api
        $perPage = $api->getPerPage();

        // set parameters per_page to max to minimize number of requests
        $api->setPerPage(100);

        try {
            $result = $this->fetch($api, $method, $parameters)['values'];

            while ($this->hasNext()) {
                $next = $this->fetchNext();
                $result = array_merge($result, $next['values']);
            }
        } finally {
            // restore the perPage
            $api->setPerPage($perPage);
        }

        return $result;
    }