public function __construct(ServerMessage $ircMessage, $commandPrefix) { if (!$ircMessage instanceof ServerMessage) { throw new \InvalidArgumentException('The provided argument is not an instance of ServerMessage.'); } if ($ircMessage->getCommand() != 'PRIVMSG') { throw new \InvalidArgumentException('The provided message is not a PRIVMSG command.'); } $this->message = $ircMessage; $this->prefix = (string) $commandPrefix; }
/** * Get the last submission status of an Instant Article. * * @param string|null $articleID the article ID * @return InstantArticleStatus */ public function getLastSubmissionStatus($articleID) { if (!$articleID) { return InstantArticleStatus::notFound(); } Type::enforce($articleID, Type::STRING); // Get the latest import status of this article $response = $this->facebook->get($articleID . '?fields=most_recent_import_status'); $articleStatus = $response->getGraphNode()->getField('most_recent_import_status'); $messages = array(); if (isset($articleStatus['errors'])) { foreach ($articleStatus['errors'] as $error) { $messages[] = ServerMessage::fromLevel($error['level'], $error['message']); } } return InstantArticleStatus::fromStatus($articleStatus['status'], $messages); }