<?php
// DeviceBulkOids.php
// Copyright P.Kassel, M.Seliger, G.Trietsch, all Rights Reserved
namespace Docuform\Api\Client;use Docuform\Api\HttpRequestHandler;use Docuform\Api\Exception\ApiHttpNotFoundException;use Docuform\Api\UserType;use Psr\Http\Message\ServerRequestInterface;use Psr\Http\Message\ResponseInterface;use Docuform\Api\ApiScopes;class DeviceBulkOids extends HttpRequestHandler{public function getAllowedUserTypes($request):array{return[UserType::USERTYPE_CUSTOMER,UserType::USERTYPE_DEALER,UserType::USERTYPE_ADMIN];}public function getRequiredScopes($request):array{return['allOf'=>[ApiScopes::bulk],'anyOf'=>[]];}public function handleRequest($request,& $response,$arguments):int{$result=404;if($request->getMethod()==='PATCH'){$clientApi=$this->getContainer()->get('RestApi');$bulk=$clientApi->getBulk();if($bulk===null){throw new ApiHttpNotFoundException($request);}$result=$bulk->setOids($request->getParsedBody());}elseif($request->getMethod()==='GET'){if(!empty($arguments['bulkId'])){$clientApi=$this->getContainer()->get('RestApi');$bulk=$clientApi->getBulk();if($bulk===null){throw new ApiHttpNotFoundException($request);}$oids=$bulk->getOids();if(!empty($oids)){$response->getBody()->write(json_encode($oids));$result=200;}else{$result=204;}}}return $result;}}