User
class User extends Base (View source)
User management client for the rokka.io service.
Constants
| DEFAULT_API_BASE_URL |
|
| protected DEFAULT_API_VERSION |
|
| protected API_KEY_HEADER |
|
| protected API_AUTHORIZATION_HEADER |
|
| protected API_VERSION_HEADER |
|
| USERS_RESOURCE |
|
| USER_RESOURCE |
|
| USER_API_KEYS_RESOURCE |
|
| ORGANIZATION_RESOURCE |
|
| ORGANIZATION_OPTION_PROTECT_DYNAMIC_STACK |
|
Properties
| protected ClientInterface | $client | Client to access Rokka. |
from Base |
| protected string|null | $defaultOrganization | Default organization. |
from Base |
Methods
Constructor.
Get the API Token Payload (unverified).
Returns for how many seconds a token is valid for.
Call the API rokka endpoint.
Return the organization or the default if empty.
Gets the payload of an API JWT Token (not validated against the signature).
Create a user.
Get current userID.
Add an Api Key to the current user.
Gets info about the currently used Api Key.
Deletes an Api Key for the current user.
Get current user.
Gets a new API JWT Token with an $apiKey.
Create an organization.
Create an organization.
Set all options for an organization at once.
Get the monthly billing statistics for an organization.
Return an organization.
Create a membership.
Create a user and membership associated to this organization.
Get the membership metadata for the given organization and user's ID.
Deletes a membership for the given organization and user's ID.
List the membership metadata for the given organization.
Details
__construct(ClientInterface $client, string|null $defaultOrganization, string|null $apiKey, string|null $apiToken = null)
Constructor.
in
Base at line 71
void
setCredentials(string|null $key)
Set the credentials.
in
Base at line 83
void
setToken(string|null $token)
Set the API Token.
in
Base at line 93
string|null
getToken()
Get the API Token.
in
Base at line 103
array|null
getTokenPayload(string|null $token = null)
Get the API Token Payload (unverified).
in
Base at line 124
int
getTokenIsValidFor(string|null $token = null)
Returns for how many seconds a token is valid for.
Doesn't check for other validity (like ip restrictions)
Returns -1 if there's no token
in
Base at line 150
protected ResponseInterface
call(string $method, string $path, array $options = [], bool $needsCredentials = true, array $credentials = [])
Call the API rokka endpoint.
in
Base at line 176
protected string
getOrganizationName(string|null $organization = null)
Return the organization or the default if empty.
in
Base at line 189
protected array|null
getUnvalidatedPayload(string $token)
Gets the payload of an API JWT Token (not validated against the signature).
User
createUser(string $email)
Create a user.
string
getCurrentUserId()
Get current userID.
UserApiKey
addUserApiKey(string|null $comment = null)
Add an Api Key to the current user.
UserApiKey
getCurrentUserApiKey()
Gets info about the currently used Api Key.
bool
deleteUserApiKey(string $id)
Deletes an Api Key for the current user.
User
getCurrentUser()
Get current user.
UserApiToken
getNewToken(string|null $apiKey = null, array $parameters = [])
Gets a new API JWT Token with an $apiKey.
Organization
createOrganization(string $name, string $billingMail, string $displayName = '')
Create an organization.
Organization
setOrganizationOption(string $organization, string $name, string $value)
Create an organization.
Organization
setOrganizationOptions(string $organization, array $options)
Set all options for an organization at once.
Unlike {\Rokka\Client\User::setOrganizationOption()}, this replaces the entire options bag in a single request. Pass an associative array of option name → value pairs.
array<string, mixed>
getBilling(string $organization, DateTime|null $from = null, DateTime|null $to = null)
Get the monthly billing statistics for an organization.
Requires admin rights on the organization. Optional from and to dates accept any
string format that \DateTime parses; the server rounds them to the first/last day
of the month. The response shape is intentionally free-form — Rokka may add fields
over time — so it's returned as a decoded associative array.
Organization
getOrganization(string $organization = '')
Return an organization.
Membership
createMembership(string $userId, string|array $roles = [Membership::ROLE_READ], string $organization = '')
Create a membership.
Membership
createUserAndMembership(string|array $roles = [Membership::ROLE_READ], string $organization = '')
Create a user and membership associated to this organization.
Membership
getMembership(string $userId, string $organization = '')
Get the membership metadata for the given organization and user's ID.
bool
deleteMembership(string $userId, string $organization = '')
Deletes a membership for the given organization and user's ID.
Membership[]
listMemberships(string $organization = '')
List the membership metadata for the given organization.