Skip to content

Commit

Permalink
Add huawei platform (#11)
Browse files Browse the repository at this point in the history
* Add huawei platform
  • Loading branch information
romkatsu authored Aug 24, 2022
1 parent 2c36e4d commit 4b7d272
Show file tree
Hide file tree
Showing 6 changed files with 495 additions and 8 deletions.
270 changes: 270 additions & 0 deletions src/main/php/Gomoob/Pushwoosh/Model/Notification/Huawei.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
<?php

namespace Gomoob\Pushwoosh\Model\Notification;

final class Huawei implements \JsonSerializable
{
/**
* @var bool|null
*/
private $badges;

/**
* @var string|null
*/
private $banner;

/**
* @var string|null
*/
private $customIcon;

/**
* @var int|null
*/
private $gcmTtl;

/**
* @var string|null
*/
private $header;

/**
* @var string|null
*/
private $ibc;

/**
* @var string|null
*/
private $icon;

/**
* @var string|null
*/
private $led;

/**
* @var int|null
*/
private $priority;

/**
* @var array|null
*/
private $rootParams;

/**
* @var string|null
*/
private $sound;

/**
* @var boolean
*/
private $vibration;

public static function create()
{
return new self();
}

public function getBadges()
{
return $this->badges;
}

public function getBanner()
{
return $this->banner;
}

public function getCustomIcon()
{
return $this->customIcon;
}

public function getGcmTtl()
{
return $this->gcmTtl;
}

public function getHeader()
{
return $this->header;
}

public function getIbc()
{
return $this->ibc;
}

public function getIcon()
{
return $this->icon;
}

public function getLed()
{
return $this->led;
}

public function getPriority()
{
return $this->priority;
}

public function getRootParams()
{
return $this->rootParams;
}

public function getSound()
{
return $this->sound;
}

public function isVibration()
{
return $this->vibration;
}

public function jsonSerialize()
{
$json = [];

if ($this->badges !== null) {
$json['huawei_android_badges'] = $this->badges;
}

if ($this->banner !== null) {
$json['huawei_android_banner'] = $this->banner;
}

if ($this->customIcon !== null) {
$json['huawei_android_custom_icon'] = $this->customIcon;
}

if ($this->gcmTtl !== null) {
$json['huawei_android_gcm_ttl'] = $this->gcmTtl;
}

if ($this->header !== null) {
$json['huawei_android_header'] = $this->header;
}

if ($this->ibc !== null) {
$json['huawei_android_ibc'] = $this->ibc;
}

if ($this->icon !== null) {
$json['huawei_android_icon'] = $this->icon;
}

if ($this->led !== null) {
$json['huawei_android_led'] = $this->led;
}

if ($this->priority !== null) {
$json['huawei_android_priority'] = $this->priority;
}

if ($this->rootParams !== null) {
$json['huawei_android_root_params'] = $this->rootParams;
}

if ($this->sound !== null) {
$json['huawei_android_sound'] = $this->sound;
}

if ($this->vibration !== null) {
$json['huawei_android_vibration'] = $this->vibration ? 1 : 0;
}

return $json;
}

public function setBadges($badges)
{
$this->badges = $badges;

return $this;
}

public function setBanner($banner)
{
$this->banner = $banner;

return $this;
}

public function setCustomIcon($customIcon)
{
$this->customIcon = $customIcon;

return $this;
}

public function setGcmTtl($gcmTtl)
{
$this->gcmTtl = $gcmTtl;

return $this;
}

public function setHeader($header)
{
$this->header = $header;

return $this;
}

public function setIbc($ibc)
{
$this->ibc = $ibc;

return $this;
}

public function setIcon($icon)
{
$this->icon = $icon;

return $this;
}

public function setLed($led)
{
$this->led = $led;

return $this;
}

public function setPriority($priority)
{
$this->priority = $priority;

return $this;
}

public function setRootParams($rootParams)
{
$this->rootParams = $rootParams;

return $this;
}

public function setSound($sound)
{
$this->sound = $sound;

return $this;
}

public function setVibration($vibration)
{
$this->vibration = $vibration;

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ class Notification implements \JsonSerializable
*/
private $wP;

/**
* @var Huawei
*/
private $huawei;

/**
* Utility function used to create a new notification.
*
Expand Down Expand Up @@ -647,6 +652,14 @@ public function getWP()
{
return $this->wP;
}

/**
* @return Huawei
*/
public function getHuawei()
{
return $this->huawei;
}

/**
* Creates a JSON representation of this request.
Expand Down Expand Up @@ -707,7 +720,8 @@ public function jsonSerialize()
$this->mac,
$this->safari,
$this->wNS,
$this->wP
$this->wP,
$this->huawei
);
}

Expand Down Expand Up @@ -1162,4 +1176,15 @@ public function setWP(WP $wP)

return $this;
}

/**
* @param Huawei $huawei
* @return $this
*/
public function setHuawei(Huawei $huawei)
{
$this->huawei = $huawei;

return $this;
}
}
13 changes: 12 additions & 1 deletion src/main/php/Gomoob/Pushwoosh/Model/Notification/Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ class Platform
*/
const FIREFOX = 12;

/**
* @const string Huawei
*/
const HUAWEI = 17;

/**
* The value of the platform, this can be equal to :
* - 1 : iOS
Expand All @@ -73,7 +78,7 @@ class Platform
* - 10: Safari
* - 11: Chrome
* - 12: Firefox
*
* - 17: Huawei
* @var int
*/
private $value;
Expand Down Expand Up @@ -198,6 +203,11 @@ public static function firefox()
return new Platform(self::FIREFOX);
}

public static function huawei()
{
return new Platform(self::HUAWEI);
}

/**
* Gets the value of the plateform, this can be equal to :
* - 1 : iOS
Expand All @@ -211,6 +221,7 @@ public static function firefox()
* - 10: Safari
* - 11: Chrome
* - 12: Firefox
* - 17: Huawei
*
* @return int the value of the platform.
*/
Expand Down
Loading

0 comments on commit 4b7d272

Please sign in to comment.