Skip to content

Commit

Permalink
feat: add suport for the new directadmin api
Browse files Browse the repository at this point in the history
  • Loading branch information
ju5t committed Jun 3, 2024
1 parent 1605c4d commit 4630499
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/DirectAdmin.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

/** @noinspection PhpUnhandledExceptionInspection */

namespace Sensson\DirectAdmin;

use Illuminate\Http\Client\ConnectionException;
Expand Down Expand Up @@ -52,12 +54,16 @@ public function get(string $command, array $params = []): Collection
*/
public function call(string $command, array $params = [], Method $method = Method::POST): Collection
{
if (str_starts_with(strtolower($command), 'cmd_api_')) {
$command = strtoupper($command);
}

try {
$response = Http::acceptJson()
->withBasicAuth($this->username, $this->password)
->withOptions($this->getHttpOptions())
->withQueryParameters($this->getQueryParams())
->{$method->verb()}($this->server.'/'.strtoupper($command), $params);
->{$method->verb()}($this->server.'/'.$command, $params);
} catch (ConnectionException $e) {
throw ConnectionFailed::create($e->getMessage());
}
Expand Down

0 comments on commit 4630499

Please sign in to comment.