Currently, there is no built-in way to add per_page or other parameters to some functions within the library. This limitation might be problematic for users who need finer control over their API requests.
Temporary Workaround:
As a temporary solution, you can create a new API class that extends the abstract API class. In this new class, you can define the functions with the desired parameters. After that, you can instantiate this new class with your client and use it as needed.
Request:
It would be beneficial to add support for parameters like per_page in the official API functions in a future release of the library.
//usage
$dropletS = new Droplet($this->client);//$this->client->droplet();
$droplets = $dropletS->getAll("staging",['per_page'=>200]);
<?php
namespace App\DigitalOceanPHP\Api ;
use DigitalOceanV2\Api\AbstractApi;
use DigitalOceanV2\Entity\Droplet as DropletEntity;
class Droplet extends AbstractApi{
/**
* @param string|null $tag
*
* @throws ExceptionInterface
*
* @return DropletEntity[]
*/
public function getAll(?string $tag = null,array $params=[])
{
if($tag){
$params['tag_name'] = $tag;
}
$droplets = $this->get('droplets', $params);
return \array_map(function ($droplet) {
return new DropletEntity($droplet);
}, $droplets->droplets);
}
}
Issue:
Currently, there is no built-in way to add per_page or other parameters to some functions within the library. This limitation might be problematic for users who need finer control over their API requests.
Temporary Workaround:
As a temporary solution, you can create a new API class that extends the abstract API class. In this new class, you can define the functions with the desired parameters. After that, you can instantiate this new class with your client and use it as needed.
Request:
It would be beneficial to add support for parameters like per_page in the official API functions in a future release of the library.