/**
  * {@inheritdoc}
  */
 public function jsonSerialize()
 {
     // The 'auth' parameter must have been set
     if (!isset($this->auth)) {
         throw new PushwooshException('The \'auth\' property is not set !');
     }
     $json = ['auth' => $this->auth];
     // 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->devicesFilter) ? $json['devices_filter'] = $this->devicesFilter : 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;
     isset($this->remotePage) ? $json['remote_page'] = $this->remotePage : false;
     isset($this->richPageId) ? $json['rich_page_id'] = $this->richPageId : false;
     isset($this->sendRate) ? $json['send_rate'] = $this->sendRate : false;
     isset($this->timezone) ? $json['timezone'] = $this->timezone : false;
     return $json;
 }
Esempio n. 2
0
 /**
  * Creates a JSON representation of this request.
  *
  * @return array a PHP which can be passed to the 'json_encode' PHP method.
  */
 public function jsonSerialize()
 {
     $json = [];
     // 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->sendRate) ? $json['send_rate'] = $this->sendRate : false;
     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 = [];
         foreach ($this->conditions as $condition) {
             $conditionsArray[] = $condition->jsonSerialize();
         }
         $json['conditions'] = $conditionsArray;
     }
     if (isset($this->platforms)) {
         $platformsArray = [];
         foreach ($this->platforms as $platform) {
             $platformsArray[] = $platform->getValue();
         }
         $json['platforms'] = $platformsArray;
     }
     // Merge specific platforms informations
     return JsonUtils::mergeJsonSerializables($json, $this->aDM, $this->android, $this->blackBerry, $this->chrome, $this->iOS, $this->mac, $this->safari, $this->wNS, $this->wP);
 }
Esempio n. 3
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;
 }