Skip to content

Commit

Permalink
Add throws tag to every methods (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Apr 13, 2023
1 parent 22f7a19 commit 122f8c0
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 38 deletions.
31 changes: 18 additions & 13 deletions lib/AuditLogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class AuditLogs
* array "metadata" Arbitrary key-value data containing information associated with the event. NOT REQUIRED
* @param string $idempotencyKey Unique key guaranteeing idempotency of events for 24 hours.
*
* @throws Exception\WorkOSException
*
* @return \WorkOS\Resource\AuditLogCreateEventStatus
*/

Expand All @@ -58,14 +60,16 @@ public function createEvent($organizationId, $event, $idempotencyKey = null)

/**
* @param array $auditLogExportOptions Associative array containing the keys detailed below
* @var null|string $organizationId Description of the record.
* @var null|string $rangeStart ISO-8601 Timestamp of the start of Export's the date range.
* @var null|string $rangeEnd ISO-8601 Timestamp of the end of Export's the date range.
* @var null|array $actions Actions that Audit Log Events will be filtered by.
* @var null|array $actors Actor names that Audit Log Events will be filtered by.
* @var null|array $targets Target types that Audit Log Events will be filtered by.
*
* @return Resource\AuditLogExport
* @var null|string $organizationId Description of the record.
* @var null|string $rangeStart ISO-8601 Timestamp of the start of Export's the date range.
* @var null|string $rangeEnd ISO-8601 Timestamp of the end of Export's the date range.
* @var null|array $actions Actions that Audit Log Events will be filtered by.
* @var null|array $actors Actor names that Audit Log Events will be filtered by.
* @var null|array $targets Target types that Audit Log Events will be filtered by.
*
* @throws Exception\WorkOSException
*
* @return Resource\AuditLogExport
*/

public function createExport($organizationId, $rangeStart, $rangeEnd, $actions = null, $actors = null, $targets = null)
Expand Down Expand Up @@ -95,11 +99,12 @@ public function createExport($organizationId, $rangeStart, $rangeEnd, $actions =
}

/**
* @param string $auditLogExportId Unique identifier of the Audit Log Export
*
* @return Resource\AuditLogExport
*/

* @param string $auditLogExportId Unique identifier of the Audit Log Export
*
* @throws Exception\WorkOSException
*
* @return Resource\AuditLogExport
*/
public function getExport($auditLogExportId)
{
$getExportPath = "audit_logs/exports/{$auditLogExportId}";
Expand Down
4 changes: 4 additions & 0 deletions lib/AuditTrail.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class AuditTrail
* @param array $event Associative array containing the keys detailed above
* @param string $idempotencyKey Unique key guaranteeing idempotency of events for 24 hours
*
* @throws Exception\WorkOSException
*
* @return boolean true if an event was successfully created
*/
public function createEvent($event, $idempotencyKey = null)
Expand Down Expand Up @@ -79,6 +81,8 @@ public function createEvent($event, $idempotencyKey = null)
* @param string $after Event ID to look after
* @param \WorkOS\Resource\Order $order The Order in which to paginate records
*
* @throws Exception\WorkOSException
*
* @return array An array containing the following:
* null|string Event ID to use as before cursor
* null|string Event ID to use as after cursor
Expand Down
15 changes: 14 additions & 1 deletion lib/DirectorySync.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class DirectorySync
* @param null|string $organizationId Unique ID for an organization
* @param \WorkOS\Resource\Order $order The Order in which to paginate records
*
* @throws Exception\WorkOSException
*
* @return array An array containing the following:
* null|string Directory ID to use as before cursor
* null|string Directory ID to use as after cursor
Expand Down Expand Up @@ -74,6 +76,8 @@ public function listDirectories(
* @param null|string $after Directory Group ID to look after
* @param \WorkOS\Resource\Order $order The Order in which to paginate records
*
* @throws Exception\WorkOSException
*
* @return array An array containing the following:
* null|string Directory Group ID to use as before cursor
* null|string Directory Group ID to use as after cursor
Expand Down Expand Up @@ -124,6 +128,8 @@ public function listGroups(
*
* @param string $directoryGroup Directory Group ID
*
* @throws Exception\WorkOSException
*
* @return \WorkOS\Resource\DirectoryGroup
*/
public function getGroup($directoryGroup)
Expand Down Expand Up @@ -151,6 +157,8 @@ public function getGroup($directoryGroup)
* @param null|string $after Directory User ID to look after
* @param \WorkOS\Resource\Order $order The Order in which to paginate records
*
* @throws Exception\WorkOSException
*
* @return array An array containing the following:
* null|string Directory User ID to use as before cursor
* null|string Directory User ID to use as after cursor
Expand Down Expand Up @@ -201,6 +209,8 @@ public function listUsers(
*
* @param string $directoryUser Directory User ID
*
* @throws Exception\WorkOSException
*
* @return \WorkOS\Resource\DirectoryUser
*/
public function getUser($directoryUser)
Expand All @@ -223,6 +233,8 @@ public function getUser($directoryUser)
*
* @param string $directory Directory ID
*
* @throws Exception\WorkOSException
*
* @return \WorkOS\Resource\Response
*/
public function deleteDirectory($directory)
Expand All @@ -245,9 +257,10 @@ public function deleteDirectory($directory)
*
* @param string $directory WorkOS directory ID
*
* @throws Exception\WorkOSException
*
* @return \WorkOS\Resource\Directory
*/

public function getDirectory($directory)
{
$directoriesPath = "directories/{$directory}";
Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/AuthenticationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
/**
* Class AuthenticationException.
*/
class AuthenticationException extends BaseRequestException
class AuthenticationException extends BaseRequestException implements WorkOSException
{
}
2 changes: 1 addition & 1 deletion lib/Exception/AuthorizationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
/**
* Class AuthorizationException.
*/
class AuthorizationException extends BaseRequestException
class AuthorizationException extends BaseRequestException implements WorkOSException
{
}
2 changes: 1 addition & 1 deletion lib/Exception/BadRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
/**
* Class BadRequestException.
*/
class BadRequestException extends BaseRequestException
class BadRequestException extends BaseRequestException implements WorkOSException
{
}
2 changes: 1 addition & 1 deletion lib/Exception/BaseRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* Base Exception for use in filtering a response for information.
*/
class BaseRequestException extends \Exception
class BaseRequestException extends \Exception implements WorkOSException
{
public $requestId = "";
public $responseError;
Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/ConfigurationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
*
* Thrown when a WorkOS package configuration related issue is encountered.
*/
class ConfigurationException extends \Exception
class ConfigurationException extends \Exception implements WorkOSException
{
}
2 changes: 1 addition & 1 deletion lib/Exception/GenericException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* Generic WorkOS Exception.
*/
class GenericException extends \Exception
class GenericException extends \Exception implements WorkOSException
{
public $data;

Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/NotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
/**
* Class NotFoundException.
*/
class NotFoundException extends BaseRequestException
class NotFoundException extends BaseRequestException implements WorkOSException
{
}
2 changes: 1 addition & 1 deletion lib/Exception/ServerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
/**
* Class ServerException.
*/
class ServerException extends BaseRequestException
class ServerException extends BaseRequestException implements WorkOSException
{
}
2 changes: 1 addition & 1 deletion lib/Exception/UnexpectedValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
/**
* class UnexpectedValueException.
*/
class UnexpectedValueException extends \Exception
class UnexpectedValueException extends \Exception implements WorkOSException
{
}
9 changes: 9 additions & 0 deletions lib/Exception/WorkOSException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace WorkOS\Exception;

use Throwable;

interface WorkOSException extends Throwable
{
}
23 changes: 13 additions & 10 deletions lib/MFA.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class MFA
* @param null|string $totpIssuer - Name of the Organization
* @param null|string $totpUser - Email of user
* @param null|string $phoneNumber - Phone number of user
*/

*
* @throws Exception\WorkOSException
*/
public function enrollFactor(
$type,
$totpIssuer = null,
Expand Down Expand Up @@ -73,8 +74,7 @@ public function enrollFactor(
*
* @param string $authenticationFactorId - ID of the authentication factor
* @param string|null $smsTemplate - Optional parameter to customize the message for sms type factors. Must include "{{code}}" if used.
*/

*/
public function challengeFactor(
$authenticationFactorId,
$smsTemplate = null
Expand Down Expand Up @@ -140,8 +140,9 @@ public function verifyFactor(
*
* @param string $authenticationChallengeId - The ID of the authentication challenge that provided the user the verification code.
* @param string $code - The verification code sent to and provided by the end user.
*/

*
* @throws Exception\WorkOSException
*/
public function verifyChallenge(
$authenticationChallengeId,
$code
Expand Down Expand Up @@ -173,8 +174,9 @@ public function verifyChallenge(
* Returns a Factor.
*
* @param string $authenticationFactorId - WorkOS Factor ID
*/

*
* @throws Exception\WorkOSException
*/
public function getFactor($authenticationFactorId)
{
$getFactorPath = "auth/factors/{$authenticationFactorId}";
Expand All @@ -195,8 +197,9 @@ public function getFactor($authenticationFactorId)
* Deletes a Factor.
*
* @param string $authenticationFactorId - WorkOS Factor ID
*/

*
* @throws Exception\WorkOSException
*/
public function deleteFactor($authenticationFactorId)
{
$deleteFactorPath = "auth/factors/{$authenticationFactorId}";
Expand Down
12 changes: 10 additions & 2 deletions lib/Organizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Organizations
* @param null|string $after Organization ID to look after
* @param \WorkOS\Resource\Order $order The Order in which to paginate records
*
* @throws Exception\WorkOSException
*
* @return array An array containing the following:
* null|string Organization ID to use as before cursor
* null|string Organization ID to use as after cursor
Expand Down Expand Up @@ -68,6 +70,8 @@ public function listOrganizations(
* that are outside of the Organization's configured User Email Domains.
* @param null|string $idempotencyKey is a unique string that identifies a distinct organization
*
* @throws Exception\WorkOSException
*
* @return \WorkOS\Resource\Organization
*/
public function createOrganization($name, $domains, $allowProfilesOutsideOrganization = null, $idempotencyKey = null)
Expand All @@ -93,8 +97,9 @@ public function createOrganization($name, $domains, $allowProfilesOutsideOrganiz
* @param string $name The name of the Organization.
* @param null|boolean $allowProfilesOutsideOrganization Whether Connections within the Organization allow profiles
* that are outside of the Organization's configured User Email Domains.
*
* @throws Exception\WorkOSException
*/

public function updateOrganization($organization, $domains, $name, $allowProfilesOutsideOrganization = null)
{
$organizationsPath = "organizations/{$organization}";
Expand All @@ -115,9 +120,10 @@ public function updateOrganization($organization, $domains, $name, $allowProfile
*
* @param string $organization WorkOS organization ID
*
* @throws Exception\WorkOSException
*
* @return \WorkOS\Resource\Organization
*/

public function getOrganization($organization)
{
$organizationsPath = "organizations/{$organization}";
Expand All @@ -132,6 +138,8 @@ public function getOrganization($organization)
*
* @param string $organization WorkOS organization ID
*
* @throws Exception\WorkOSException
*
* @return \WorkOS\Resource\Response
*/
public function deleteOrganization($organization)
Expand Down
9 changes: 7 additions & 2 deletions lib/Passwordless.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class Passwordless
* @param string $type The only supported ConnectionType at the time of this writing is MagicLink
* @param $connection the unique WorkOS connection_ID
* @param $expiresIn The number of seconds the Passwordless Session should live before expiring.
*
* @throws Exception\WorkOSException
*
* @return \WorkOS\Resource\PasswordlessSession
*/
public function createSession($email, $redirectUri, $state, $type, $connection, $expiresIn)
Expand Down Expand Up @@ -50,11 +53,13 @@ public function createSession($email, $redirectUri, $state, $type, $connection,
return Resource\PasswordlessSession::constructFromResponse($response);
}


/** Send a passwordless link via email from WorkOS.
/**
* Send a passwordless link via email from WorkOS.
*
* @param \WorkOS\Resource\PasswordlessSession $session Passwordless session generated through Passwordless->createSession
*
* @throws Exception\WorkOSException
*
* @return boolean true
*/
public function sendSession($session)
Expand Down
2 changes: 2 additions & 0 deletions lib/Portal.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Portal
* @param null|string $successUrl The URL to which WorkOS will redirect users to
* upon successfully setting up Single Sign On or Directory Sync. (Optional).
*
* @throws Exception\WorkOSException
*
* @return \WorkOS\Resource\PortalLink
*/
public function generateLink($organization, $intent, $returnUrl = null, $successUrl = null)
Expand Down

0 comments on commit 122f8c0

Please sign in to comment.