slacker775/knowbe4-kmsat-api

1.1.0 2021-11-16 19:14 UTC

This package is auto-updated.

Last update: 2024-11-17 01:36:04 UTC


README

This library provices access to the KnowBe4 training, phishing, user and group data. It leverages PSR18 HTTP clients (symfony/http-client or others) to provide flexibility with your project.

###Really basic usage

$KNOWBE4_API_TOKEN = '12345';

$bearerAuth = new BearerAuthAuthentication(
$KNOWBE4_API_TOKEN
);

$httpClient = getHttpClient([new AuthenticationRegistry([$bearerAuth])]);
$apiClient = \KnowBe4\Kmsat\Api\Client::create($httpClient);

$result = $apiClient->getAccount();

function getHttpClient(array $additionalPlugins = []): PluginClient
{
    $httpClient = Psr18ClientDiscovery::find();
    $plugins = [];
    $uri = Psr17FactoryDiscovery::findUrlFactory()->createUri(
        'https://us.api.knowbe4.com'
    );
    $plugins[] = new AddHostPlugin($uri);
    if (count($additionalPlugins) > 0) {
        $plugins = array_merge($plugins, $additionalPlugins);
    }
    return new PluginClient($httpClient, $plugins);
}