|
@ -3,6 +3,7 @@ |
|
|
namespace Darksparrow\DeegraphInteractions\Core; |
|
|
namespace Darksparrow\DeegraphInteractions\Core; |
|
|
|
|
|
|
|
|
use Darksparrow\DeegraphInteractions\DataStructures\ServerInfo; |
|
|
use Darksparrow\DeegraphInteractions\DataStructures\ServerInfo; |
|
|
|
|
|
use Darksparrow\DeegraphInteractions\Enumerators\HTTPMethod; |
|
|
use Exception; |
|
|
use Exception; |
|
|
|
|
|
|
|
|
final class DeegraphServer |
|
|
final class DeegraphServer |
|
@ -38,6 +39,7 @@ final class DeegraphServer |
|
|
* Runs an API request against the Deegraph Server, and returns back information about the Deegraph Server. |
|
|
* Runs an API request against the Deegraph Server, and returns back information about the Deegraph Server. |
|
|
* |
|
|
* |
|
|
* @return ServerInfo |
|
|
* @return ServerInfo |
|
|
|
|
|
* @throws Exception |
|
|
*/ |
|
|
*/ |
|
|
public function ServerInfo(): ServerInfo |
|
|
public function ServerInfo(): ServerInfo |
|
|
{ |
|
|
{ |
|
@ -45,7 +47,7 @@ final class DeegraphServer |
|
|
return ServerInfo::FromAPIResponse(response: $response); |
|
|
return ServerInfo::FromAPIResponse(response: $response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function RunRawRequest(string $endpoint, string $method = "GET", string $body = null): string |
|
|
public function RunRawRequest(string $endpoint, HTTPMethod $method = HTTPMethod::GET, string $body = null): string |
|
|
{ |
|
|
{ |
|
|
$ch = curl_init("https://{$this->ServerDomain}:{$this->Port}{$endpoint}"); |
|
|
$ch = curl_init("https://{$this->ServerDomain}:{$this->Port}{$endpoint}"); |
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
|
@ -55,7 +57,7 @@ final class DeegraphServer |
|
|
]); |
|
|
]); |
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
|
|
|
|
|
|
|
if($method == "POST") |
|
|
if($method == HTTPMethod::POST) |
|
|
{ |
|
|
{ |
|
|
curl_setopt($ch, CURLOPT_POST, 1); |
|
|
curl_setopt($ch, CURLOPT_POST, 1); |
|
|
} |
|
|
} |
|
@ -65,7 +67,7 @@ final class DeegraphServer |
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if($method == "POST" || $method == "PUT") |
|
|
if($method == HTTPMethod::POST || $method == HTTPMethod::PUT) |
|
|
{ |
|
|
{ |
|
|
if($body != null) |
|
|
if($body != null) |
|
|
{ |
|
|
{ |
|
|