@@ 229-239 (lines=11) @@ | ||
226 | * |
|
227 | * @return Answer |
|
228 | */ |
|
229 | public function update($id, $body, array $params = self::QUERY_PARAMS, $serialize = true) |
|
230 | { |
|
231 | if (!$this->authentication instanceof Authentication) { |
|
232 | throw new \Exception('Authentication is required'); |
|
233 | } |
|
234 | $response = Http::instance()->put( |
|
235 | self::URL . $id . '/edit', array_merge(['body' => $body], $params, $this->authentication->toArray()) |
|
236 | ); |
|
237 | ||
238 | return $serialize === true ? AnswerSerializer::serialize($response) : $response; |
|
239 | } |
|
240 | ||
241 | /** |
|
242 | * Upvotes an answer. |
|
@@ 350-362 (lines=13) @@ | ||
347 | * |
|
348 | * @return Answer |
|
349 | */ |
|
350 | public function addOfQuestionId($id, $body, array $params = self::QUERY_PARAMS, $serialize = true) |
|
351 | { |
|
352 | if (!$this->authentication instanceof Authentication) { |
|
353 | throw new \Exception('Authentication is required'); |
|
354 | } |
|
355 | $response = Http::instance()->post( |
|
356 | 'questions/' . $id . '/' . self::URL . 'add', array_merge( |
|
357 | ['body' => $body], $params, $this->authentication->toArray() |
|
358 | ) |
|
359 | ); |
|
360 | ||
361 | return $serialize === true ? AnswerSerializer::serialize($response) : $response; |
|
362 | } |
|
363 | ||
364 | /** |
|
365 | * Render an answer given it's body and the question it's on. |