public function test_put() { global $TEST_SERVER_URL; $api = new RestClient(); $result = $api->put($TEST_SERVER_URL, array('foo' => ' bar', 'baz' => 1)); $response_json = $result->decode_response(); $this->assertEquals('PUT', $response_json->SERVER->REQUEST_METHOD); $this->assertEquals("foo=+bar&baz=1", $response_json->body); }
/** * @method * * Checkin document/file * * @name Checkin * @label Checkin document/file * * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco * @param string | $docUid | Document Uid * @param string | $comments | Comments * @param string | $user | Valid Admin username to connect to Alfresco server * @param string | $pwd | Valid Admin password to connect to Alfresco server * * @return string | $result | Response | * */ function checkIn($alfrescoServerUrl, $docUid, $comments, $user = "", $pwd = "") { $alfresco_url = "{$alfrescoServerUrl}/s/cmis/pwc/i/{$docUid}?checkin=true&checkinComment={$comments}"; $xmlData = array(); $xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom"/>'; $alfresco_exec = RestClient::put($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml"); $alfrescoMessage = $alfresco_exec->getResponseMessage(); if ($alfrescoMessage === 'OK') { return "The Document has been Checkedin"; } elseif ($alfrescoMessage === 'Internal Server Error') { return "Please enter a Valid Document Id"; } else { return $alfrescoMessage; } }
function clearAllBadgeCount($userName, $deviceToken) { Util::throwExceptionIfNullOrBlank($userName, "User Name"); Util::throwExceptionIfNullOrBlank($deviceToken, "Device Token"); $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":{"push":{"userName":"******","deviceToken":"' . $deviceToken . '","increment":"' . 0 . '"}}}'; $signParams['body'] = $body; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/resetPushBadgeforDevice"; $response = RestClient::put($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams); $pushResponseObj = new PushNotificationResponseBuilder(); $pushObj = $pushResponseObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $pushObj; }
/** * Invalidate a session based on the session id. All the attributes store in * the session will be lost. * * @param sessionId * - The session id for which the session has to be invalidated. * * @return App42Response if invalidated successfully */ function invalidate($sessionId) { Util::throwExceptionIfNullOrBlank($sessionId, "session Id"); $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":{"session":{"id":"' . $sessionId . '"}}}'; $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::put($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams); $sessionResponseObj = new SessionResponseBuilder(); $sessionObj = $sessionResponseObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $sessionObj; }
function unblockUser($userName, $buddyName) { Util::throwExceptionIfNullOrBlank($userName, "UserName"); Util::throwExceptionIfNullOrBlank($buddyName, "BuddyName"); $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":{"buddy":{"userName":"******","buddyName":"' . $buddyName . '"}}}'; $signParams['body'] = $body; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/unblock"; $response = RestClient::put($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams); $buddyRespObj = new BuddyResponseBuilder(); $buddyObj = $buddyRespObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $buddyObj; }
function saveOrUpdateDocumentByKeyValue($dbName, $collectionName, $key, $value, $newJsonDoc) { Util::throwExceptionIfNullOrBlank($dbName, "DataBase Name"); Util::throwExceptionIfNullOrBlank($collectionName, "Collection Name"); Util::throwExceptionIfNullOrBlank($key, "Key"); Util::throwExceptionIfNullOrBlank($value, "Value"); $encodedDbName = Util::encodeParams($dbName); $encodedCollectionName = Util::encodeParams($collectionName); $encodedKey = Util::encodeParams($key); $encodedValue = Util::encodeParams($value); $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['dbName'] = $dbName; $signParams['collectionName'] = $collectionName; $signParams['key'] = $key; $signParams['value'] = $value; $body = null; $body = '{"app42":{"storage":{"jsonDoc":' . $newJsonDoc . '}}}}'; $signParams['body'] = $body; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/saveorupdate/dbName/" . $encodedDbName . "/collectionName/" . $encodedCollectionName . "/" . $encodedKey . "/" . $encodedValue; $response = RestClient::put($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams); $storageResponseObj = new StorageResponseBuilder(); $storageObj = $storageResponseObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $storageObj; }
function addTagToActivity($tag, $activityId, $userId) { Util::throwExceptionIfNullOrBlank($tag, "tag"); Util::throwExceptionIfNullOrBlank($activityId, "commentId"); Util::throwExceptionIfNullOrBlank($userId, "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); $body = null; $body = '{"app42":{"bravo":{"tag":"' . $tag . '","commentId":"' . $activityId . '","userId":"' . $userId . '"}}}'; $signParams['body'] = $body; $signature = urlencode($objUtil->sign($signParams)); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/addtagtocomment"; $response = RestClient::put($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams); $bravoResponseObj = new BravoBoardResponseBuilder(); $bravoObj = $bravoResponseObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $bravoObj; }
function revokeAccess($albName, $uName, $phName, $aclList) { Util::throwExceptionIfNullOrBlank($uName, "User Name"); Util::throwExceptionIfNullOrBlank($albName, "Album Name"); Util::throwExceptionIfNullOrBlank($phName, "Photo Name"); Util::throwExceptionIfNullOrBlank($aclList, "ACL List"); $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); $aclArray = array(); foreach ($aclList as $acl) { $aclValue = $acl->getJSONObject(); array_push($aclArray, $aclValue); } $body = null; $body = '{"app42":{"photo":{"acls": { "acl": ' . json_encode($aclArray) . '}}}}'; print_r($body); $signParams['albumName'] = $albName; $signParams['photoName'] = $phName; $signParams['userName'] = $uName; $signParams['body'] = $body; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/revokeAccess" . "/" . $uName . "/" . $albName . "/" . $phName; $response = RestClient::put($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams); $album = new AlbumResponseBuilder(); $albumObj = $album->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $albumObj; }
/** * * @param scoreId * @param gameScore * @return * @throws App42Exception */ function editScoreValueById($scoreId, $gameScore) { Util::throwExceptionIfNullOrBlank($scoreId, "Score Id"); Util::throwExceptionIfNullOrBlank($gameScore, "Game 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":{"scores":{"score":{"scoreId":"' . $scoreId . '","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 . "/editscore"; $response = RestClient::put($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams); $scoreObj = new GameResponseBuilder(); $scoreObj1 = $scoreObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $scoreObj1; }
/** * To decrease quantity of existing item in the cart.. * * @params cartID * - The Cart Id from where item quantity has to be reduced * @params itemID * - The Item id from where item quantity has to be reduced. If * the Catalogue Service is used along with the Cart Service then * the Item ids should be same. * @params itemQuantity * - Quantity of the Item has to be reduced * * @returns Cart object containing updated item. */ function decreaseQuantity($cartID, $itemID, $quant) { Util::throwExceptionIfNullOrBlank($cartID, "Cart ID"); Util::throwExceptionIfNullOrBlank($itemID, "Item ID"); Util::throwExceptionIfNullOrBlank($quant, "Quantity"); $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; //echo date("Y-m-d\TG:i:s",strtotime($profile->dateOfBirth)).substr((string)microtime(), 1, 4)."Z"; $body = '{"app42":{"cart":{"cartId":"' . $cartID . '","itemId":"' . $itemID . '","quantity":"' . $quant . '"}}}'; $signParams['body'] = $body; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/decreaseQuantity"; $response = RestClient::put($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams); $cartResponseObj = new CartResponseBuilder(); $cartObj = $cartResponseObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $cartObj; }
function acceptGiftRequest($requestId, $recipient) { Util::throwExceptionIfNullOrBlank($requestId, "RequestId"); Util::throwExceptionIfNullOrBlank($recipient, "recipient"); $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":{"gift":{"requestId":"' . $requestId . '","recipient":"' . $recipient . '"}}}'; $signParams['body'] = $body; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/giftRequestAccpeted"; $response = RestClient::put($baseURL, $params, null, null, $contentType, $accept, $body, $headerParams); $giftResponseObj = new GiftResponseBuilder(); $giftObj = $giftResponseObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $giftObj; }