diff --git a/src/httpRequest/push/Base.php b/src/httpRequest/push/Base.php index a265d8a..4b11387 100644 --- a/src/httpRequest/push/Base.php +++ b/src/httpRequest/push/Base.php @@ -251,13 +251,11 @@ public function getOtherParams() public function getNotify() { - if (!$this->getTransmission()) { - return []; + $data = ["transmission_type" => true]; + if ($this->getTransmission()) { + $data['transmission_content'] = $this->getTransmission(); } - return [ - "transmission_type" => true, - "transmission_content" => $this->getTransmission() - ]; + return $data; } public function getLink() diff --git a/src/template/Link.php b/src/template/Link.php index 301fdfa..84d0565 100644 --- a/src/template/Link.php +++ b/src/template/Link.php @@ -38,52 +38,62 @@ class Link implements Template */ protected $duration_end; - /** - * 获取应用模板 - * - * @return array - */ - public function getEntity() :array - { - $res = [ - 'style' => $this->style, - 'url' => $this->url - ]; - $this->duration_begin && $res['duration_begin'] = $this->duration_begin; - $this->duration_end && $res['duration_end'] = $this->duration_end; - return $res; - } - /** * @param array $style + * @return $this */ - public function setStyle($style) + public function setStyle(array $style) { $this->style = $style; + return $this; } /** * @param string $url + * @return $this */ - public function setUrl($url) + public function setUrl(string $url) { $this->url = $url; + return $this; } /** * @param string $duration_begin + * @return $this */ - public function setDurationBegin($duration_begin) + public function setDurationBegin(string $duration_begin) { $this->duration_begin = $duration_begin; + return $this; } /** * @param string $duration_end + * @return $this */ - public function setDurationEnd($duration_end) + public function setDurationEnd(string $duration_end) { $this->duration_end = $duration_end; + return $this; + } + + + + /** + * 获取应用模板 + * + * @return array + */ + public function getEntity() :array + { + $res = [ + 'style' => $this->style, + 'url' => $this->url + ]; + $this->duration_begin && $res['duration_begin'] = $this->duration_begin; + $this->duration_end && $res['duration_end'] = $this->duration_end; + return $res; } diff --git a/src/template/Message.php b/src/template/Message.php index 5091b0a..71b8890 100644 --- a/src/template/Message.php +++ b/src/template/Message.php @@ -58,56 +58,60 @@ class Message implements Template */ const MSG_TYPE_TRANSMISSION = 'transmission'; - - /** - * 获取实体 - * - * @return array - */ - public function getEntity(): array - { - return [ - 'appkey' => $this->app_key, - 'is_offline' => $this->is_offline, - 'offline_expire_time' => $this->expire_time, - 'msgtype' => $this->msgtype, - ]; - } - /** * @param string $app_key + * @return $this */ - public function setAppKey($app_key) + public function setAppKey(string $app_key) { $this->app_key = $app_key; + return $this; } /** * @param bool $is_offline + * @return $this */ - public function setIsOffline($is_offline) + public function setIsOffline(bool $is_offline) { $this->is_offline = $is_offline; + return $this; } /** * @param float|int $expire_time + * @return $this */ public function setExpireTime($expire_time) { $this->expire_time = $expire_time; + return $this; } /** * @param string $msgtype + * @return $this */ - public function setMsgtype($msgtype) + public function setMsgtype(string $msgtype) { $this->msgtype = $msgtype; + return $this; } - public function getMsgtype() + + + /** + * 获取实体 + * + * @return array + */ + public function getEntity(): array { - return $this->msgtype; + return [ + 'appkey' => $this->app_key, + 'is_offline' => $this->is_offline, + 'offline_expire_time' => $this->expire_time, + 'msgtype' => $this->msgtype, + ]; } } \ No newline at end of file diff --git a/src/template/Notification.php b/src/template/Notification.php index deebc39..3ba9c6b 100644 --- a/src/template/Notification.php +++ b/src/template/Notification.php @@ -12,7 +12,7 @@ class Notification implements Template { /** * 通知栏消息布局样式,详见Style说明 - * @var array + * @var Style */ protected $style; @@ -56,43 +56,53 @@ public function getEntity() : array } /** - * @param array $style + * @param Style $style + * @return $this */ - public function setStyle($style) + public function setStyle(Style $style) { - $this->style = $style; + $this->style = $style->getEntity(); + return $this; } /** * @param bool $transmission_type + * @return $this */ - public function setTransmissionType($transmission_type) + public function setTransmissionType(bool $transmission_type) { $this->transmission_type = $transmission_type; + return $this; } /** * @param string $transmission_content + * @return $this */ - public function setTransmissionContent($transmission_content) + public function setTransmissionContent(string $transmission_content) { $this->transmission_content = $transmission_content; + return $this; } /** * @param string $duration_begin + * @return $this */ - public function setDurationBegin($duration_begin) + public function setDurationBegin(string $duration_begin) { $this->duration_begin = $duration_begin; + return $this; } /** * @param string $duration_end + * @return $this */ - public function setDurationEnd($duration_end) + public function setDurationEnd(string $duration_end) { $this->duration_end = $duration_end; + return $this; } diff --git a/src/template/Notypopload.php b/src/template/Notypopload.php index 4da6e28..8ce23f4 100644 --- a/src/template/Notypopload.php +++ b/src/template/Notypopload.php @@ -12,266 +12,348 @@ class Notypopload implements Template { /** * 通知栏消息布局样式,详见Style说明 - * @var array + * + * @var Style */ protected $style; /** * 通知栏图标 (必传) + * * @var string */ protected $notyicon; /** * 通知标题 (必传) + * * @var string */ protected $notytitle; /** * 通知内容 (必传) + * * @var string */ protected $notycontent; /** * 弹出框标题 (必传) + * * @var string */ protected $poptitle; /** * 弹出框内容 (必传) + * * @var string */ protected $popcontent; /** * 弹出框图标 (必传) + * * @var string */ protected $popimage; /** * 弹出框左边按钮名称 (必传) + * * @var string */ protected $popbutton1; /** * 弹出框右边按钮名称 (必传) + * * @var string */ protected $popbutton2; /** * 下载图标 + * * @var string */ protected $loadicon; /** * 下载标题 + * * @var string */ protected $loadtitle; /** * 下载文件地址 (必传) + * * @var string */ protected $loadurl; /** * 是否自动安装,默认值false + * * @var bool */ protected $is_autoinstall = false; /** * 安装完成后是否自动启动应用程序,默认值false + * * @var bool */ protected $is_actived = false; /** * 安装完成后是否自动启动应用程序,默认值false + * * @var string */ protected $duration_begin; /** * 设定展示结束时间,格式为yyyy-MM-dd HH:mm:ss + * * @var string */ protected $duration_end; /** * 安卓标识 + * * @var string */ protected $androidmark; /** * 塞班标识 + * * @var string */ protected $symbianmark; /** * 苹果标识 + * * @var string */ protected $iphonemark; - public function getEntity() : array - { - $res = [ - 'style' => $this->style, - 'notyicon' => $this->notyicon, - 'notytitle' => $this->notytitle, - 'notycontent' => $this->notycontent, - 'poptitle' => $this->poptitle, - 'popcontent' => $this->popcontent, - 'popimage' => $this->popimage, - 'popbutton1' => $this->popbutton1, - 'popbutton2' => $this->popbutton2, - 'loadicon' => $this->loadicon, - 'loadtitle' => $this->loadtitle, - 'loadurl' => $this->loadurl, - 'is_autoinstall' => $this->is_autoinstall, - 'is_actived' => $this->is_actived, - ]; - $this->duration_begin && $res['duration_begin'] = $this->duration_begin; - $this->duration_end && $res['duration_end'] = $this->duration_end; - return $res; - } - /** - * @param array $style + * @param Style $style + * @return $this */ - public function setStyle($style) + public function setStyle(Style $style) { - $this->style = $style; + $this->style = $style->getEntity(); + return $this; } /** * @param string $notyicon + * @return $this */ - public function setNotyicon($notyicon) + public function setNotyicon(string $notyicon) { $this->notyicon = $notyicon; + return $this; } /** * @param string $notytitle + * @return $this */ - public function setNotytitle($notytitle) + public function setNotytitle(string $notytitle) { $this->notytitle = $notytitle; + return $this; } /** * @param string $notycontent + * @return $this */ - public function setNotycontent($notycontent) + public function setNotycontent(string $notycontent) { $this->notycontent = $notycontent; + return $this; } /** * @param string $poptitle + * @return $this */ - public function setPoptitle($poptitle) + public function setPoptitle(string $poptitle) { $this->poptitle = $poptitle; + return $this; } /** * @param string $popcontent + * @return $this */ - public function setPopcontent($popcontent) + public function setPopcontent(string $popcontent) { $this->popcontent = $popcontent; + return $this; } /** * @param string $popimage + * @return $this */ - public function setPopimage($popimage) + public function setPopimage(string $popimage) { $this->popimage = $popimage; + return $this; } /** * @param string $popbutton1 + * @return $this */ - public function setPopbutton1($popbutton1) + public function setPopbutton1(string $popbutton1) { $this->popbutton1 = $popbutton1; + return $this; } /** * @param string $popbutton2 + * @return $this */ - public function setPopbutton2($popbutton2) + public function setPopbutton2(string $popbutton2) { $this->popbutton2 = $popbutton2; + return $this; } /** * @param string $loadicon + * @return $this */ - public function setLoadicon($loadicon) + public function setLoadicon(string $loadicon) { $this->loadicon = $loadicon; + return $this; } /** * @param string $loadtitle + * @return $this */ - public function setLoadtitle($loadtitle) + public function setLoadtitle(string $loadtitle) { $this->loadtitle = $loadtitle; + return $this; } /** * @param string $loadurl + * @return $this */ - public function setLoadurl($loadurl) + public function setLoadurl(string $loadurl) { $this->loadurl = $loadurl; + return $this; } /** * @param bool $is_autoinstall + * @return $this */ - public function setIsAutoinstall($is_autoinstall) + public function setIsAutoinstall(bool $is_autoinstall) { $this->is_autoinstall = $is_autoinstall; + return $this; } /** * @param bool $is_actived + * @return $this */ - public function setIsActived($is_actived) + public function setIsActived(bool $is_actived) { $this->is_actived = $is_actived; + return $this; } /** * @param string $duration_begin + * @return $this */ - public function setDurationBegin($duration_begin) + public function setDurationBegin(string $duration_begin) { $this->duration_begin = $duration_begin; + return $this; } /** * @param string $duration_end + * @return $this */ - public function setDurationEnd($duration_end) + public function setDurationEnd(string $duration_end) { $this->duration_end = $duration_end; + return $this; + } + + /** + * @param string $androidmark + * @return $this + */ + public function setAndroidmark(string $androidmark) + { + $this->androidmark = $androidmark; + return $this; + } + + /** + * @param string $symbianmark + * @return $this + */ + public function setSymbianmark(string $symbianmark) + { + $this->symbianmark = $symbianmark; + return $this; + } + + /** + * @param string $iphonemark + * @return $this + */ + public function setIphonemark(string $iphonemark) + { + $this->iphonemark = $iphonemark; + return $this; + } + + public function getEntity(): array + { + $res = [ + 'style' => $this->style, + 'notyicon' => $this->notyicon, + 'notytitle' => $this->notytitle, + 'notycontent' => $this->notycontent, + 'poptitle' => $this->poptitle, + 'popcontent' => $this->popcontent, + 'popimage' => $this->popimage, + 'popbutton1' => $this->popbutton1, + 'popbutton2' => $this->popbutton2, + 'loadicon' => $this->loadicon, + 'loadtitle' => $this->loadtitle, + 'loadurl' => $this->loadurl, + 'is_autoinstall' => $this->is_autoinstall, + 'is_actived' => $this->is_actived, + ]; + $this->duration_begin && $res['duration_begin'] = $this->duration_begin; + $this->duration_end && $res['duration_end'] = $this->duration_end; + return $res; } + } \ No newline at end of file diff --git a/src/template/PushInfo.php b/src/template/PushInfo.php index 584f066..0ce8da4 100644 --- a/src/template/PushInfo.php +++ b/src/template/PushInfo.php @@ -165,116 +165,249 @@ class PushInfo implements Template protected $only_wifi = false; /** - * 获取弹窗通知实体 - * - * @return array + * @param array $aps + * @return $this */ - public function getAlertEntity() + public function setAps(array $aps) { - $res = [ - 'aps' => [ - 'alert' => [ - "title" => $this->title, - "body" => $this->body, - ], - 'autoBadge' => $this->auto_badge, - 'content-available' => $this->content_available, - 'sound' => $this->sound, - ], - ]; - $this->url && $res['aps']['multimedia'] = [ - 'type' => $this->type, - 'url' => $this->url, - 'only_wifi' => $this->only_wifi, - ]; - $this->payload && $res['payload'] = $this->payload; - return $res; + $this->aps = $aps; + return $this; } /** - * 获取单透传通知实体 - * - * @return array + * @param array $alert + * @return $this + */ + public function setAlert(array $alert) + { + $this->alert = $alert; + return $this; + } + + /** + * @param string $body + * @return $this */ - public function getPayloadEntity() + public function setBody(string $body) { - return ['payload' => $this->payload]; + $this->body = $body; + return $this; } - public function getEntity(): array + /** + * @param string $action_loc_key + * @return $this + */ + public function setActionLocKey(string $action_loc_key) { - return $this->getAlertEntity(); + $this->action_loc_key = $action_loc_key; + return $this; } /** - * @param string $body + * @param string $loc_key + * @return $this */ - public function setBody($body) + public function setLocKey(string $loc_key) { - $this->body = $body; + $this->loc_key = $loc_key; + return $this; + } + + /** + * @param string $loc_args + * @return $this + */ + public function setLocArgs(string $loc_args) + { + $this->loc_args = $loc_args; + return $this; + } + + /** + * @param string $launch_image + * @return $this + */ + public function setLaunchImage(string $launch_image) + { + $this->launch_image = $launch_image; + return $this; } /** * @param string $title + * @return $this */ - public function setTitle($title) + public function setTitle(string $title) { $this->title = $title; + return $this; + } + + /** + * @param string $titile_loc_key + * @return $this + */ + public function setTitileLocKey(string $titile_loc_key) + { + $this->titile_loc_key = $titile_loc_key; + return $this; + } + + /** + * @param string $title_loc_args + * @return $this + */ + public function setTitleLocArgs(string $title_loc_args) + { + $this->title_loc_args = $title_loc_args; + return $this; + } + + /** + * @param string $subtitle + * @return $this + */ + public function setSubtitle(string $subtitle) + { + $this->subtitle = $subtitle; + return $this; + } + + /** + * @param string $subtitle_loc_key + * @return $this + */ + public function setSubtitleLocKey(string $subtitle_loc_key) + { + $this->subtitle_loc_key = $subtitle_loc_key; + return $this; + } + + /** + * @param string $subtitle_loc_args + * @return $this + */ + public function setSubtitleLocArgs(string $subtitle_loc_args) + { + $this->subtitle_loc_args = $subtitle_loc_args; + return $this; } /** * @param string $auto_badge + * @return $this */ - public function setAutoBadge($auto_badge) + public function setAutoBadge(string $auto_badge) { $this->auto_badge = $auto_badge; + return $this; } /** * @param string $sound + * @return $this */ - public function setSound($sound) + public function setSound(string $sound) { $this->sound = $sound; + return $this; } /** * @param int $content_available + * @return $this */ - public function setContentAvailable($content_available) + public function setContentAvailable(int $content_available) { $this->content_available = $content_available; + return $this; + } + + /** + * @param string $category + * @return $this + */ + public function setCategory(string $category) + { + $this->category = $category; + return $this; } /** * @param string $payload + * @return $this */ - public function setPayload($payload) + public function setPayload(string $payload) { $this->payload = $payload; + return $this; + } + + /** + * @param array $multimedia + * @return $this + */ + public function setMultimedia(array $multimedia) + { + $this->multimedia = $multimedia; + return $this; } /** * @param string $url + * @return $this */ - public function setUrl($url) + public function setUrl(string $url) { $this->url = $url; + return $this; } /** * @param int $type + * @return $this */ - public function setType($type) + public function setType(int $type) { $this->type = $type; + return $this; } /** * @param bool $only_wifi + * @return $this */ - public function setOnlyWifi($only_wifi) + public function setOnlyWifi(bool $only_wifi) { $this->only_wifi = $only_wifi; + return $this; + } + + /** + * 获取弹窗通知实体 + * + * @return array + */ + public function getAlertEntity() + { + $res = [ + 'aps' => [ + 'alert' => [ + "title" => $this->title, + "body" => $this->body, + ], + 'autoBadge' => $this->auto_badge, + 'content-available' => $this->content_available, + 'sound' => $this->sound, + ], + ]; + $this->url && $res['aps']['multimedia'] = [ + 'type' => $this->type, + 'url' => $this->url, + 'only_wifi' => $this->only_wifi, + ]; + $this->payload && $res['payload'] = $this->payload; + return $res; } } \ No newline at end of file