public function getNotificationConnectionDetails($queues) { $endpoint = $this->getFqdn() . '/myMessages/v2/notificationConnectionDetails'; $req = new RestfulRequest($endpoint); $req->setHeader('Accept', 'application/json')->setAuthorizationHeader($this->getToken()); $httpGet = new HttpGet(); $httpGet->setParam('queues', $queues); $result = $req->sendHttpGet($httpGet); $arr = Service::parseJson($result); return IMMNNotificactionCD::fromArray($arr); }
/** * Sends a request to the API gateway for getting groups. * * @param PaginationParameters $pParams paginiations parameters * @param string|null $groupName group name used in search, if any * * @return ResultSet returned groups * @throws ServiceException if request was not successful */ public function getGroups(PaginationParameters $pParams = null, $groupName = null) { $endpoint = $this->getFqdn() . '/addressBook/v1/groups'; $httpGet = new HttpGet(); if ($pParams != null) { $httpGet->setParams($pParams->toArray()); } if ($groupName != null) { $httpGet->setParam('groupName', $groupName); } $req = new RestfulRequest($endpoint); $req->setAuthorizationHeader($this->getToken())->setHeader('Accept', 'application/json')->setHeader('Content-Type', 'application/json'); $result = $req->sendHttpGet($httpGet); if ($result->getResponseCode() == 204) { return null; } $successCodes = array(200); $arr = Service::parseJson($result, $successCodes); return GroupsResultSet::fromArray($arr); }
/** * Sends a request to the API for getting an advertisement. * * @param string $category category of this app. * @param string $userAgent user agent string to send to API. * @param string $udid specifies a universially unique * identifier, which must be at least 30 * characters in length. * @param OptArgs|null $optArgs any optional values. * * @return null|ADSResponse null if no ads were returned, * otherwise an ADSResponse object * @throws ServiceException if API request was not successful */ public function getAdvertisement($category, $userAgent, $udid, OptArgs $optArgs = null, $raw_response = false) { $endpoint = $this->getFqdn() . '/rest/1/ads'; $req = new RestfulRequest($endpoint); $req->setAuthorizationHeader($this->getToken())->setHeader('User-agent', $userAgent)->setHeader('Udid', $udid); $httpGet = new HttpGet(); $httpGet->setParam('Category', $category); if ($optArgs != null) { $this->_appendOptArgs($httpGet, $optArgs); } $result = $req->sendHttpGet($httpGet); // no ads returned if ($result->getResponseCode() == 204) { if ($raw_response) { return $result->getResponseBody(); } return null; } if ($raw_response) { return Service::parseApiResposeBody($result); } // response as json array $jarr = Service::parseJson($result); return ADSResponse::fromArray($jarr); }
public function getNotificationSubscription($channelId, $subscriptionId) { $channelId = urlencode($channelId); $subscriptionId = urlencode($subscriptionId); $suburl = '/notification/v1/channels/' . $channelId . '/subscriptions/' . $subscriptionId; $endpoint = $this->getFqdn() . $suburl; $req = new RestfulRequest($endpoint); $req->setAuthorizationHeader($this->getToken())->setHeader('Accept', 'application/json'); $result = $req->sendHttpGet(); $contentType = $result->getHeader('content-type'); $systemTransId = $result->getHeader('x-systemTransactionId'); $successCodes = array(200); $arr = Service::parseJson($result, $successCodes); $arrSubscription = $arr['subscription']; $arrSubscriptionId = $arrSubscription['subscriptionId']; $arrExpiresIn = $arrSubscription['expiresIn']; /* TODO: remove work-around for events/eventFilters check */ $arrEvents = null; if (isset($arrSubscription['events'])) { $arrEvents = $arrSubscription['events']; } else { $arrEvents = $arrSubscription['eventFilters']; } $arrCallbackData = $arrSubscription['callbackData']; return new GetSubscriptionResponse($contentType, $arrSubscriptionId, $arrExpiresIn, $arrEvents, $arrCallbackData, $systemTransId); }