Cerys
4 weeks ago
7 changed files with 78 additions and 4 deletions
@ -0,0 +1,26 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\DirectoryQuery; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Core\DeegraphServer; |
||||
|
|
||||
|
final class DirectoryQuery |
||||
|
{ |
||||
|
protected string $QueryString; |
||||
|
|
||||
|
public function __construct(string $queryString) |
||||
|
{ |
||||
|
$this->QueryString = $queryString; |
||||
|
} |
||||
|
|
||||
|
public function RunQuery(DeegraphServer $server): DirectoryQueryResponse |
||||
|
{ |
||||
|
$response = $server->RunRawRequest( |
||||
|
endpoint: "/api/v1/@query", |
||||
|
method: "POST", |
||||
|
body: $this->QueryString |
||||
|
); |
||||
|
$temp = json_decode($response, true); |
||||
|
return new DirectoryQueryResponse($temp); |
||||
|
} |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\DirectoryQuery; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\PermissionsQuery\PermissionQuery; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
||||
|
|
||||
|
#[QueryBuilderQuery] |
||||
|
final class DirectoryQueryBuilder |
||||
|
{ |
||||
|
|
||||
|
use QueryBuilderTrait; |
||||
|
|
||||
|
#[QueryBuilderRequiredField] |
||||
|
protected string $RelativePath = ""; |
||||
|
|
||||
|
|
||||
|
public function RelativePath(string $relativePath): DirectoryQueryBuilder |
||||
|
{ |
||||
|
self::ValidateDeegraphPath(target: $relativePath); |
||||
|
$this->RelativePath = $relativePath; |
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function Build(): DirectoryQuery |
||||
|
{ |
||||
|
self::ValidateValues(target: $this); |
||||
|
$builder = "DIRECTORY " . $this->RelativePath; |
||||
|
return new DirectoryQuery(queryString: $builder); |
||||
|
} |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\DirectoryQuery; |
||||
|
|
||||
|
class DirectoryQueryResponse |
||||
|
{ |
||||
|
public array $Map; |
||||
|
|
||||
|
public function __construct(array $deegraphResponse) |
||||
|
{ |
||||
|
$this->Map = $deegraphResponse["@map"]; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue