diff --git a/src/Socialbox/Enums/ReservedUsernames.php b/src/Socialbox/Enums/ReservedUsernames.php new file mode 100644 index 0000000..651d22b --- /dev/null +++ b/src/Socialbox/Enums/ReservedUsernames.php @@ -0,0 +1,10 @@ + 'Unknown Error', + + self::RPC_METHOD_NOT_FOUND => 'The request method was not found', + self::RPC_INVALID_ARGUMENTS => 'The request method contains one or more invalid arguments', + + self::INTERNAL_SERVER_ERROR => 'Internal server error', + self::SERVER_UNAVAILABLE => 'Server temporarily unavailable', + + self::INVALID_PUBLIC_KEY => 'The given public key is not valid', + self::SESSION_NOT_FOUND => 'The requested session UUID was not found', + self::UNSUPPORTED_AUTHENTICATION_TYPE => 'The requested authentication type is not supported by the server' + }; + + } +} \ No newline at end of file diff --git a/src/Socialbox/Enums/StandardHeaders.php b/src/Socialbox/Enums/StandardHeaders.php new file mode 100644 index 0000000..ec0b6fb --- /dev/null +++ b/src/Socialbox/Enums/StandardHeaders.php @@ -0,0 +1,59 @@ + true, + + default => false, + }; + } + + /** + * Retrieves an array of required headers. + * + * @return array An array containing only the headers that are marked as required. + */ + public static function getRequiredHeaders(): array + { + /** @var StandardHeaders $header */ + return array_filter(StandardHeaders::toArray(), fn($header) => $header->isRequired()); + } + + /** + * @return array + */ + public static function toArray(): array + { + $results = []; + foreach(StandardHeaders::values() as $header) + { + $results[$header->getValue()] = $header; + } + + return $results; + } +} \ No newline at end of file diff --git a/src/Socialbox/Enums/StandardMethods.php b/src/Socialbox/Enums/StandardMethods.php new file mode 100644 index 0000000..456d2b7 --- /dev/null +++ b/src/Socialbox/Enums/StandardMethods.php @@ -0,0 +1,26 @@ + Ping::execute($request, $rpcRequest), + self::CREATE_SESSION => CreateSession::execute($request, $rpcRequest), + + default => $rpcRequest->produceError(StandardError::RPC_METHOD_NOT_FOUND, sprintf('The method %s is not handled by the server', $this->value)), + }; + } +} \ No newline at end of file diff --git a/src/Socialbox/Enums/StandardResponseCodes.php b/src/Socialbox/Enums/StandardResponseCodes.php new file mode 100644 index 0000000..a6c1769 --- /dev/null +++ b/src/Socialbox/Enums/StandardResponseCodes.php @@ -0,0 +1,27 @@ +