1<?php
2
3declare(strict_types = 1);
4
5namespace Elasticsearch\Endpoints;
6
7use Elasticsearch\Endpoints\AbstractEndpoint;
8
9/**
10 * Class Render
11 *
12 * @category Elasticsearch
13 * @package  Elasticsearch\Endpoints
14 * @author   Zachary Tong <zach@elastic.co>
15 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache2
16 * @link     http://elastic.co
17 */
18
19class RenderSearchTemplate extends AbstractEndpoint
20{
21    /**
22     * @return $this
23     */
24    public function setBody($body): RenderSearchTemplate
25    {
26        if (isset($body) !== true) {
27            return $this;
28        }
29
30        $this->body = $body;
31        return $this;
32    }
33
34    public function getURI(): string
35    {
36        $id = $this->id ?? null;
37
38        if (isset($id)) {
39            return "/_render/template/$id";
40        }
41        return "/_render/template";
42    }
43
44    public function getParamWhitelist(): array
45    {
46        return [];
47    }
48
49    public function getBody()
50    {
51        return $this->body;
52    }
53
54    public function getMethod(): string
55    {
56        return isset($this->body) ? 'POST' : 'GET';
57    }
58}
59