PHP Interface Neomerx\JsonApi\Contracts\Http\ResponsesInterface

Datei anzeigen Open project: neomerx/json-api Interface Usage Examples

Public Methods

Method Description
getCodeResponse ( integer $statusCode, array $headers = [] ) : mixed Get response with HTTP code only.
getContentResponse ( object | array $data, integer $statusCode = self::HTTP_OK, array | null $links = null, mixed $meta = null, array $headers = [] ) : mixed Get response with regular JSON API Document in body.
getCreatedResponse ( object $resource, array | null $links = null, mixed $meta = null, array $headers = [] ) : mixed Get response for newly created resource with HTTP code 201 (adds 'location' header).
getErrorResponse ( Neomerx\JsonApi\Contracts\Document\ErrorInterface | Neomerx\JsonApi\Contracts\Document\ErrorInterface[] | ErrorCollection $errors, integer $statusCode = self::HTTP_BAD_REQUEST, array $headers = [] ) : mixed Get response with JSON API Error in body.
getIdentifiersResponse ( object | array $data, integer $statusCode = self::HTTP_OK, array | null $links = null, mixed $meta = null, array $headers = [] ) : mixed Get response with only resource identifiers.
getMetaResponse ( array | object $meta, integer $statusCode = self::HTTP_OK, array $headers = [] ) : mixed Get response with meta information only.

Method Details

getCodeResponse() public method

Get response with HTTP code only.
public getCodeResponse ( integer $statusCode, array $headers = [] ) : mixed
$statusCode integer
$headers array
return mixed

getContentResponse() public method

Get response with regular JSON API Document in body.
public getContentResponse ( object | array $data, integer $statusCode = self::HTTP_OK, array | null $links = null, mixed $meta = null, array $headers = [] ) : mixed
$data object | array
$statusCode integer
$links array | null
$meta mixed
$headers array
return mixed

getCreatedResponse() public method

Get response for newly created resource with HTTP code 201 (adds 'location' header).
public getCreatedResponse ( object $resource, array | null $links = null, mixed $meta = null, array $headers = [] ) : mixed
$resource object
$links array | null
$meta mixed
$headers array
return mixed

getErrorResponse() public method

Get response with JSON API Error in body.
public getErrorResponse ( Neomerx\JsonApi\Contracts\Document\ErrorInterface | Neomerx\JsonApi\Contracts\Document\ErrorInterface[] | ErrorCollection $errors, integer $statusCode = self::HTTP_BAD_REQUEST, array $headers = [] ) : mixed
$errors Neomerx\JsonApi\Contracts\Document\ErrorInterface | Neomerx\JsonApi\Contracts\Document\ErrorInterface[] | Neomerx\JsonApi\Exceptions\ErrorCollection
$statusCode integer
$headers array
return mixed

getIdentifiersResponse() public method

Get response with only resource identifiers.
public getIdentifiersResponse ( object | array $data, integer $statusCode = self::HTTP_OK, array | null $links = null, mixed $meta = null, array $headers = [] ) : mixed
$data object | array
$statusCode integer
$links array | null
$meta mixed
$headers array
return mixed

getMetaResponse() public method

Get response with meta information only.
public getMetaResponse ( array | object $meta, integer $statusCode = self::HTTP_OK, array $headers = [] ) : mixed
$meta array | object Meta information.
$statusCode integer
$headers array
return mixed