From 45fe5f4156619305b962e6cff51520838a92134d Mon Sep 17 00:00:00 2001 From: aymm Date: Wed, 10 Mar 2021 20:10:09 +0000 Subject: [PATCH] Added support for broadsword polls --- src/APnutI.php | 9 ++++++++- src/Entities/Poll.php | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/APnutI.php b/src/APnutI.php index 72775bb..4e7c07a 100644 --- a/src/APnutI.php +++ b/src/APnutI.php @@ -10,6 +10,7 @@ use APnutI\Exceptions\NotFoundException; use APnutI\Exceptions\NotAuthorizedException; use APnutI\Exceptions\HttpPnutException; use APnutI\Exceptions\HttpPnutRedirectException; +use APnutI\Exceptions\NotSupportedPollException; use APnutI\Meta; use Monolog\Logger; use Monolog\Handler\RotatingFileHandler; @@ -458,7 +459,13 @@ class APnutI public function getPoll(int $poll_id): Poll { - return new Poll($this->get('/polls/' . $poll_id)); + $res = $this->get('/polls/' . $poll_id); + try { + return new Poll($res); + } catch (NotSupportedPollException $e) { + $this->logger->error('Poll not supported: '.json_encode($res)); + throw $e; + } } public function getAuthorizedUser(): User diff --git a/src/Entities/Poll.php b/src/Entities/Poll.php index 123440d..2c00d04 100644 --- a/src/Entities/Poll.php +++ b/src/Entities/Poll.php @@ -24,7 +24,8 @@ class Poll protected static array $poll_types = [ 'general.poll', 'net.unsweets.beta', - 'io.pnut.core.poll' + 'io.pnut.core.poll', + 'io.broadsword.poll' ]; public function __construct(array $data)