@param \Spryker\Glue\GlueApplication\Rest\JsonApi\RestResponseInterface $restResponse

@return \Spryker\Glue\GlueApplication\Rest\JsonApi\RestResponseInterface
183736
public function addExternalReferenceMissingError(RestResponseInterface $restResponse): RestResponseInterface
    {
        $restErrorTransfer = (new RestErrorMessageTransfer())
            ->setCode(CompanyBusinessUnitsRestApiConfig::RESPONSE_CODE_EXTERNAL_REFERENCE_MISSING)
            ->setStatus(Response::HTTP_BAD_REQUEST)
            ->setDetail(CompanyBusinessUnitsRestApiConfig::RESPONSE_DETAILS_EXTERNAL_REFERENCE_MISSING);

        return $restResponse->addError($restErrorTransfer);
    }
657555
public function setResponse(JsonResponse $response)
    {
        $this->response = $response;

        if (!$response->getRequest()) {
            $response->setRequest($this);
        }

        return $this;
    }
750142
public function configureRestler(Restler $restler)
    {
        if ($this->extensionConfiguration->isOnlineDocumentationEnabled()) {
            $restler->addAPIClass('Luracast\\Restler\\Explorer\\v2\\Explorer', $this->extensionConfiguration->getPathOfOnlineDocumentation());
            $restler->addAuthenticationClass('Aoe\\Restler\\Controller\\ExplorerAuthenticationController');
        }

        // add authentication-class, which can be used to check, if BE-user is logged in
        $restler->addAuthenticationClass('Aoe\\Restler\\Controller\\BeUserAuthenticationController');

        // add authentication-class, which can be used to check, if FE-user is logged in
        $restler->addAuthenticationClass('Aoe\\Restler\\Controller\\FeUserAuthenticationController');
    }
294288
private function doTransformObjectResponse(ObjectResponse $objectResponse)
    {
        $responseData = $objectResponse;

        if ($objectResponse->isActionTransform()) {
            try {
                $responseData = $this->transformerManager->transform(
                    $responseData->getObject(),
                    $objectResponse->getTransformerContext()
                );

                if (!is_object($responseData)) {
                    throw UnexpectedTypeException::create($responseData, 'object');
                }
            } catch (TransformerUnsupportedObjectException $e) {
                throw new \RuntimeException(sprintf(
                    'Can not transform object with class "%s".',
                    get_class($objectResponse)
                ), 0, $e);
            }
        }

        try {
            $responseData = $this->normalizerManager->normalize(
                $responseData instanceof ObjectResponse ? $responseData->getObject() : $responseData,
                $objectResponse->getNormalizerContext()
            );

            if (!is_array($responseData)) {
                throw UnexpectedTypeException::create($responseData, 'array');
            }
        } catch (NormalizerUnsupportedObjectException $e) {
            throw new \RuntimeException(sprintf(
                'Can not normalize object with class "%s".',
                get_class($responseData)
            ), 0, $e);
        }

        if ($objectResponse->isEmptyResponse()) {
            $response = new EmptyResponse($responseData, $objectResponse->getHttpStatusCode());
        } else {
            $response = new Response($responseData, $objectResponse->getHttpStatusCode());
        }

        return $response;
    }
1151325
protected String callRestEndpointForMultifactor(final Principal principal, final Service resolvedService) {
        val restTemplate = new RestTemplate();
        val restEndpoint = casProperties.getAuthn().getMfa().getRestEndpoint();
        val entity = new RestEndpointEntity(principal.getId(), resolvedService.getId());
        val responseEntity = restTemplate.postForEntity(restEndpoint, entity, String.class);
        if (responseEntity.getStatusCode() == HttpStatus.OK) {
            return responseEntity.getBody();
        }
        return null;
    }
1169000
public function onKernelRequest(RestEvent $event)
    {
        $request = $event->getRequest();

        if ($request->headers->has('Accept')) {

            $format = $request->getFormat($request->headers->get('Accept'));

            if (!empty($format)) {
                $request->setRequestFormat($format);
            }
        }
    }
1048625
private function parse($uri)
    {
        $this->parsedUri = parse_url($uri);

        if (false === strstr($this->parsedUri['path'], $this->config->getRootEndpoint())) {
            throw RestException::invalidEndpoint($this->parsedUri['path']);
        }

        $this->adjustRootEndpoint($this->parsedUri['path']);

        $this->parsedUri['path'] = str_replace($this->config->getRootEndpoint(), '', $this->parsedUri['path']);
        $this->parsePath($this->parsedUri['path']);

        $this->parsedUri['query'] = isset($this->parsedUri['query']) ? $this->parsedUri['query'] : '';
        $this->parseQueryString($this->parsedUri['query']);

        return $this;
    }
584304
public function create($data)
    {
        // TODO refacto translate
        $mode = $this->params('mode', false);
        $type = $this->params('type', false);
        $endpoint = $this->params('endpoint', false);
        $annee = $this->params('annee', 0);
        $processStateHandler = $this->getProcessStateHandler();
        $processExecutionHandler = $this->getProcessExecutionHandler();
        $processExecutionHandler->cleanProcesses();
        
        $process = $processStateHandler->getProcess($mode, $type, $endpoint, $annee);
        if (is_null($process) || ! $process instanceof \Minibus\Model\Entity\Process)
            throw new RestApiException(array(
                "not-found" => "Le process $mode-$type-$endpoint-$annee n'existe pas "
            ));
        else 
            if ($process instanceof \Minibus\Model\Entity\Process) {
                if ($process->getActive() !== true)
                    throw new RestApiException(array(
                        "inactive" => "Le process $mode-$type-$endpoint-$annee n'est pas actif"
                    ));
                if ($process->getRunning() == true)
                    throw new RestApiException(array(
                        "running" => "Le process $mode-$type-$endpoint-$annee est en cours d'exécution"
                    ));
                $processStateHandler->askImmediateExecution($process, $data);
                $response = $this->getResponse();
                $response->getHeaders()->addHeaderLine('Content-Type', 'application/json');
                $serializer = $this->getSerializer();
                $response->setContent($serializer->serialize($process, 'json'));
                return $response;
            }
    }
1294742
private function contentParser(RestRequestModel $apiRequest)
    {
        $content = [];

        if ($apiRequest->getContentType() == 'form') {
            parse_str($apiRequest->getContent(), $content);
        }

        if (in_array($apiRequest->getContentType(), ['json', 'js'])) {
            $content = json_decode($apiRequest->getContent());

            if (is_object($content) && isset($content->payload)) {
                $this->pkgUuid = isset($content->pkg_uuid) ? $content->pkg_uuid : null;
                $content = $content->payload;
            }
        }

        return $content;
    }
427907
private function setRestDriver($restDriver)
    {
        $namespace = '\\' . __NAMESPACE__ . '\\RestClient\\';
        $driver = $namespace . $restDriver;
        $parent = $namespace . 'DriverInterface';

        if (
            empty($restDriver)
            || !class_exists($driver)
            || !is_subclass_of($driver, $parent)
        ) {
            throw new InvalidArgumentException('rest driver', $driver);
        }

        // create a new REST Driver
        $this->restDriver = new $driver();
        if (isset($this->url)) {
            $this->restDriver->setHost($this->url);
        }
    }
267425
protected function getService( $service){
        $rest = new utils\rest\RestAuth( $this->application->getFreeboxApiHost() . $service);
        $rest->setSessionToken( $this->application->getSessionToken());
        return $rest;
    }
529411
private function extractFilters(array $params)
    {
        if (false === $this->issetNotEmpty(self::PARAM_FILTERING, $params)) {
            return $this;
        }
        $filters = $params[self::PARAM_FILTERING];
        if (!is_array($filters)) {
            throw RestException::invalidQueryParam(self::PARAM_FILTERING, 'The filter parameter must be an array keyed by filter name and value.');
        }
        foreach ($filters as $key => $value) {
            $this->filters[$key] = $value;
        }
        return $this;
    }
125671
public static function makeFromJson(JsonResponse $json)
    {
        $content = $json->getContent();

        // If the contents of the JsonResponse does not starts with /**/ (typical laravel jsonp response)
        // we assume that it is a valid json response that can be decoded, or we just use the raw jsonp
        // contents for building the response
        if (! starts_with($json->getContent(), '/**/')) {
            $content = json_decode($json->getContent(), true);
        }

        $new = static::create($content, $json->getStatusCode());

        $new->headers = $json->headers;

        return $new;
    }
793584
public function resource(
        RestRequestContract $request,
        ResourceInterface   $resource = null,
        int                 $httStatus = RestResponse::HTTP_OK,
        array               $headers = []
    ) {
        $data = $resource ? $this->fractal($request)->createData($resource)->toArray() : null;

        return RestResponse::create($data, $httStatus, $headers);
    }
1291855
public function get($id)
    {
        $entity = $this->repository->find($id);

        if (!$entity) {
            throw new RestNotFoundException();
        }

        return $entity;
    }
336144
public static function sendScriptResponse(ServiceResponseInterface $response)
    {
        $content = $response->getContent();
        $contentType = $response->getContentType();
        $format = $response->getDataFormat();
        $headers = $response->getHeaders();

        $status = $response->getStatusCode();
        //  In case the status code is not a valid HTTP Status code
        if (!in_array($status, HttpStatusCodes::getDefinedConstants())) {
            //  Do necessary translation here. Default is Internal server error.
            $status = HttpStatusCodeInterface::HTTP_INTERNAL_SERVER_ERROR;
        }

        if ($content instanceof \Exception) {
            $status =
                ($content instanceof RestException) ? $content->getStatusCode()
                    : ServiceResponseInterface::HTTP_INTERNAL_SERVER_ERROR;
            $content = ['error' => self::exceptionToArray($content)];
            $format = DataFormats::PHP_ARRAY;
        }

        return [
            'status_code'  => $status,
            'content'      => $content,
            'content_type' => $contentType,
            'format'       => $format,
            'headers'      => $headers
        ];
    }
276469
protected function createSaveCompanyBusinessUnitFailedErrorResponse(
        RestCompanyBusinessUnitsResponseTransfer $restCompanyBusinessUnitsResponseTransfer
    ): RestResponseInterface {
        $restResponse = $this->restResourceBuilder->createRestResponse();

        foreach ($restCompanyBusinessUnitsResponseTransfer->getErrors() as $restCompanyBusinessUnitsErrorTransfer) {
            $restResponse->addError((new RestErrorMessageTransfer())
                ->setCode($restCompanyBusinessUnitsErrorTransfer->getCode())
                ->setStatus($restCompanyBusinessUnitsErrorTransfer->getStatus())
                ->setDetail($restCompanyBusinessUnitsErrorTransfer->getDetail()));
        }

        return $restResponse;
    }