Group management methods

This commit is contained in:
2025-04-24 15:38:16 +02:00
parent e6e1e980ea
commit a580c4a42c
2 changed files with 19 additions and 2 deletions

View File

@ -15,7 +15,8 @@
} }
], ],
"require": { "require": {
"psr/http-client": "^1.0" "psr/http-client": "^1.0",
"psr/http-message": "^2.0"
}, },
"require-dev": { "require-dev": {
"guzzlehttp/guzzle": "^7.9", "guzzlehttp/guzzle": "^7.9",

View File

@ -162,10 +162,23 @@ class SlotDbClient
return $data; return $data;
} }
public function updateGroup(string $groupId, array $props): array public function createGroup(string $groupId, array $props): array
{
$res = $this->post("/groups", $props);
$data = json_decode($res->getBody(), true);
if (is_array($data) && isset($data['error'])) {
throw new GroupException($data['error']);
}
return $data;
}
public function updateGroup(string $groupId, array $props): bool
{ {
$res = $this->post("/group/{$groupId}", $props); $res = $this->post("/group/{$groupId}", $props);
$data = json_decode($res->getBody(), true); $data = json_decode($res->getBody(), true);
if (is_array($data) && isset($data['error'])) {
throw new GroupException($data['error']);
}
return $data; return $data;
} }
@ -196,3 +209,6 @@ class SlotDbClient
} }
} }
class GroupException extends \RuntimeException
{}