@@ 57-75 (lines=19) @@ | ||
54 | * |
|
55 | * @throws Exception |
|
56 | */ |
|
57 | public function get(int $id) |
|
58 | { |
|
59 | if (empty($id)) { |
|
60 | throw new InvalidArgumentException('Id cannot be empty'); |
|
61 | } |
|
62 | ||
63 | $response = $this->httpGet(sprintf('/v1/tweets/%d', $id)); |
|
64 | ||
65 | if (!$this->hydrator) { |
|
66 | return $response; |
|
67 | } |
|
68 | ||
69 | // Use any valid status code here |
|
70 | if ($response->getStatusCode() !== 200) { |
|
71 | $this->handleErrors($response); |
|
72 | } |
|
73 | ||
74 | return $this->hydrator->hydrate($response, TweetModel::class); |
|
75 | } |
|
76 | ||
77 | /** |
|
78 | * @param string $message |
|
@@ 179-197 (lines=19) @@ | ||
176 | * |
|
177 | * @throws Exception |
|
178 | */ |
|
179 | public function delete(int $id) |
|
180 | { |
|
181 | if (empty($id)) { |
|
182 | throw new InvalidArgumentException('Id cannot be empty'); |
|
183 | } |
|
184 | ||
185 | $response = $this->httpDelete(sprintf('/v1/tweets/%d', $id)); |
|
186 | ||
187 | if (!$this->hydrator) { |
|
188 | return $response; |
|
189 | } |
|
190 | ||
191 | // Use any valid status code here |
|
192 | if ($response->getStatusCode() !== 200) { |
|
193 | $this->handleErrors($response); |
|
194 | } |
|
195 | ||
196 | return $this->hydrator->hydrate($response, TweetDeleted::class); |
|
197 | } |
|
198 | } |
|
199 |
@@ 31-49 (lines=19) @@ | ||
28 | * |
|
29 | * @throws Exception |
|
30 | */ |
|
31 | public function get(string $username, array $params = []) |
|
32 | { |
|
33 | if (empty($username)) { |
|
34 | throw new InvalidArgumentException('Username cannot be empty'); |
|
35 | } |
|
36 | ||
37 | $response = $this->httpGet(sprintf('/v1/stats/%s', rawurlencode($username)), $params); |
|
38 | ||
39 | if (!$this->hydrator) { |
|
40 | return $response; |
|
41 | } |
|
42 | ||
43 | // Use any valid status code here |
|
44 | if ($response->getStatusCode() !== 200) { |
|
45 | $this->handleErrors($response); |
|
46 | } |
|
47 | ||
48 | return $this->hydrator->hydrate($response, StatModel::class); |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * @param array $params |