1 | <?php |
||
7 | class HttpfulClient implements HttpInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var bool |
||
11 | */ |
||
12 | protected $hasErrors = false; |
||
13 | |||
14 | /** |
||
15 | * Invoke a GET request. |
||
16 | * |
||
17 | * @param string $endpoint |
||
18 | * @param array $parameters |
||
19 | * |
||
20 | * @return array|string |
||
21 | * |
||
22 | * @throws \Httpful\Exception\ConnectionErrorException |
||
23 | */ |
||
24 | public function get(string $endpoint, array $parameters = []) |
||
31 | |||
32 | /** |
||
33 | * Invoke a POST request. |
||
34 | * |
||
35 | * @param string $endpoint |
||
36 | * @param array $parameters |
||
37 | * |
||
38 | * @return array|string |
||
39 | * |
||
40 | * @throws \Httpful\Exception\ConnectionErrorException |
||
41 | */ |
||
42 | public function post(string $endpoint, array $parameters = []) |
||
50 | |||
51 | /** |
||
52 | * Encode the given array to JSON. If the array would not translate to an |
||
53 | * object, force it. |
||
54 | * |
||
55 | * WORK[etc] expects an object, even if that object would be empty. |
||
56 | * |
||
57 | * @param array $array |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | protected function jsonEncode(array $array): string |
||
69 | |||
70 | /** |
||
71 | * Send the request and check for errors. |
||
72 | * |
||
73 | * @param \Httpful\Request $request |
||
74 | * |
||
75 | * @return array|string |
||
76 | * |
||
77 | * @throws \Httpful\Exception\ConnectionErrorException |
||
78 | */ |
||
79 | protected function send(Request $request) |
||
87 | |||
88 | /** |
||
89 | * Builds the query string for the URL. |
||
90 | * |
||
91 | * @param array $data |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | protected function buildQuery(array $data = []): string |
||
103 | |||
104 | /** |
||
105 | * Returns whether or not errors have occurred. |
||
106 | * |
||
107 | * @return bool |
||
108 | */ |
||
109 | public function hasErrors(): bool |
||
113 | } |
||
114 |