/** * Returns a single message by unique id * * @throws ZForge_LogBank_Exception if API Key is invalid * @param string $apiKey the api key to authenticate the message * @param string $message_uid the message uid to return * @return ZForge_LogBank_Server_Message|null */ public function readMessage($apiKey, $message_uid) { if (!$this->verifyApiKey($apiKey)) { require_once 'ZForge/LogBank/Exception.php'; throw new ZForge_LogBank_Exception('Provided API Key is invalid'); } $doc = $this->_couch->docOpen($message_uid, $options); if (!is_null($doc) && $doc->apiKey == $apiKey) { $msg = new ZForge_LogBank_Server_Message(); $msg->setId($doc->getId()); foreach ($doc->toArray() as $key => $value) { switch ($key) { #standard fields, write directly case 'apiKey': //no break //no break case 'appId': //no break //no break case 'priority': //no break //no break case 'description': //no break //no break case 'created': $msg->{$key} = $value; break; #ignored fields, skip #ignored fields, skip case 'fields': //duplicated 'fields' array bug //duplicated 'fields' array bug case 'type': //a system value continue; break; #non-standard fields, add to custom fields #non-standard fields, add to custom fields default: $msg->fields[$key] = $value; } } return $msg; } return null; }