Created fetch() method to handle fetchall requests
This commit is contained in:
parent
f5bec882f5
commit
c1641270c0
32
src/API.php
32
src/API.php
@ -118,18 +118,8 @@ final class API
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of our clients
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return Generic
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getCustomers(array $parameters=[]): Generic
|
||||
private function fetch(string $path,array $parameters,string $key): Base
|
||||
{
|
||||
Log::debug(sprintf('%s:Get a list of customers',static::LOGKEY));
|
||||
$key = 'customers';
|
||||
|
||||
$fetchall = FALSE;
|
||||
if (Arr::get($parameters,'fetchall')) {
|
||||
Arr::forget($parameters,['fetchall']);
|
||||
@ -139,9 +129,9 @@ final class API
|
||||
$fetchall = TRUE;
|
||||
}
|
||||
|
||||
$o = new Generic($this->execute($key,$parameters),$key);
|
||||
$o = new Generic($this->execute($path,$parameters),$key);
|
||||
|
||||
return $fetchall ? $this->fetchall($o,$key,$parameters) : $o;
|
||||
return $fetchall ? $this->fetchall($o,$path,$parameters) : $o;
|
||||
}
|
||||
|
||||
private function fetchall(Base $o,string $path,array $parameters): Base
|
||||
@ -155,6 +145,20 @@ final class API
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of our clients
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return Generic
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getCustomers(array $parameters=[]): Generic
|
||||
{
|
||||
Log::debug(sprintf('%s:Get a list of customers',static::LOGKEY));
|
||||
|
||||
return $this->fetch('customers',$parameters,'customers');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of our clients domains
|
||||
*
|
||||
@ -166,7 +170,7 @@ final class API
|
||||
{
|
||||
Log::debug(sprintf('%s:Get a list of domains',static::LOGKEY));
|
||||
|
||||
return new Generic($this->execute('domains',$parameters),'domains');
|
||||
return $this->fetch('domains',$parameters,'domains');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user