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 :
Clients.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\Clients as ClientsMapper; use PleskExt\RestApi\v2\Mapper\Response as ResponseMapper; use PleskExt\RestApi\v2\Entity\Client as ClientEntity; use PleskExt\RestApi\v2\SDK; use PleskRestApi\Slim\Psr7\Request; use PleskRestApi\Slim\Psr7\Response; class Clients extends InvokableHandler { /** * @Producer(mapper=ClientsMapper::class) */ protected function get(Request $request, Response $response) { $clients = \pm_Client::getAll(); $response->getBody()->write($this->produce($clients)); return $response; } /** * @Consumer(type=ClientEntity::class) * @Producer(mapper=ResponseMapper::class) */ protected function post(Request $request, Response $response) { $client = SDK\pm_Client::create($this->consume()); $response->getBody()->write($this->produce($client)); return $response->withStatus(201); } }