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