Beispiel #1
0
 function createApp($appName, $orgName)
 {
     Util::throwExceptionIfNullOrBlank($appName, "App Name");
     Util::throwExceptionIfNullOrBlank($orgName, "orgName");
     $objUtil = new Util($this->apiKey, $this->secretKey);
     try {
         $params = array();
         $params['apiKey'] = $this->apiKey;
         $params['version'] = $this->version;
         date_default_timezone_set('UTC');
         $params['timeStamp'] = date("Y-m-d\\TG:i:s") . substr((string) microtime(), 1, 4) . "Z";
         $params['App Name'] = $appName;
         $params['orgName'] = $orgName;
         $signature = urlencode($objUtil->sign($params));
         //die();
         $body = null;
         $body = '{"app42":{"app":}}';
         $params['body'] = $body;
         $params['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $this->url = $this->url;
         $response = RestClient::post($this->url, $params, null, null, $contentType, $accept, $body);
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $response;
 }
 /**
  * Removes all the attributes for a given session id
  *
  * @param sessionId
  *            - The session id for which the attributes has to be removed
  *
  * @return App42Response if removed successfully
  */
 function removeAllAttributes($sessionId)
 {
     Util::throwExceptionIfNullOrBlank($sessionId, "session Id");
     $encodedSessionId = Util::encodeParams($sessionId);
     $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['sessionId'] = $sessionId;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/id/" . $encodedSessionId;
         $response = RestClient::delete($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $sessionResponseObj = new SessionResponseBuilder();
         $sessionObj = $sessionResponseObj->buildResponse($response->getResponse());
         $responseObj->setStrResponse($sessionObj);
         $responseObj->setResponseSuccess(true);
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $responseObj;
 }
 function isActive($testName)
 {
     Util::throwExceptionIfNullOrBlank($testName, "testName");
     $objUtil = new Util($this->apiKey, $this->secretKey);
     try {
         $params = null;
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $signParams['testName'] = $testName;
         $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 . "/isActive/" . $testName;
         $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $abTestRespObj = new ABTestResponseBuilder();
         $abTestObj = $abTestRespObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $abTestObj;
 }
 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;
 }
Beispiel #5
0
 /**
  * Delete the specified Geo points from Cloud.
  *
  * @param storageName
  *            - Unique handler for storage name
  *
  * @return App42Response object containing the name of the storage that has
  *         been deleted
  *
  * @throws App42Exception
  */
 function deleteGeoPoints($geoStorageName, $geoPointsList)
 {
     Util::throwExceptionIfNullOrBlank($geoStorageName, "Geo Storage Name");
     Util::throwExceptionIfNullOrBlank($geoPointsList, "Geo Points List");
     $encodedStorageName = Util::encodeParams($geoStorageName);
     $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);
         if (is_array($geoPointsList)) {
             $string = '{"app42":{ "geo": {"storage":{"points": { "point": ' . json_encode($geoPointsList) . '}}}}}';
         } else {
             $string = '{"app42":{ "geo": {"storage":{"points": { "point": "' . $geoPointsList . '"}}}}}';
         }
         $signParams['geoPoints'] = $string;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/points/" . $encodedStorageName;
         $response = RestClient::delete($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $geoResponseObj = new GeoResponseBuilder();
         $geoObj = $geoResponseObj->buildResponse($response->getResponse());
         $responseObj->setStrResponse($geoObj);
         $responseObj->setResponseSuccess(true);
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $responseObj;
 }
 /**
  * Add or Update preference list on the cloud.
  *
  * @param preferenceDataList
  *            - List of PreferenceData which contains customerId, itemId,
  *            preference
  *
  * @return App42Response object
  */
 function addOrUpdatePreference($preferenceDataList)
 {
     Util::throwExceptionIfNullOrBlank($preferenceDataList, "Preference Data List");
     $responseObj = new App42Response();
     $objUtil = new Util($this->apiKey, $this->secretKey);
     $dataValue = array();
     $preferenceData = new PreferenceData();
     if (is_array($preferenceDataList)) {
         foreach ($preferenceDataList as $arrayValue) {
             $userId = $arrayValue->getUserId();
             $itemId = $arrayValue->getItemId();
             $preference = $arrayValue->getPreference();
             $array = array("UserId" => $userId, "itemId" => $itemId, "preference" => $preference);
             array_push($dataValue, $array);
         }
     } else {
         $userId = $preferenceDataList->getUserId();
         $itemId = $preferenceDataList->getItemId();
         $preference = $preferenceDataList->getPreference();
         $array = array("UserId" => $userId, "itemId" => $itemId, "preference" => $preference);
         array_push($dataValue, $array);
     }
     try {
         $params = null;
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $body = null;
         //$body = '{"app42":{"preferences":{"preference":"' . $preferenceDataList->getUserId() . '","itemId":"' . $preferenceDataList->getItemId() . '","preference":"' . $preferenceDataList->getPreference() . '"}}}}';
         $body = '{"app42":{"preferences":{"preference":' . json_encode($dataValue) . '}}}';
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/addOrUpdatePreference";
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $responseObj->setStrResponse($response);
         $responseObj->setResponseSuccess(true);
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $responseObj;
 }
Beispiel #7
0
 function createUserWithProfile($uName, $pwd, $emailAddress, Profile $profile)
 {
     Util::throwExceptionIfNullOrBlank($uName, "User Name");
     Util::throwExceptionIfNullOrBlank($pwd, "Password");
     Util::throwExceptionIfNullOrBlank($emailAddress, "Email Address");
     Util::throwExceptionIfEmailNotValid($emailAddress, "Email Address");
     Util::throwExceptionIfNullOrBlank($profile, "Profile Data");
     $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);
         $body = null;
         $body = '{"app42":{"user":{"userName":"******","password":"******","email":"' . $emailAddress . '", "profileData":{"firstName":"' . $profile->getFirstName() . '","lastName":"' . $profile->getLastName() . '","sex":"' . $profile->getSex() . '","mobile":"' . $profile->getMobile() . '","line1":"' . $profile->getLine1() . '","line2":"' . $profile->getLine2() . '","city":"' . $profile->getCity() . '","state":"' . $profile->getState() . '","country":"' . $profile->getCountry() . '","pincode":"' . $profile->getPincode() . '","homeLandLine":"' . $profile->getHomeLandLine() . '","officeLandLine":"' . $profile->getOfficeLandLine() . '","dateOfBirth":"' . (date("Y-m-d\\TG:i:s", strtotime($profile->getDateOfBirth())) . substr((string) microtime(), 1, 4) . "Z") . '"}}}}';
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         //CONTENT_TYPE;
         $accept = $this->accept;
         //ACCEPT;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/userwithprofile";
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $userResponseObj = new UserResponseBuilder();
         $userObj = $userResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $userObj;
 }
 /**
  * Deducts the score from users account for a particular Game
  *
  * @param gameName
  *            - Name of the game for which scores have to be deducted
  * @param gameUserName
  *            - The user for whom scores have to be deducted
  * @param gameScore
  *            - The scores that have to be deducted
  *
  * @return Game object containing the scores that has been deducted
  */
 function deductScore($gameName, $gameUserName, $gameScore)
 {
     Util::throwExceptionIfNullOrBlank($gameName, "Game Name");
     Util::throwExceptionIfNullOrBlank($gameUserName, "User Name");
     Util::throwExceptionIfNullOrBlank($gameScore, "Score");
     $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);
         $body = null;
         $body = '{"app42":{"game":{"name":"' . $gameName . '", "scores":{"score":{"userName":"******","value":"' . $gameScore . '"}}}}}';
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/deduct";
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $gameResponseObj = new GameResponseBuilder();
         $gameObj = $gameResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $gameObj;
 }
 function uploadFileForFriends($name, $userName, $filePath, $fileType, $description)
 {
     Util::throwExceptionIfNullOrBlank($name, "File Name");
     Util::throwExceptionIfNullOrBlank($userName, "User Name");
     Util::throwExceptionIfNullOrBlank($filePath, "FilePath");
     Util::throwExceptionIfNullOrBlank($fileType, "UploadFileType");
     Util::throwExceptionIfNullOrBlank($description, "Description");
     $encodedUserName = Util::encodeParams($userName);
     $objUtil = new Util($this->apiKey, $this->secretKey);
     //$file = fopen($filePath, r);
     if (!file_exists($filePath)) {
         throw new App42Exception("The file with the name '{$filePath}' not found ");
     }
     $body = null;
     try {
         $params = null;
         $uploadTypeObj = new UploadFileType();
         if ($uploadTypeObj->isAvailable($fileType) == "null") {
             throw new App42Exception("The file with  type '{$fileType}' does not Exist ");
         }
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $postParams = array();
         $postParams['name'] = $name;
         $postParams['userName'] = $userName;
         $postParams['type'] = $fileType;
         $postParams['description'] = $description;
         $params = array_merge($postParams, $signParams);
         $signature = urlencode($objUtil->sign($params));
         //die();
         $params['uploadFile'] = "@" . $filePath;
         $headerParams['signature'] = $signature;
         //CONTENT_TYPE == "multipart/form-data"
         $contentType = "multipart/form-data";
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/" . "friendsAll/" . $encodedUserName;
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $uploadResponseObj = new UploadResponseBuilder();
         $uploadObj = $uploadResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $uploadObj;
 }
 function getUsersWithScoreRange($gameName, $minScore, $maxScore)
 {
     Util::throwExceptionIfNullOrBlank($gameName, "Game Name");
     $encodedGameName = Util::encodeParams($gameName);
     $encodedMinScore = Util::encodeParams($minScore);
     $encodedMaxScore = Util::encodeParams($maxScore);
     $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['name'] = $gameName;
         $signParams['minScore'] = $minScore;
         $signParams['maxScore'] = $maxScore;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/" . $encodedGameName . "/range/" . $minScore . "/" . $maxScore;
         $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $gameResponseObj = new GameResponseBuilder();
         $gameObj = $gameResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $gameObj;
 }
Beispiel #11
0
 function updatePhoto($userName, $albumName, $photoName, $photoDescription, $path)
 {
     Util::throwExceptionIfNullOrBlank($userName, "User Name");
     Util::throwExceptionIfNullOrBlank($albumName, "Album Name");
     Util::throwExceptionIfNullOrBlank($photoName, "Photo Name");
     Util::throwExceptionIfNullOrBlank($photoDescription, "Description");
     Util::throwExceptionIfNullOrBlank($path, "Path");
     Util::throwExceptionIfNotValidImageExtension($path, "Photo Path");
     $encodedUserName = Util::encodeParams($userName);
     $objUtil = new Util($this->apiKey, $this->secretKey);
     if (!file_exists($path)) {
         throw new App42Exception("File Not Found");
     }
     try {
         $params = null;
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $postParams = array();
         $postParams['userName'] = $userName;
         $postParams['albumName'] = $albumName;
         $postParams['name'] = $photoName;
         $postParams['description'] = $photoDescription;
         $params = array_merge($postParams, $signParams);
         $signature = urlencode($objUtil->sign($params));
         //die();
         $params['imageFile'] = "@" . $path;
         $headerParams['signature'] = $signature;
         $contentType = "multipart/form-data";
         $body = null;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/update/" . $encodedUserName;
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $photoResponseObj = new AlbumResponseBuilder();
         $photoObj = $photoResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $photoObj;
 }
Beispiel #12
0
 /**
  * This Service is used to send Emails. This service can be used by app to send mail to one or multiple recipients.
  *
  * @params sendTo
  *            - The email ids to which the email has to be sent. Email can
  *            be sent to multiple email ids. Multiple email ids can be
  *            passed using comma as the separator e.g. sid@shephertz.com,
  *            info@shephertz.com
  * @params sendSubject
  *            - Subject of the Email which to be sent
  * @params sendMsg
  *            - Email body which has to be sent
  * @params fromEmail
  *            - The Email Id using which the mail(s) has to be sent
  * @params emailMime
  *            - MIME Type to be used for sending mail. EmailMIME available
  *            options are PLAIN_TEXT_MIME_TYPE or HTML_TEXT_MIME_TYPE
  *
  * @return Email object containing all the details used for sending mail
  */
 function sendMail($fromEmail, $sendTo, $sendSubject, $sendMsg, $emailMIME)
 {
     Util::throwExceptionIfNullOrBlank($fromEmail, "Email Id");
     Util::throwExceptionIfNullOrBlank($sendTo, "Send To");
     Util::throwExceptionIfNullOrBlank($sendSubject, "Send Subject");
     Util::throwExceptionIfNullOrBlank($sendMsg, "Send Message");
     Util::throwExceptionIfNullOrBlank($emailMIME, "EmailMIME");
     $objUtil = new Util($this->apiKey, $this->secretKey);
     try {
         $params = null;
         $emailMIMETypeObj = new EmailMIME();
         if ($emailMIMETypeObj->isAvailable($emailMIME) == "null") {
             throw new App42Exception("The EmailMIME with  type '{$emailMIME}' does not Exist ");
         }
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $body = null;
         $body = '{"app42":{"email":{"emailId":"' . $fromEmail . '","to":"' . $sendTo . '","subject":"' . $sendSubject . '","msg":"' . $sendMsg . '","mimeType":"' . $emailMIME . '"}}}';
         $signParams['body'] = $body;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL;
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $emailResponseObj = new EmailResponseBuilder();
         $emailObj = $emailResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $emailObj;
 }
 /**
  * Converts the format of the image. Returns the original image url and converted image url.
  * Images are stored on the cloud and can be accessed through the urls
  * Conversion is done based on the formatToConvert provided
  *
  * @param name
  *            - Name of the image to convert
  * @param imagePath
  *            - Path of the local file to convert
  * @param formatToConvert
  *            - To which file needs to be converted
  * @return Image object containing urls for the original and converted
  *          images
  *
  * @throws App42Exception
  *
  */
 function convertFormat($name, $imagePath, $formatToConvert)
 {
     Util::throwExceptionIfNullOrBlank($name, "Name");
     Util::throwExceptionIfNullOrBlank($imagePath, "Image Path");
     Util::throwExceptionIfNotValidImageExtension($imagePath, "imagePath");
     Util::throwExceptionIfNullOrBlank($formatToConvert, "formatToConvert");
     $objUtil = new Util($this->apiKey, $this->secretKey);
     //$file = fopen($filePath, r);
     if (!file_exists($imagePath)) {
         throw new App42Exception(" File " . $imagePath . " does not exist");
     }
     //$file = new File($filePath);
     //if(!file_exists($file)){
     //throw Exception
     //}
     try {
         $params = null;
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         $postParams = array();
         $postParams['name'] = $name;
         $postParams['formatToConvert'] = $formatToConvert;
         $params = array_merge($postParams, $signParams);
         $signature = urlencode($objUtil->sign($params));
         //die();
         $params['imageFile'] = "@" . $imagePath;
         $headerParams['signature'] = $signature;
         //CONTENT_TYPE == "multipart/form-data"
         $contentType = "multipart/form-data";
         $body = null;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/convertformat";
         $response = RestClient::post($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams);
         $imageResponseObj = new ImageProcessorResponseBuilder();
         $imageObj = $imageResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $imageObj;
 }
Beispiel #14
0
 /**
  * History of Carts and Payments for a User. It gives all the carts which
  * are in AUTHORIZED, DECLINED, PENDING state.
  *
  * @params userId
  *            - User Id for whom payment history has to be fetched
  *
  * @returns List containing Cart objects. Payment history can be retrieved
  *          from individual Cart object.
  */
 function getPaymentHistoryByUser($userId)
 {
     Util::throwExceptionIfNullOrBlank($userId, "User Id");
     $encodedUserId = Util::encodeParams($userId);
     $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['userId'] = $userId;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/payment/history/" . $encodedUserId;
         $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $cartResponseObj = new CartResponseBuilder();
         $cartObj = $cartResponseObj->buildArrayResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $cartObj;
 }
 function getAllDevicesOfUser($userName)
 {
     Util::throwExceptionIfNullOrBlank($userName, "User Name");
     $encodedUserName = Util::encodeParams($userName);
     $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['userName'] = $userName;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/getAllDevices/" . $encodedUserName;
         $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $pushResponseObj = new PushNotificationResponseBuilder();
         $pushObj = $pushResponseObj->buildArrayResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $pushObj;
 }
Beispiel #16
0
 public function setAdminKey($adminKey)
 {
     Util::throwExceptionIfNullOrBlank(adminKey, "adminKey");
     $this->adminKey = $adminKey;
 }
 function getFacebookProfilesFromIds($facebookIds)
 {
     Util::throwExceptionIfNullOrBlank($facebookIds, "FacebookIds");
     $objUtil = new Util($this->apiKey, $this->secretKey);
     $body = null;
     try {
         $params = null;
         $headerParams = array();
         $queryParams = array();
         $signParams = $this->populateSignParams();
         $metaHeaders = $this->populateMetaHeaderParams();
         $headerParams = array_merge($signParams, $metaHeaders);
         if (is_array($facebookIds)) {
             $headerParams['userList'] = json_encode($facebookIds);
         } else {
             $headerParams['userList'] = $facebookIds;
         }
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/facebook/ids";
         $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $socialResponseObj = new SocialResponseBuilder();
         $socialObj = $socialResponseObj->buildResponse($response->getResponse());
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $socialObj;
 }
 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;
 }
Beispiel #19
0
 function deleteUser($gameName)
 {
     Util::throwExceptionIfNullOrBlank($gameName, "Game Name");
     $encodedUserName = Util::encodeParams($gameName);
     $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['gameName'] = $gameName;
         $signature = urlencode($objUtil->sign($signParams));
         //die();
         $headerParams['signature'] = $signature;
         $contentType = $this->content_type;
         $accept = $this->accept;
         $baseURL = $this->url;
         $baseURL = $baseURL . "/delete/" . $encodedUserName;
         $response = RestClient::delete($baseURL, $params, null, null, $contentType, $accept, $headerParams);
         $responseObj->setStrResponse($response->getResponse());
         $responseObj->setResponseSuccess(true);
     } catch (App42Exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new App42Exception($e);
     }
     return $responseObj;
 }
Beispiel #20
0
 public function setEvent($eventName)
 {
     $this->event = $eventName;
     Util::throwExceptionIfNullOrBlank($eventName, "eventName");
     $this->info($eventName, "_App42_Event");
 }