Compare commits
2 Commits
50934994a6
...
f0de6b3702
Author | SHA1 | Date |
---|---|---|
Cerys Lewis | f0de6b3702 | 5 months ago |
Cerys Lewis | 72c714dc56 | 5 months ago |
5 changed files with 80 additions and 20 deletions
@ -0,0 +1,37 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilders; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderQuery; |
||||
|
use Darksparrow\DeegraphInteractions\Attributes\QueryBuilderRequiredField; |
||||
|
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphEqualityOperator; |
||||
|
use Darksparrow\DeegraphInteractions\Enumerators\DeegraphPermissionType; |
||||
|
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderRequiredFieldIsNotSetException; |
||||
|
use Darksparrow\DeegraphInteractions\Interfaces\QueryBuilderInterface; |
||||
|
use Darksparrow\DeegraphInteractions\QueryInstance\DeleteQuery; |
||||
|
use Darksparrow\DeegraphInteractions\QueryInstance\GrantQuery; |
||||
|
|
||||
|
#[QueryBuilderQuery] |
||||
|
final class DeleteQueryBuilder implements QueryBuilderInterface |
||||
|
{ |
||||
|
#[QueryBuilderRequiredField] |
||||
|
protected string $RelativePath; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* @throws QueryBuilderRequiredFieldIsNotSetException |
||||
|
*/ |
||||
|
public function Build(): DeleteQuery |
||||
|
{ |
||||
|
$builder = "DELETE "; |
||||
|
if($this->RelativePath != "") $builder .= $this->RelativePath; |
||||
|
|
||||
|
return new DeleteQuery(queryString: $builder); |
||||
|
} |
||||
|
|
||||
|
public function RelativePath(string $relativePath): DeleteQueryBuilder |
||||
|
{ |
||||
|
$this->RelativePath = $relativePath; |
||||
|
return $this; |
||||
|
} |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryInstance; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Core\DeegraphServer; |
||||
|
use Darksparrow\DeegraphInteractions\Interfaces\QueryInstanceInterface; |
||||
|
use Darksparrow\DeegraphInteractions\QueryResponse\DeleteQueryResponse; |
||||
|
use Darksparrow\DeegraphInteractions\QueryResponse\GrantQueryResponse; |
||||
|
use Darksparrow\DeegraphInteractions\Superclasses\QueryInstanceSuperclass; |
||||
|
|
||||
|
final class DeleteQuery extends QueryInstanceSuperclass implements QueryInstanceInterface |
||||
|
{ |
||||
|
public function RunQuery(DeegraphServer $deegraphServer): DeleteQueryResponse |
||||
|
{ |
||||
|
$response = $deegraphServer->RunRawRequest( |
||||
|
endpoint: "/api/v1/@query", |
||||
|
method: "POST", |
||||
|
body: $this->QueryString, |
||||
|
); |
||||
|
return new DeleteQueryResponse(response: $response); |
||||
|
} |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\QueryResponse; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Interfaces\QueryResponseInterface; |
||||
|
|
||||
|
final class DeleteQueryResponse implements QueryResponseInterface |
||||
|
{ |
||||
|
public function __construct(string $response) |
||||
|
{ |
||||
|
$response = json_decode($response, true); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue