Beispiel #1
0
 /**
  * Creates a JSON representation of this request.
  *
  * @return array a PHP which can be passed to the 'json_encode' PHP method.
  */
 public function toJSON()
 {
     $json = array();
     // Mandatory parameters
     $json['ignore_user_timezone'] = $this->ignoreUserTimezone;
     $json['send_date'] = is_string($this->sendDate) ? $this->sendDate : $this->sendDate->format('Y-m-d H:i');
     // Optional parameters
     isset($this->content) ? $json['content'] = $this->content : false;
     isset($this->data) ? $json['data'] = $this->data : false;
     isset($this->devices) ? $json['devices'] = $this->devices : false;
     isset($this->filter) ? $json['filter'] = $this->filter : false;
     isset($this->link) ? $json['link'] = $this->link : false;
     isset($this->minimizeLink) ? $json['minimize_link'] = $this->minimizeLink->getValue() : false;
     isset($this->pageId) ? $json['page_id'] = $this->pageId : false;
     if (isset($this->conditions)) {
         $conditionsArray = array();
         foreach ($this->conditions as $condition) {
             $conditionsArray[] = $condition->toJSON();
         }
         $json['conditions'] = $conditionsArray;
     }
     if (isset($this->platforms)) {
         $platformsArray = array();
         foreach ($this->platforms as $platform) {
             $platformsArray[] = $platform->getValue();
         }
         $json['platforms'] = $platformsArray;
     }
     // Amazon Device Messaging specific informations
     if (isset($this->aDM)) {
         foreach ($this->aDM->toJSON() as $key => $value) {
             $json[$key] = $value;
         }
     }
     // Android specific informations
     if (isset($this->android)) {
         foreach ($this->android->toJSON() as $key => $value) {
             $json[$key] = $value;
         }
     }
     // BlackBerry specific informations
     if (isset($this->blackBerry)) {
         foreach ($this->blackBerry->toJSON() as $key => $value) {
             $json[$key] = $value;
         }
     }
     // iOS specific informations
     if (isset($this->iOS)) {
         foreach ($this->iOS->toJSON() as $key => $value) {
             $json[$key] = $value;
         }
     }
     // Mac specific informations
     if (isset($this->mac)) {
         foreach ($this->mac->toJSON() as $key => $value) {
             $json[$key] = $value;
         }
     }
     // Safari specific informations
     if (isset($this->safari)) {
         foreach ($this->safari->toJSON() as $key => $value) {
             $json[$key] = $value;
         }
     }
     // Windows Notification Service specific informations
     if (isset($this->wNS)) {
         foreach ($this->wNS->toJSON() as $key => $value) {
             $json[$key] = $value;
         }
     }
     // Windows Phone specific informations
     if (isset($this->wP)) {
         foreach ($this->wP->toJSON() as $key => $value) {
             $json[$key] = $value;
         }
     }
     return $json;
 }