diff --git a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookDeleteContact.php b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookDeleteContact.php index 3f3ccf8..2ab7463 100644 --- a/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookDeleteContact.php +++ b/src/Socialbox/Classes/StandardMethods/AddressBook/AddressBookDeleteContact.php @@ -6,6 +6,8 @@ use Socialbox\Abstracts\Method; use Socialbox\Enums\StandardError; use Socialbox\Exceptions\DatabaseOperationException; + use Socialbox\Exceptions\Standard\InvalidRpcArgumentException; + use Socialbox\Exceptions\Standard\MissingRpcArgumentException; use Socialbox\Exceptions\Standard\StandardException; use Socialbox\Interfaces\SerializableInterface; use Socialbox\Managers\ContactManager; @@ -16,13 +18,16 @@ class AddressBookDeleteContact extends Method { /** + * Deletes a contact from the authenticated peer's address book, returns True if the contact was deleted + * false if the contact does not exist. + * * @inheritDoc */ public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface { if(!$rpcRequest->containsParameter('peer')) { - return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'Missing required peer parameter'); + throw new MissingRpcArgumentException('peer'); } try @@ -31,7 +36,7 @@ } catch(InvalidArgumentException $e) { - throw new StandardException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e); + throw new InvalidRpcArgumentException('peer', $e->getMessage()); } try @@ -40,7 +45,7 @@ $peer = $request->getPeer(); if(!ContactManager::isContact($peer, $address)) { - return $rpcRequest->produceError(StandardError::FORBIDDEN, 'Contact does not exist'); + return $rpcRequest->produceResponse(false); } // Create the contact