/** * @param \Psr\Http\Message\ResponseInterface $response * @throws \Exception */ public function validateBody(ResponseInterface $response) { $errors = $this->validateMessage($this->deserializer->getBodyAsString($response)); if (empty($errors) === false) { throw $this->exceptionFactory->createResponseBodyInvalidJsonApiException($response, $errors, $this->includeOriginalMessage); } }
/** * Returns a response with a status code of $responseCode, containing all the provided sections of the error * document. You can also pass additional meta information for the document in the $additionalMeta argument. * * @param SerializerInterface $serializer * @param \Psr\Http\Message\ResponseInterface $response * @param int $responseCode * @param array $additionalMeta * @return \Psr\Http\Message\ResponseInterface */ public function getResponse(SerializerInterface $serializer, ResponseInterface $response, $responseCode = null, array $additionalMeta = []) { return $serializer->serialize($response, $this->getResponseCode($responseCode), $this->transformContent($additionalMeta)); }
/** * Returns a response with a status code of $responseCode, containing the $relationshipName relationship object as * the primary data, assembled based on the $domainObject. You can also pass additional meta information to the * document in the $additionalMeta argument. * * @param string $relationshipName * @param \WoohooLabs\Yin\JsonApi\Request\RequestInterface $request * @param \Psr\Http\Message\ResponseInterface $response * @param \WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory * @param mixed $domainObject * @param int $responseCode * @param array $additionalMeta * @return \Psr\Http\Message\ResponseInterface */ public function getRelationshipResponse($relationshipName, RequestInterface $request, ResponseInterface $response, ExceptionFactoryInterface $exceptionFactory, SerializerInterface $serializer, $domainObject, $responseCode, array $additionalMeta = []) { $transformation = new Transformation($request, $this->createData(), $exceptionFactory, ""); $this->initializeDocument($domainObject); $content = $this->transformRelationshipContent($relationshipName, $transformation, $additionalMeta); return $serializer->serialize($response, $responseCode, $content); }