Reference·PHP SDK · BIMworksPHP

AccountApi

PHP SDK: the Account operations, 10 methods, each with its parameters, result and a complete example.

PHP SDK · BIMworks\Api · class · 10 methods

The signed-in account: registration, password, sessions and settings

Construct it with the client of the connect step: new AccountApi(config: $client). Each method is one operation of the API part, where it runs on its page.

MethodOperationDescription
changePasswordChangePasswordChange the password
getSettingsGetSettingsRead the account settings
listReferenceValuesListReferenceValuesThe values of the settings form
logoutLogoutRecord a sign-out
registerRegisterRegister an account
requestPasswordResetRequestPasswordResetSend a password reset e-mail
requestValidationEmailRequestValidationEmailSend a new validation e-mail
saveSettingsSaveSettingsChange the account settings
signOutOtherSessionsSignOutOtherSessionsSign out every other session
validateEmailAddressValidateEmailAddressConfirm an e-mail address and set the password

changePassword#

PHP#
public function changePassword(ChangePasswordRequest $change_password_request): AuthResult

Change the password. Changes the password of the signed-in account and signs out every other session; this one continues on the session answered here. An account session only: an API token is refused. current_password is needed when the account has a password, code when it has two-factor authentication. An account without a password (one that signs in with e-mail codes) gets its first one, which needs a session signed in within the last 10 minutes.

OperationChangePassword · POST /openapi/account/ChangePassword
Scopeaccount:write

Parameters#

NameTypeDescription
change_password_requestChangePasswordRequestrequiredThe request: its properties are those of the model, its JSON that of ChangePassword's request body.

Returns#

AuthResult — The new session

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\ChangePasswordRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "current_password": "",
  "password": "",
  "code": 0,
  "response_format": "auth"
}
JSON, ChangePasswordRequest::class);

// 3. The call
$result = (new AccountApi(config: $client))->changePassword($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;

getSettings#

PHP#
public function getSettings(): AccountSettings

Read the account settings. The settings of the account behind the credential: name, country, language, time zone and the web app preferences. With an API token, those of the account that created it.

OperationGetSettings · POST /openapi/account/GetSettings
Scopeaccount:read

Parameters#

None: the operation takes no request.

Returns#

AccountSettings — The settings

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());

// 2. The request
// (GetSettings takes no request)

// 3. The call
$result = (new AccountApi(config: $client))->getSettings();

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;

listReferenceValues#

PHP#
public function listReferenceValues(ListReferenceValuesRequest $list_reference_values_request): ReferenceValue[]

The values of the settings form. The countries (ISO 3166 codes), languages (ISO 639-1 codes) or time zones (tz identifiers) that the settings take, with a name to show. Names are in English.

OperationListReferenceValues · POST /openapi/account/ListReferenceValues
Scopeany login

Parameters#

NameTypeDescription
list_reference_values_requestListReferenceValuesRequestrequiredThe request: its properties are those of the model, its JSON that of ListReferenceValues's request body.

Returns#

ReferenceValue[] — The values

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\ListReferenceValuesRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "kind": "countries"
}
JSON, ListReferenceValuesRequest::class);

// 3. The call
$result = (new AccountApi(config: $client))->listReferenceValues($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;

logout#

PHP#
public function logout(): void

Record a sign-out. Records that the session signed out. It revokes nothing: the bearer token stays valid until it expires. To end sessions, use SignOutOtherSessions or ChangePassword.

OperationLogout · POST /openapi/account/Logout
Scopeany login

Parameters#

None: the operation takes no request.

Returns#

Nothing: the operation answers without a body (Recorded).

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());

// 2. The request
// (Logout takes no request)

// 3. The call
(new AccountApi(config: $client))->logout();

// 4. The result
// (Logout answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;

register#

PHP#
public function register(RegisterRequest $register_request): void

Register an account. Creates an account for an e-mail address and sends it the validation e-mail; the account is usable once the address is confirmed with ValidateEmailAddress. Refused (REGISTRATION_NOT_ALLOWED) when the instance does not allow self-registration (security.account_self_registration) or the address asked too often; an address that already has an account is refused with EMAIL_ADDRESS_ALREADY_REGISTERED.

OperationRegister · POST /openapi/account/Register
Scopenone: callable before logging in

Parameters#

NameTypeDescription
register_requestRegisterRequestrequiredThe request: its properties are those of the model, its JSON that of Register's request body.

Returns#

Nothing: the operation answers without a body (The validation e-mail is sent).

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Configuration;
use BIMworks\Model\RegisterRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works (Register needs no login)
$client = (new Configuration())->setHost('https://bim.works/openapi');

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "username": "",
  "preferred_language": ""
}
JSON, RegisterRequest::class);

// 3. The call
(new AccountApi(config: $client))->register($request);

// 4. The result
// (Register answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;

requestPasswordReset#

PHP#
public function requestPasswordReset(RequestPasswordResetRequest $request_password_reset_request): void

Send a password reset e-mail. Sends a link to reset the password. The reset itself is completed in the BIM.works web app. It answers the same whether or not the account exists.

OperationRequestPasswordReset · POST /openapi/account/RequestPasswordReset
Scopenone: callable before logging in

Parameters#

NameTypeDescription
request_password_reset_requestRequestPasswordResetRequestrequiredThe request: its properties are those of the model, its JSON that of RequestPasswordReset's request body.

Returns#

Nothing: the operation answers without a body (Done (whether or not an e-mail was sent)).

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Configuration;
use BIMworks\Model\RequestPasswordResetRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works (RequestPasswordReset needs no login)
$client = (new Configuration())->setHost('https://bim.works/openapi');

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "username": ""
}
JSON, RequestPasswordResetRequest::class);

// 3. The call
(new AccountApi(config: $client))->requestPasswordReset($request);

// 4. The result
// (RequestPasswordReset answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;

requestValidationEmail#

PHP#
public function requestValidationEmail(RequestValidationEmailRequest $request_validation_email_request): void

Send a new validation e-mail. A new validation link for an address that registered but did not confirm yet. It answers the same whether or not such an account exists.

OperationRequestValidationEmail · POST /openapi/account/RequestValidationEmail
Scopenone: callable before logging in

Parameters#

NameTypeDescription
request_validation_email_requestRequestValidationEmailRequestrequiredThe request: its properties are those of the model, its JSON that of RequestValidationEmail's request body.

Returns#

Nothing: the operation answers without a body (Done (whether or not an e-mail was sent)).

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Configuration;
use BIMworks\Model\RequestValidationEmailRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works (RequestValidationEmail needs no login)
$client = (new Configuration())->setHost('https://bim.works/openapi');

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "username": ""
}
JSON, RequestValidationEmailRequest::class);

// 3. The call
(new AccountApi(config: $client))->requestValidationEmail($request);

// 4. The result
// (RequestValidationEmail answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;

saveSettings#

PHP#
public function saveSettings(AccountSettings $account_settings): void

Change the account settings. Changes the settings that are passed; the others stay as they are. With an API token, those of the account that created it.

OperationSaveSettings · POST /openapi/account/SaveSettings
Scopeaccount:write

Parameters#

NameTypeDescription
account_settingsAccountSettingsrequiredThe request: its properties are those of the model, its JSON that of SaveSettings's request body.

Returns#

Nothing: the operation answers without a body (Saved).

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\AccountSettings;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "full_name": "",
  "country_code": "",
  "preferred_language": "",
  "time_zone_id": "",
  "bim_context": "",
  "show_deleted_nodes": false,
  "email_about_vulnerabilities": false,
  "ui_mode": "END_USER"
}
JSON, AccountSettings::class);

// 3. The call
(new AccountApi(config: $client))->saveSettings($request);

// 4. The result
// (SaveSettings answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;

signOutOtherSessions#

PHP#
public function signOutOtherSessions(?SignOutOtherSessionsRequest $sign_out_other_sessions_request = null): AuthResult

Sign out every other session. Ends every session of the signed-in account except this one, which continues on the session answered here: for a lost or shared device. An account session only. API tokens are separate credentials and keep working; revoke them with DeleteApiToken.

OperationSignOutOtherSessions · POST /openapi/account/SignOutOtherSessions
Scopeaccount:write

Parameters#

NameTypeDescription
sign_out_other_sessions_requestSignOutOtherSessionsRequestoptionalThe request: its properties are those of the model, its JSON that of SignOutOtherSessions's request body.

Returns#

AuthResult — The new session

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\Model\SignOutOtherSessionsRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "response_format": "auth"
}
JSON, SignOutOtherSessionsRequest::class);

// 3. The call
$result = (new AccountApi(config: $client))->signOutOtherSessions($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;

validateEmailAddress#

PHP#
public function validateEmailAddress(ValidateEmailAddressRequest $validate_email_address_request): void

Confirm an e-mail address and set the password. Confirms the address with the token from the validation e-mail and sets the account's password (8 to 128 characters, not a common one, not the address). It does not sign in: use LoginWithUsernamePassword after. The link is valid for a day.

OperationValidateEmailAddress · POST /openapi/account/ValidateEmailAddress
Scopenone: callable before logging in

Parameters#

NameTypeDescription
validate_email_address_requestValidateEmailAddressRequestrequiredThe request: its properties are those of the model, its JSON that of ValidateEmailAddress's request body.

Returns#

Nothing: the operation answers without a body (The address is confirmed).

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\AccountApi;
use BIMworks\Configuration;
use BIMworks\Model\ValidateEmailAddressRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works (ValidateEmailAddress needs no login)
$client = (new Configuration())->setHost('https://bim.works/openapi');

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "username": "",
  "token": "",
  "password": ""
}
JSON, ValidateEmailAddressRequest::class);

// 3. The call
(new AccountApi(config: $client))->validateEmailAddress($request);

// 4. The result
// (ValidateEmailAddress answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;