Group management methods
This commit is contained in:
@ -15,7 +15,8 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"psr/http-client": "^1.0"
|
||||
"psr/http-client": "^1.0",
|
||||
"psr/http-message": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"guzzlehttp/guzzle": "^7.9",
|
||||
|
@ -162,10 +162,23 @@ class SlotDbClient
|
||||
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);
|
||||
$data = json_decode($res->getBody(), true);
|
||||
if (is_array($data) && isset($data['error'])) {
|
||||
throw new GroupException($data['error']);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -196,3 +209,6 @@ class SlotDbClient
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class GroupException extends \RuntimeException
|
||||
{}
|
Reference in New Issue
Block a user