Implemented mechanism to add/remove roles from API keys

This commit is contained in:
Alejandro Celaya
2021-01-06 10:59:02 +01:00
parent 01b3c504f8
commit 041f231ff2
4 changed files with 82 additions and 5 deletions

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Rest\ApiKey\Model;
use Shlinkio\Shlink\Rest\ApiKey\Role;
final class RoleDefinition
{
private string $roleName;
private array $meta;
private function __construct(string $roleName, array $meta)
{
$this->roleName = $roleName;
$this->meta = $meta;
}
public static function forAuthoredShortUrls(): self
{
return new self(Role::AUTHORED_SHORT_URLS, []);
}
public static function forDomain(string $domainId): self
{
return new self(Role::DOMAIN_SPECIFIC, ['domain_id' => $domainId]);
}
public function roleName(): string
{
return $this->roleName;
}
public function meta(): array
{
return $this->meta;
}
}