Beispiel #1
0
 /**
  * Fetches the count of all games for the App
  *
  * @return App42Response object containing count of all the Game for the App
  */
 function getAllGamesCount()
 {
     $objUtil = new Util($this->apiKey, $this->secretKey);
     try {
         $params = null;
         $gameObj = new App42Response();
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/count";
         $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $gameObj->setStrResponse($response->getResponse());
         $gameObj->setResponseSuccess(true);
         $gameResponseObj = new GameResponseBuilder();
         $gameObj->setTotalRecords($gameResponseObj->getTotalRecords($response->getResponse()));
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $gameObj;
 }
 function getReviewsCountByItemAndRating($itemId, $rating)
 {
     Util::throwExceptionIfNullOrBlank($itemId, "Item Id");
     Util::throwExceptionIfNullOrBlank($rating, "Rating");
     $encodedItemId = Util::encodeParams($itemId);
     $encodedRating = Util::encodeParams($rating);
     $responseObj = new App42Response();
     $objUtil = new Util($this->apiKey, $this->secretKey);
     try {
         $params = null;
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $signParams['itemId'] = $itemId;
         $signParams['rating'] = $rating;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/item" . "/" . $encodedItemId . "/rating" . "/" . $encodedRating;
         $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $responseObj->setStrResponse($response->getResponse());
         $responseObj->setResponseSuccess(true);
         $reviewResponseObj = new ReviewResponseBuilder();
         $responseObj->setTotalRecords($reviewResponseObj->getTotalRecords($response->getResponse()));
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $responseObj;
 }
 /**
  * Gets the count of all the subscribed channels of a particular user.
  * @param  $userName - Name of the user for which you want to get a count of the subscribed channels.
  * @return App42Response
  * @throws App42Exception
  */
 function getUserSubscribedChannelsCount($userName)
 {
     Util::throwExceptionIfNullOrBlank($userName, "UserName");
     $objUtil = new Util($this->apiKey, $this->secretKey);
     $pushObj = new App42Response();
     try {
         $params = null;
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $signParams['userName'] = $userName;
         $queryParams['userName'] = $userName;
         $params = array_merge($queryParams, $signParams);
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/count/userchannels";
         $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $pushObj->setStrResponse($response->getResponse());
         $pushObj->setResponseSuccess(true);
         $pushResponseObj = new PushNotificationResponseBuilder();
         $pushObj->setTotalRecords($pushResponseObj->getTotalRecords($response->getResponse()));
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $pushObj;
 }
 function getCountByQuery($dbName, $collectionName, $query)
 {
     Util::throwExceptionIfNullOrBlank($dbName, "DataBase Name");
     Util::throwExceptionIfNullOrBlank($collectionName, "Collection Name");
     Util::throwExceptionIfNullOrBlank($query, "query");
     $encodedDbName = Util::encodeParams($dbName);
     $encodedCollectionName = Util::encodeParams($collectionName);
     $responseObj = new App42Response();
     $objUtil = new Util($this->apiKey, $this->secretKey);
     $queryObject = null;
     if ($query instanceof JSONObject) {
         $queryObject = array();
         array_push($queryObject, $query);
     } else {
         $queryObject = $query;
     }
     try {
         $params = null;
         $storageObj = new App42Response();
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $signParams['dbName'] = $dbName;
         $signParams['collectionName'] = $collectionName;
         $signParams['jsonQuery'] = json_encode($queryObject);
         $queryParams['jsonQuery'] = json_encode($queryObject);
         $params = array_merge($queryParams, $signParams);
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/findDocsByQuery" . "/dbName/" . $encodedDbName . "/collectionName/" . $encodedCollectionName;
         $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $storageResponseObj = new StorageResponseBuilder();
         $storageObj = $storageResponseObj->buildResponse($response->getResponse());
         $totalRecord = $storageObj->getRecordCount();
         $body = '{"app42":{"response":{"totalRecords":"' . $totalRecord . '"}}}';
         $responseObj->setStrResponse($body);
         $responseObj->setResponseSuccess(true);
         $responseObj->setTotalRecords($totalRecord);
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $responseObj;
 }
 /**
  * Fetches count of all items for a Catalogue and Category
  *
  * @params catalogueName
  *            - Name of the Catalogue from which count of item has to be
  *            fetched
  * @params categoryName
  *            - Name of the Category from which count of item has to be
  *            fetched
  *
  * @returns App42Response object
  */
 function getItemsCountByCategory($catalogueName, $categoryName)
 {
     Util::throwExceptionIfNullOrBlank($catalogueName, "Catalogue Name");
     Util::throwExceptionIfNullOrBlank($categoryName, "Catagory Name");
     $encodedCatName = Util::encodeParams($catalogueName);
     $encodedCategoryName = Util::encodeParams($categoryName);
     $objUtil = new Util($this->apiKey, $this->secretKey);
     try {
         $params = null;
         $catalogueObj = new App42Response();
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $signParams['catalogueName'] = $catalogueName;
         $signParams['categoryName'] = $categoryName;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/" . $encodedCatName . "/" . $encodedCategoryName . "/count";
         $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $catalogueObj->setStrResponse($response->getResponse());
         $catalogueObj->setResponseSuccess(true);
         $catalogueResponseObj = new CatalogueResponseBuilder();
         $catalogueObj->setTotalRecords($catalogueResponseObj->getTotalRecords($response->getResponse()));
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $catalogueObj;
 }
 function getActivityCountByUser($userId)
 {
     Util::throwExceptionIfNullOrBlank($userId, "UserId");
     $encodedUserId = Util::encodeParams($userId);
     $objUtil = new Util($this->apiKey, $this->secretKey);
     $bravoObj = new App42Response();
     try {
         $params = null;
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $signParams['userId'] = $userId;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/activity/userId/" . $encodedUserId . "/count";
         $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $bravoObj->setStrResponse($response->getResponse());
         $bravoObj->setResponseSuccess(true);
         $bravoResponseObj = new BravoBoardResponseBuilder();
         $bravoObj->setTotalRecords($bravoResponseObj->getTotalRecords($response->getResponse()));
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $bravoObj;
 }
 /**
  * Get the count of files based on file type.
  *
  * @params uploadFileType
  *            - Type of the file e.g. Upload.AUDIO, Upload.XML etc.
  *
  * @return App42Response object
  */
 function getFilesCountByType($uploadFileType)
 {
     Util::throwExceptionIfNullOrBlank($uploadFileType, "UploadFileType");
     $encodedUploadFileType = Util::encodeParams($uploadFileType);
     $objUtil = new Util($this->apiKey, $this->secretKey);
     try {
         $params = null;
         $responseObj = new App42Response();
         $uploadTypeObj = new UploadFileType();
         if ($uploadTypeObj->isAvailable($uploadFileType) == "null") {
             throw new App42Exception("The file with  type '{$uploadFileType}' does not Exist ");
         }
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $signParams['type'] = $uploadFileType;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/type/" . $encodedUploadFileType . "/count";
         $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $responseObj->setStrResponse($response->getResponse());
         $responseObj->setResponseSuccess(true);
         $uploadResponseObj = new UploadResponseBuilder();
         $responseObj->setTotalRecords($uploadResponseObj->getTotalRecords($response->getResponse()));
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $responseObj;
 }
Beispiel #8
0
 /**
  * Fetch count of log messages based on Date range
  *
  * @param startDate
  *            - Start date from which the count of log messages have to be
  *            fetched
  * @param endDate
  *            - End date upto which the count of log messages have to be
  *            fetched
  *
  * @return App42Response object containing count of fetched messages
  */
 function fetchLogCountByDateRange($startDate, $endDate)
 {
     Util::throwExceptionIfNullOrBlank($startDate, "Start Date");
     Util::throwExceptionIfNullOrBlank($endDate, "End Date");
     $validateStartDate = Util::validateDate($startDate);
     $validateEndDate = Util::validateDate($endDate);
     $encodedStartDate = Util::encodeParams($startDate);
     $encodedEndDate = Util::encodeParams($endDate);
     $objUtil = new Util($this->apiKey, $this->secretKey);
     try {
         $params = null;
         $strStartDate = date("Y-m-d\\TG:i:s", strtotime($startDate)) . substr((string) microtime(), 1, 4) . "Z";
         $strEndDate = date("Y-m-d\\TG:i:s", strtotime($endDate)) . substr((string) microtime(), 1, 4) . "Z";
         $logObj = new App42Response();
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $signParams['startDate'] = $strStartDate;
         $signParams['endDate'] = $strEndDate;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/startDate/" . $strStartDate . "/endDate/" . $strEndDate . "/count";
         $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $logObj->setStrResponse($response->getResponse());
         $logObj->setResponseSuccess(true);
         $logResponseObj = new LogResponseBuilder();
         $logObj->setTotalRecords($logResponseObj->getTotalRecords($response->getResponse()));
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $logObj;
 }