コード例 #1
0
 /**
  * Gets a Message
  * @param UUID $messageId
  * @return Message|HttpResponse|null
  * @throws ErrorException
  */
 public function getMessage($messageId)
 {
     $resource = "/messages/";
     if (is_null($messageId)) {
         throw new ErrorException("Parameter 'messageId' cannot be null");
     } elseif (!CommonUtil::is_uuid($messageId)) {
         throw new ErrorException("Parameter 'messageId' must be a valid UUID");
     }
     try {
         $resource .= $messageId;
         $response = $this->httpClient->get($resource);
         if ($response instanceof HttpResponse) {
             if ($response->getStatus() === HttpStatusCode::HTTP_OK) {
                 $json = JsonHelper::getJson($response->getBody());
                 if (isset($json)) {
                     return new Message($json);
                 }
             } else {
                 return $response;
             }
         }
     } catch (Exception $exc) {
         echo $exc->getTraceAsString();
     }
     return null;
 }
コード例 #2
0
 /**
  * Updates the details of an existing content media.
  * @param UUID $mediaId The content media
  * @param MediaInfo $mediaInfo The content media details
  * @return HttpResponse|ContentMedia|null
  * @throws ErrorException
  */
 public function updateContentMedia($mediaId, $mediaInfo = null)
 {
     $resource = "/media/";
     if (is_null($mediaId)) {
         throw new ErrorException("Parameter 'mediaId' cannot be null");
     } elseif (!CommonUtil::is_uuid($mediaId)) {
         throw new ErrorException("Parameter 'mediaId' must be a valid UUID");
     }
     if (!is_null($mediaInfo) && !$mediaInfo instanceof MediaInfo) {
         throw new ErrorException("Parameter 'mediaInfo' cannot be null and must be an instance of MediaInfo.");
     }
     try {
         $resource .= $mediaId;
         // Set the mediainfo data
         $params["ContentName"] = $mediaInfo->contentName;
         $params["LibraryId"] = $mediaInfo->libraryId;
         $params["DestinationFolder"] = $mediaInfo->destinationFolder;
         $params["Preference"] = $mediaInfo->preference;
         $params["Width"] = $mediaInfo->width;
         $params["Height"] = $mediaInfo->height;
         $params["DrmProtect"] = $mediaInfo->drmProtect;
         $params["Streamable"] = $mediaInfo->streamable;
         $params["DisplayText"] = $mediaInfo->displayText;
         $params["ContentText"] = $mediaInfo->contentText;
         $params["Tags"] = "";
         // set the medainfo tags
         if (!is_null($mediaInfo->tags) && is_array($mediaInfo->tags) && count($mediaInfo->tags) > 0) {
             $params["Tags"] = JsonHelper::toJson($mediaInfo->tags);
         }
         $response = $this->httpClient->put($resource, $params);
         if ($response instanceof HttpResponse) {
             if ($response->getStatus() === HttpStatusCode::HTTP_OK) {
                 $json = JsonHelper::getJson($response->getBody());
                 if (isset($json)) {
                     return new ContentMedia($json);
                 }
             } else {
                 return $response;
             }
         }
     } catch (Exception $ex) {
         $ex->getTraceAsString();
     }
     return null;
 }