-
Notifications
You must be signed in to change notification settings - Fork 214
feat: Add Self Service Profiles endpoints #795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tim-zitcha
wants to merge
3
commits into
auth0:main
Choose a base branch
from
tim-zitcha:add-self-service-profiles
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+578
−3
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,208 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Auth0\SDK\API\Management; | ||
|
|
||
| use Auth0\SDK\Contract\API\Management\SelfServiceProfilesInterface; | ||
| use Auth0\SDK\Utility\Request\RequestOptions; | ||
| use Auth0\SDK\Utility\Toolkit; | ||
| use Psr\Http\Message\ResponseInterface; | ||
|
|
||
| /** | ||
| * Handles requests to the Self Service Profiles endpoint of the v2 Management API. | ||
| * | ||
| * @see https://auth0.com/docs/api/management/v2/self-service-profiles | ||
| */ | ||
| final class SelfServiceProfiles extends ManagementEndpoint implements SelfServiceProfilesInterface | ||
| { | ||
| public function create( | ||
| string $name, | ||
| array $body, | ||
| ?RequestOptions $options = null, | ||
| ): ResponseInterface { | ||
| [$name] = Toolkit::filter([$name])->string()->trim(); | ||
| [$body] = Toolkit::filter([$body])->array()->trim(); | ||
|
|
||
| Toolkit::assert([ | ||
| [$name, \Auth0\SDK\Exception\ArgumentException::missing('name')], | ||
| ])->isString(); | ||
|
|
||
| /** @var array<mixed> $body */ | ||
|
|
||
| return $this->getHttpClient() | ||
| ->method('post') | ||
| ->addPath(['self-service-profiles']) | ||
| ->withBody( | ||
| (object) Toolkit::merge([[ | ||
| 'name' => $name, | ||
| ], $body]), | ||
| ) | ||
| ->withOptions($options) | ||
| ->call(); | ||
| } | ||
|
|
||
| public function createSsoTicket( | ||
| string $id, | ||
| ?array $body = null, | ||
| ?RequestOptions $options = null, | ||
| ): ResponseInterface { | ||
| [$id] = Toolkit::filter([$id])->string()->trim(); | ||
| [$body] = Toolkit::filter([$body])->array()->trim(); | ||
|
|
||
| Toolkit::assert([ | ||
| [$id, \Auth0\SDK\Exception\ArgumentException::missing('id')], | ||
| ])->isString(); | ||
|
|
||
| /** @var array<mixed> $body */ | ||
|
|
||
| return $this->getHttpClient() | ||
| ->method('post') | ||
| ->addPath(['self-service-profiles', $id, 'sso-ticket']) | ||
| ->withBody((object) $body) | ||
| ->withOptions($options) | ||
| ->call(); | ||
| } | ||
|
|
||
| public function delete( | ||
| string $id, | ||
| ?RequestOptions $options = null, | ||
| ): ResponseInterface { | ||
| [$id] = Toolkit::filter([$id])->string()->trim(); | ||
|
|
||
| Toolkit::assert([ | ||
| [$id, \Auth0\SDK\Exception\ArgumentException::missing('id')], | ||
| ])->isString(); | ||
|
|
||
| return $this->getHttpClient() | ||
| ->method('delete') | ||
| ->addPath(['self-service-profiles', $id]) | ||
| ->withOptions($options) | ||
| ->call(); | ||
| } | ||
|
|
||
| public function get( | ||
| string $id, | ||
| ?RequestOptions $options = null, | ||
| ): ResponseInterface { | ||
| [$id] = Toolkit::filter([$id])->string()->trim(); | ||
|
|
||
| Toolkit::assert([ | ||
| [$id, \Auth0\SDK\Exception\ArgumentException::missing('id')], | ||
| ])->isString(); | ||
|
|
||
| return $this->getHttpClient() | ||
| ->method('get') | ||
| ->addPath(['self-service-profiles', $id]) | ||
| ->withOptions($options) | ||
| ->call(); | ||
| } | ||
|
|
||
| public function getAll( | ||
| ?array $parameters = null, | ||
| ?RequestOptions $options = null, | ||
| ): ResponseInterface { | ||
| [$parameters] = Toolkit::filter([$parameters])->array()->trim(); | ||
|
|
||
| /** @var array<null|int|string> $parameters */ | ||
|
|
||
| return $this->getHttpClient() | ||
| ->method('get') | ||
| ->addPath(['self-service-profiles']) | ||
| ->withParams($parameters) | ||
| ->withOptions($options) | ||
| ->call(); | ||
| } | ||
|
|
||
| public function getCustomTextForProfile( | ||
| string $id, | ||
| string $language, | ||
| string $page, | ||
| ?RequestOptions $options = null, | ||
| ): ResponseInterface { | ||
| [$id] = Toolkit::filter([$id])->string()->trim(); | ||
| [$language] = Toolkit::filter([$language])->string()->trim(); | ||
| [$page] = Toolkit::filter([$page])->string()->trim(); | ||
|
|
||
| Toolkit::assert([ | ||
| [$id, \Auth0\SDK\Exception\ArgumentException::missing('id')], | ||
| [$language, \Auth0\SDK\Exception\ArgumentException::missing('language')], | ||
| [$page, \Auth0\SDK\Exception\ArgumentException::missing('page')], | ||
| ])->isString(); | ||
|
|
||
| return $this->getHttpClient() | ||
| ->method('get') | ||
| ->addPath(['self-service-profiles', $id, 'custom-text', $language, $page]) | ||
| ->withOptions($options) | ||
| ->call(); | ||
| } | ||
|
|
||
| public function revokeSsoTicket( | ||
| string $profileId, | ||
| string $id, | ||
| ?RequestOptions $options = null, | ||
| ): ResponseInterface { | ||
| [$profileId, $id] = Toolkit::filter([$profileId, $id])->string()->trim(); | ||
|
|
||
| Toolkit::assert([ | ||
| [$profileId, \Auth0\SDK\Exception\ArgumentException::missing('profileId')], | ||
| [$id, \Auth0\SDK\Exception\ArgumentException::missing('id')], | ||
| ])->isString(); | ||
|
|
||
| return $this->getHttpClient() | ||
| ->method('post') | ||
| ->addPath(['self-service-profiles', $profileId, 'sso-ticket', $id, 'revoke']) | ||
| ->withOptions($options) | ||
| ->call(); | ||
| } | ||
|
|
||
| public function setCustomTextForProfile( | ||
| string $id, | ||
| string $language, | ||
| string $page, | ||
| array $body, | ||
| ?RequestOptions $options = null, | ||
| ): ResponseInterface { | ||
| [$id] = Toolkit::filter([$id])->string()->trim(); | ||
| [$language] = Toolkit::filter([$language])->string()->trim(); | ||
| [$page] = Toolkit::filter([$page])->string()->trim(); | ||
| [$body] = Toolkit::filter([$body])->array()->trim(); | ||
|
|
||
| Toolkit::assert([ | ||
| [$id, \Auth0\SDK\Exception\ArgumentException::missing('id')], | ||
| [$language, \Auth0\SDK\Exception\ArgumentException::missing('language')], | ||
| [$page, \Auth0\SDK\Exception\ArgumentException::missing('page')], | ||
| ])->isString(); | ||
|
|
||
| return $this->getHttpClient() | ||
| ->method('PUT') | ||
| ->addPath(['self-service-profiles', $id, 'custom-text', $language, $page]) | ||
| ->withOptions($options) | ||
| ->withBody($body ?? []) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant null coalescing operator: The |
||
| ->call(); | ||
| } | ||
|
|
||
| public function update( | ||
| string $id, | ||
| array $body, | ||
| ?RequestOptions $options = null, | ||
| ): ResponseInterface { | ||
| [$id] = Toolkit::filter([$id])->string()->trim(); | ||
| [$body] = Toolkit::filter([$body])->array()->trim(); | ||
|
|
||
| Toolkit::assert([ | ||
| [$id, \Auth0\SDK\Exception\ArgumentException::missing('id')], | ||
| ])->isString(); | ||
|
|
||
| Toolkit::assert([ | ||
| [$body, \Auth0\SDK\Exception\ArgumentException::missing('body')], | ||
| ])->isArray(); | ||
|
|
||
| return $this->getHttpClient() | ||
| ->method('patch') | ||
| ->addPath(['self-service-profiles', $id]) | ||
| ->withBody((object) $body) | ||
| ->withOptions($options) | ||
| ->call(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTTP method case inconsistency: This method uses
'PUT'in uppercase while all other methods in the class use lowercase ('post','get','delete','patch'). For consistency with the rest of the codebase, this should be'put'in lowercase.