class User extends Base (View source)

User management client for the rokka.io service.

Constants

DEFAULT_API_BASE_URL

DEFAULT_API_VERSION

API_KEY_HEADER

API_VERSION_HEADER

USERS_RESOURCE

USER_RESOURCE

ORGANIZATION_RESOURCE

Properties

protected ClientInterface $client

Client to access Rokka.

from  Base
protected string|null $defaultOrganization

Default organization.

from  Base

Methods

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

Constructor.

setCredentials(string $key)

Set the credentials.

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

Call the API rokka endpoint.

from  Base
string
getOrganizationName(string|null $organization = null)

Return the organization or the default if empty.

from  Base
createUser(string $email)

Create a user.

string
getCurrentUserId()

Get current user.

createOrganization(string $name, string $billingMail, string $displayName = '')

Create an organization.

getOrganization(string $organization = '')

Return an organization.

createMembership(string $userId, string|array $roles = [Membership::ROLE_READ], string $organization = '')

Create a membership.

createUserAndMembership(string|array $roles = [Membership::ROLE_READ], string $organization = '')

Create a user and membership associated to this organization.

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.

listMemberships(string $organization = '')

List the membership metadata for the given organization.

Details

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

Constructor.

Parameters

ClientInterface $client

Client instance

string|null $defaultOrganization
string|null $apiKey

API key

setCredentials(string $key)

Set the credentials.

Parameters

string $key

API key

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

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

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

User createUser(string $email)

Create a user.

Parameters

string $email Email

Return Value

User

Exceptions

GuzzleException
RuntimeException

string getCurrentUserId()

Since: 1.7.0

Get current user.

Return Value

string

Exceptions

GuzzleException
RuntimeException

Organization createOrganization(string $name, string $billingMail, string $displayName = '')

Create an organization.

Parameters

string $name

Organization name

string $billingMail

Billing mail

string $displayName

Optional display name

Return Value

Organization

Exceptions

GuzzleException
RuntimeException

Organization getOrganization(string $organization = '')

Since: 1.7.0

Return an organization.

Parameters

string $organization

Organization name

Return Value

Organization

Exceptions

GuzzleException
RuntimeException

Membership createMembership(string $userId, string|array $roles = [Membership::ROLE_READ], string $organization = '')

Since: 1.7.0

Create a membership.

Parameters

string $userId

User ID

string|array $roles

Role to add

string $organization Organization

Return Value

Membership

Exceptions

GuzzleException
RuntimeException

Membership createUserAndMembership(string|array $roles = [Membership::ROLE_READ], string $organization = '')

Since: 1.7.0

Create a user and membership associated to this organization.

Parameters

string|array $roles

Role to add

string $organization Organization

Return Value

Membership

Exceptions

GuzzleException
RuntimeException

Membership getMembership(string $userId, string $organization = '')

Since: 1.7.0

Get the membership metadata for the given organization and user's ID.

Parameters

string $userId

User ID

string $organization Organization

Return Value

Membership

Exceptions

GuzzleException
RuntimeException

bool deleteMembership(string $userId, string $organization = '')

Since: 1.7.0

Deletes a membership for the given organization and user's ID.

Parameters

string $userId

User ID

string $organization Organization

Return Value

bool

Exceptions

GuzzleException
RuntimeException

Membership[] listMemberships(string $organization = '')

Since: 1.7.0

List the membership metadata for the given organization.

Parameters

string $organization Organization

Return Value

Membership[]

Exceptions

GuzzleException
RuntimeException