forked from coder-sapient/json-api-document-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SingleDocumentRequest.php
48 lines (38 loc) · 1.07 KB
/
SingleDocumentRequest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types=1);
/*
* (c) Yaroslav Khalupiak <i.am.khalupiak@gmail.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CoderSapient\JsonApi\Request;
use CoderSapient\JsonApi\Exception\BadRequestException;
use CoderSapient\JsonApi\Exception\InvalidArgumentException;
use CoderSapient\JsonApi\Query\SingleDocumentQuery;
trait SingleDocumentRequest
{
use JsonApiRequest;
/**
* @return string
*/
abstract public function resourceId(): string;
/**
* @return SingleDocumentQuery
*
* @throws BadRequestException
* @throws InvalidArgumentException
*/
public function toQuery(): SingleDocumentQuery
{
$this->ensureQueryParamsIsValid();
$query = new SingleDocumentQuery($this->resourceId(), $this->resourceType());
return $query->setIncludes($this->includes());
}
/**
* @return array
*/
public function acceptableQueryParams(): array
{
return [$this->queryInclude];
}
}