예제 #1
0
 /**
  * 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 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);
 }