public function execute($command, array $parameters = [])
{
if (!isset(self::$commands[$command])) {
throw new InvalidArgumentException("The command '{$command}' is not currently supported");
}
$command = self::$commands[$command];
if ($command['token']) {
$parameters = array_merge($parameters, ['token' => $this->token]);
}
if (isset($command['format'])) {
foreach ($command['format'] as $format) {
if (isset($parameters[$format])) {
$parameters[$format] = self::format($parameters[$format]);
}
}
}
$headers = [];
if (isset($command['headers'])) {
$headers = $command['headers'];
}
$url = self::$baseUrl . $command['endpoint'];
if (isset($command['post']) && $command['post']) {
return $this->interactor->post($url, [], $parameters, $headers);
}
return $this->interactor->get($url, $parameters, $headers);
}