D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
psa
/
admin
/
plib
/
modules
/
rest-api
/
v2
/
externals
/
Handler
/
Filename :
ClientsId.php
back
Copy
<?php // Copyright 1999-2024. WebPros International GmbH. All rights reserved. namespace PleskExt\RestApi\v2\Handler; use PleskExt\RestApi\v2\Annotation\Consumer; use PleskExt\RestApi\v2\Annotation\Producer; use PleskExt\RestApi\v2\Helper\InvokableHandler; use PleskExt\RestApi\v2\Mapper\Response as ResponseMapper; use PleskExt\RestApi\v2\Mapper\Client as ClientMapper; use PleskExt\RestApi\v2\Entity\Client as ClientEntity; use PleskExt\RestApi\v2\SDK; use PleskRestApi\Slim\Psr7\Request; use PleskRestApi\Slim\Psr7\Response; class ClientsId extends InvokableHandler { /** * @Producer(mapper=ClientMapper::class) */ protected function get(Request $request, Response $response) { $client = SDK\pm_Client::getByClientId($request->getAttribute('id')); $response->getBody()->write($this->produce($client)); return $response; } /** * @Consumer(type=ClientEntity::class) * @Producer(mapper=ResponseMapper::class) */ protected function put(Request $request, Response $response) { $client = SDK\pm_Client::getByClientId($request->getAttribute('id')); $client->update($this->consume()); $response->getBody()->write($this->produce($client)); return $response; } /** * @Producer(mapper=ResponseMapper::class) */ protected function delete(Request $request, Response $response) { $client = SDK\pm_Client::getByClientId($request->getAttribute('id')); $client->delete(); $response->getBody()->write($this->produce($client)); return $response; } }