1 | <?php |
||
11 | class JsonApiResponse extends JsonResponse implements ApiResponse |
||
12 | { |
||
13 | /** @var int */ |
||
14 | private $code; |
||
15 | |||
16 | /** @var string */ |
||
17 | private $charset; |
||
18 | |||
19 | /** @var string|null */ |
||
20 | private $encodedData = null; |
||
21 | |||
22 | /** |
||
23 | * @param int $code |
||
24 | * @param array|\stdClass $data |
||
25 | * @param string $contentType |
||
26 | * @param string $charset |
||
27 | */ |
||
28 | 12 | public function __construct($code, $data, $contentType = 'application/json', $charset = 'utf-8') |
|
34 | |||
35 | /** |
||
36 | * Return api response http code |
||
37 | * @return integer |
||
38 | */ |
||
39 | 12 | public function getCode() |
|
43 | |||
44 | /** |
||
45 | * @return string |
||
46 | * @throws JsonException |
||
47 | */ |
||
48 | public function getEncodedData() |
||
55 | |||
56 | /** |
||
57 | * Return encoding charset for http response |
||
58 | * @return string |
||
59 | */ |
||
60 | 12 | public function getCharset() |
|
64 | |||
65 | /** |
||
66 | * @param IRequest $httpRequest |
||
67 | * @param IResponse $httpResponse |
||
68 | */ |
||
69 | public function send(IRequest $httpRequest, IResponse $httpResponse) |
||
78 | } |
||
79 |