|
|
@ -4,22 +4,40 @@ namespace Darksparrow\DeegraphInteractions\DataStructures; |
|
|
|
|
|
|
|
class QueryResponseWrapper |
|
|
|
{ |
|
|
|
public array $Nodes; |
|
|
|
|
|
|
|
public array $Rows; |
|
|
|
public string $RowFormat; |
|
|
|
|
|
|
|
public static function FromAPIResponse(string $response): QueryResponseWrapper |
|
|
|
{ |
|
|
|
$temp = json_decode($response, true); |
|
|
|
$response = json_decode($response, true); |
|
|
|
|
|
|
|
echo "\n\n\n"; |
|
|
|
var_dump($response); |
|
|
|
echo "\n\n\n"; |
|
|
|
|
|
|
|
|
|
|
|
$builder = new QueryResponseWrapper(); |
|
|
|
|
|
|
|
foreach($temp["@rows"] as $row) $builder->Rows[] = QueryResponseRow::FromArray(array: $row); |
|
|
|
$builder->RowFormat = $temp["@row_format"]; |
|
|
|
if(array_key_exists(key: "@rows", array: $response)) |
|
|
|
{ |
|
|
|
$builder->Rows = []; |
|
|
|
foreach($response["@rows"] as $row) |
|
|
|
$builder->Rows[] = QueryResponseRow::FromArray(array: $row); |
|
|
|
$builder->RowFormat = $response["@row_format"]; |
|
|
|
} |
|
|
|
if(array_key_exists(key: "@nodes", array: $response)) |
|
|
|
{ |
|
|
|
$builder->Nodes = []; |
|
|
|
foreach($response["@nodes"] as $row) |
|
|
|
$builder->Nodes = $response["@nodes"]; |
|
|
|
} |
|
|
|
|
|
|
|
return $builder; |
|
|
|
} |
|
|
|
|
|
|
|
public function Flatten(): array |
|
|
|
public function FlattenRows(): array |
|
|
|
{ |
|
|
|
$builder = []; |
|
|
|
|
|
|
|