Skip to content

Commit

Permalink
feature: Add management() to SDK service as a Management API conven…
Browse files Browse the repository at this point in the history
…ience method (#376)
  • Loading branch information
evansims authored Apr 24, 2023
1 parent ae4b1f7 commit 7326cfb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Auth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Auth0\Laravel\Store\LaravelSession;
use Auth0\SDK\Auth0 as SDK;
use Auth0\SDK\Configuration\SdkConfiguration as Configuration;
use Auth0\SDK\Contract\API\ManagementInterface;
use Auth0\SDK\Contract\Auth0Interface as SDKContract;
use Auth0\SDK\Utility\HttpTelemetry;

Expand Down Expand Up @@ -115,6 +116,11 @@ public function getSdk(): SDKContract
return $this->setSdk(new SDK($this->getConfiguration()));
}

public function management(): ManagementInterface
{
return $this->getSdk()->management();
}

public function reset(): self
{
unset($this->sdk, $this->configuration);
Expand Down
6 changes: 6 additions & 0 deletions src/Contract/Auth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Auth0\Laravel\Contract;

use Auth0\SDK\Configuration\SdkConfiguration as Configuration;
use Auth0\SDK\Contract\API\ManagementInterface;
use Auth0\SDK\Contract\Auth0Interface as SDK;

interface Auth0
Expand All @@ -19,6 +20,11 @@ public function getConfiguration(): Configuration;
*/
public function getSdk(): SDK;

/**
* Returns an instance of the Management API class.
*/
public function management(): ManagementInterface;

/**
* Resets and cleans up the internal state of the SDK.
*/
Expand Down
7 changes: 6 additions & 1 deletion tests/Unit/Auth0Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
declare(strict_types=1);

use Auth0\SDK\Contract\Auth0Interface as SdkContract;
use Auth0\Laravel\Auth0;
use Auth0\SDK\Auth0 as SDKAuth0;
use Auth0\SDK\Configuration\SdkConfiguration;
use Auth0\SDK\Contract\API\ManagementInterface;

uses()->group('auth0');

it('returns a Management API class', function (): void {
$laravel = app('auth0');
expect($laravel->management())->toBeInstanceOf(ManagementInterface::class);
});

it('can get/set the configuration', function (): void {
$laravel = app('auth0');
expect($laravel->getConfiguration())->toBeInstanceOf(SdkConfiguration::class);
Expand Down

0 comments on commit 7326cfb

Please sign in to comment.