@@ 251-261 (lines=11) @@ | ||
248 | * |
|
249 | * @return Answer |
|
250 | */ |
|
251 | public function update($id, $body, array $params = self::QUERY_PARAMS, $serialize = true) |
|
252 | { |
|
253 | if (!$this->authentication instanceof Authentication) { |
|
254 | throw new \Exception('Authentication is required'); |
|
255 | } |
|
256 | $response = HttpClient::instance()->put( |
|
257 | self::URL . $id . '/edit', array_merge(['body' => $body], $params, $this->authentication->toArray()) |
|
258 | ); |
|
259 | ||
260 | return $serialize === true ? AnswerSerializer::serialize($response) : $response; |
|
261 | } |
|
262 | ||
263 | /** |
|
264 | * Upvotes an answer. |
|
@@ 378-390 (lines=13) @@ | ||
375 | * |
|
376 | * @return Answer |
|
377 | */ |
|
378 | public function addOfQuestionId($id, $body, array $params = self::QUERY_PARAMS, $serialize = true) |
|
379 | { |
|
380 | if (!$this->authentication instanceof Authentication) { |
|
381 | throw new \Exception('Authentication is required'); |
|
382 | } |
|
383 | $response = HttpClient::instance()->post( |
|
384 | 'questions/' . $id . '/' . self::URL . 'add', array_merge( |
|
385 | ['body' => $body], $params, $this->authentication->toArray() |
|
386 | ) |
|
387 | ); |
|
388 | ||
389 | return $serialize === true ? AnswerSerializer::serialize($response) : $response; |
|
390 | } |
|
391 | ||
392 | /** |
|
393 | * Render an answer given it's body and the question it's on. |