diff --git a/src/Core/DeegraphServer.php b/src/Core/DeegraphServer.php index 5ba9623..cd83b10 100644 --- a/src/Core/DeegraphServer.php +++ b/src/Core/DeegraphServer.php @@ -5,6 +5,7 @@ namespace Darksparrow\DeegraphInteractions\Core; use Auxilium\Exceptions\DatabaseConnectionException; use Auxilium\Exceptions\DeegraphException; use Darksparrow\DeegraphInteractions\DataStructures\DeegraphNodeDetails; +use Darksparrow\DeegraphInteractions\DataStructures\NewNodeDetails; use Darksparrow\DeegraphInteractions\DataStructures\ServerInfo; use Darksparrow\DeegraphInteractions\DataStructures\UUID; use Exception; @@ -174,4 +175,27 @@ class DeegraphServer ); return new ServerInfo(response: $response); } + + + public function CreatedNewNode( + UUID $actorID, + string $dataURL, + ?string $schema = null, + ?UUID $creator = null + ): NewNodeDetails + { + $body = [ + "@data" => $dataURL, + ]; + if($schema != null) + $body["@schema"] = $schema; + + $response = $this->RunRawRequest( + actorID: $actorID, + endpoint: "/api/v1/@new", + method: "PUT", + body: json_encode($body), + ); + return new NewNodeDetails(serverResponse: $response); + } } diff --git a/src/DataStructures/NewNodeDetails.php b/src/DataStructures/NewNodeDetails.php new file mode 100644 index 0000000..81d6378 --- /dev/null +++ b/src/DataStructures/NewNodeDetails.php @@ -0,0 +1,12 @@ +ID = $serverResponse["@id"]; + } +}