abstract class Base (View source)

Base Client class.

Constants

DEFAULT_API_BASE_URL

protected DEFAULT_API_VERSION

protected API_KEY_HEADER

protected API_AUTHORIZATION_HEADER

protected API_VERSION_HEADER

Properties

protected ClientInterface $client

Client to access Rokka.

protected string|null $defaultOrganization

Default organization.

Methods

__construct(ClientInterface $client, string|null $defaultOrganization)

Constructor.

void
setCredentials(string|null $key)

Set the credentials.

void
setToken(string|null $token)

Set the API Token.

string|null
getToken()

Get the API Token.

array|null
getTokenPayload(string|null $token = null)

Get the API Token Payload (unverified).

int
getTokenIsValidFor(string|null $token = null)

Returns for how many seconds a token is valid for.

ResponseInterface
call(string $method, string $path, array $options = [], bool $needsCredentials = true, array $credentials = [])

Call the API rokka endpoint.

string
getOrganizationName(string|null $organization = null)

Return the organization or the default if empty.

array|null
getUnvalidatedPayload(string $token)

Gets the payload of an API JWT Token (not validated against the signature).

Details

__construct(ClientInterface $client, string|null $defaultOrganization)

Constructor.

Parameters

ClientInterface $client

Client instance

string|null $defaultOrganization

void setCredentials(string|null $key)

Set the credentials.

Parameters

string|null $key

API key

Return Value

void

void setToken(string|null $token)

Since: 1.17.0

Set the API Token.

Parameters

string|null $token

API token

Return Value

void

string|null getToken()

Since: 1.17.0

Get the API Token.

Return Value

string|null

array|null getTokenPayload(string|null $token = null)

Since: 1.17.0

Get the API Token Payload (unverified).

Parameters

string|null $token

Return Value

array|null

int getTokenIsValidFor(string|null $token = null)

Since: 1.17.0

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

Parameters

string|null $token

Return Value

int

protected ResponseInterface call(string $method, string $path, array $options = [], bool $needsCredentials = true, array $credentials = [])

Call the API rokka endpoint.

Parameters

string $method

HTTP method to use

string $path

Path on the API

array $options

Request options

bool $needsCredentials

True if credentials are needed

array $credentials

Credentials to be used, useful for overwriting api-key

Return Value

ResponseInterface

Exceptions

GuzzleException

protected string getOrganizationName(string|null $organization = null)

Return the organization or the default if empty.

Parameters

string|null $organization Organization

Return Value

string

Exceptions

RuntimeException

protected array|null getUnvalidatedPayload(string $token)

Gets the payload of an API JWT Token (not validated against the signature).

Parameters

string $token

Return Value

array|null