1 | <?php |
||
15 | class QueryBuilder extends \hiqdev\hiart\AbstractQueryBuilder |
||
16 | { |
||
17 | protected $authHeaders = []; |
||
18 | |||
19 | /** |
||
20 | * This function is for you to provide your authentication. |
||
21 | * @param Query $query |
||
22 | */ |
||
23 | public function buildAuth(Query $query) |
||
24 | { |
||
25 | $auth = $this->db->getAuth(); |
||
26 | if (isset($auth['headerToken'])) { |
||
27 | $this->authHeaders['Authorization'] = 'token ' . $auth['headerToken']; |
||
28 | } |
||
29 | if (isset($auth['headerBearer'])) { |
||
30 | $this->authHeaders['Authorization'] = 'Bearer ' . $auth['headerBearer']; |
||
31 | } |
||
32 | } |
||
33 | |||
34 | public function buildMethod(Query $query) |
||
35 | { |
||
36 | static $defaultMethods = [ |
||
37 | 'get' => 'GET', |
||
38 | 'put' => 'PUT', |
||
39 | 'head' => 'HEAD', |
||
40 | 'post' => 'GET', |
||
41 | 'search' => 'GET', |
||
42 | 'insert' => 'POST', |
||
43 | 'update' => 'PUT', |
||
44 | 'delete' => 'DELETE', |
||
45 | ]; |
||
46 | |||
47 | return isset($defaultMethods[$query->action]) ? $defaultMethods[$query->action] : 'POST'; |
||
48 | } |
||
49 | |||
50 | public function buildUri(Query $query) |
||
54 | |||
55 | public function buildHeaders(Query $query) |
||
56 | { |
||
59 | |||
60 | public function buildProtocolVersion(Query $query) |
||
64 | |||
65 | public function buildQueryParams(Query $query) |
||
69 | |||
70 | public function buildFormParams(Query $query) |
||
74 | |||
75 | public function buildBody(Query $query) |
||
79 | } |
||
80 |