|
@@ 241-251 (lines=11) @@
|
| 238 |
|
* |
| 239 |
|
* @return Answer |
| 240 |
|
*/ |
| 241 |
|
public function update($id, $body, array $params = self::QUERY_PARAMS, $serialize = true) |
| 242 |
|
{ |
| 243 |
|
if (!$this->authentication instanceof Authentication) { |
| 244 |
|
throw new \Exception('Authentication is required'); |
| 245 |
|
} |
| 246 |
|
$response = Http::instance()->put( |
| 247 |
|
self::URL . $id . '/edit', array_merge(['body' => $body], $params, $this->authentication->toArray()) |
| 248 |
|
); |
| 249 |
|
|
| 250 |
|
return $serialize === true ? AnswerSerializer::serialize($response) : $response; |
| 251 |
|
} |
| 252 |
|
|
| 253 |
|
/** |
| 254 |
|
* Upvotes an answer. |
|
@@ 368-380 (lines=13) @@
|
| 365 |
|
* |
| 366 |
|
* @return Answer |
| 367 |
|
*/ |
| 368 |
|
public function addOfQuestionId($id, $body, array $params = self::QUERY_PARAMS, $serialize = true) |
| 369 |
|
{ |
| 370 |
|
if (!$this->authentication instanceof Authentication) { |
| 371 |
|
throw new \Exception('Authentication is required'); |
| 372 |
|
} |
| 373 |
|
$response = Http::instance()->post( |
| 374 |
|
'questions/' . $id . '/' . self::URL . 'add', array_merge( |
| 375 |
|
['body' => $body], $params, $this->authentication->toArray() |
| 376 |
|
) |
| 377 |
|
); |
| 378 |
|
|
| 379 |
|
return $serialize === true ? AnswerSerializer::serialize($response) : $response; |
| 380 |
|
} |
| 381 |
|
|
| 382 |
|
/** |
| 383 |
|
* Render an answer given it's body and the question it's on. |
|
@@ 451-461 (lines=11) @@
|
| 448 |
|
* |
| 449 |
|
* @return array|Answer |
| 450 |
|
*/ |
| 451 |
|
public function myAnswers(array $params = self::QUERY_PARAMS, $serialize = true) |
| 452 |
|
{ |
| 453 |
|
if (!$this->authentication instanceof Authentication) { |
| 454 |
|
throw new \Exception('Authentication is required'); |
| 455 |
|
} |
| 456 |
|
$response = Http::instance()->get( |
| 457 |
|
'me/' . self::URL, array_merge($params, $this->authentication->toArray()) |
| 458 |
|
); |
| 459 |
|
|
| 460 |
|
return $serialize === true ? AnswerSerializer::serialize($response) : $response; |
| 461 |
|
} |
| 462 |
|
|
| 463 |
|
/** |
| 464 |
|
* Returns the top 30 answers a user has posted in response to questions with the given tags. |