Skip to content

Commit

Permalink
* Fix #39 - Fix ios category id naming issue and add support for
Browse files Browse the repository at this point in the history
send_rate ;
 * Test the IOS `getCategoryId()` and `setCategoryId($categoryId)`
functions ;
 * Add new Notification `preset`, `getPreset()` and `setPreset($preset)`
attribute and functions ;
 * Add new Notification `remotePage`, `getRemotePage()` and
`setRemotePage($remotePage)` attribute and functions ; 
 * Add new Notification `richPageId`, `getRichPageId()` and
`setRichPageId($richPageId)` attribute and functions ; 
 * Add new Notification `sendRate`, `getSendRate()` and
`setSendRate($sendRate)` attribute and functions ; 
 * Update composer dependencies.
  • Loading branch information
bgaillard committed Jan 7, 2016
1 parent b962ec2 commit 0c6785e
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 37 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "gomoob/php-pushwoosh",
"description" : "A PHP Library to easily work with the Pushwoosh REST Web Services.",
"version" : "1.3.1",
"version" : "1.4.0",
"license" : "MIT",
"type" : "library",
"keywords" : [
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gomoob-php-pushwoosh",
"version": "1.3.1",
"version": "1.4.0",
"license": "MIT",
"repository" : {
"type" : "git",
Expand Down
153 changes: 127 additions & 26 deletions src/main/php/Gomoob/Pushwoosh/Model/Notification/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ class Notification implements \JsonSerializable
// TODO: DOCUMENT ME !
private $ignoreUserTimezone = true;

// TODO: DOCUMENT ME !
private $sendRate;

/**
* The object which contains specific Pushwoosh notification informations for IOS (Apple Push Notification Service).
*
Expand Down Expand Up @@ -159,6 +156,27 @@ class Notification implements \JsonSerializable
* @var \Gomoob\Pushwoosh\Model\Notification\Platform[]
*/
private $platforms;

/**
* Sets the Push Preset ID from your Control Panel.
*
* @var string
*/
private $preset;

/**
* The remote Rich HTML Page URL. <scheme>://<authority>.
*
* @var string
*/
private $remotePage;

/**
* The new Rich HTML page identifier.
*
* @var int
*/
private $richPageId;

/**
* The object which contains specific Pushwoosh notification informations for Safari.
Expand All @@ -177,6 +195,13 @@ class Notification implements \JsonSerializable
* @var \DateTime | string
*/
private $sendDate = 'now';

/**
* The throttling, valid values are from 100 to 1000 pushes/second.
*
* @var int
*/
private $sendRate;

/**
* The object which contains specific Pushwoosh notification informations for WNS (Windows Notification Service).
Expand Down Expand Up @@ -215,7 +240,6 @@ public function addCondition(ICondition $condition)
}

$this->conditions[] = $condition;

}

/**
Expand All @@ -234,7 +258,6 @@ public function addDevice($device)
$this->devices[] = $device;

return $this;

}

/**
Expand All @@ -253,7 +276,6 @@ public function addPlatform(Platform $platform)
$this->platforms[] = $platform;

return $this;

}

/**
Expand Down Expand Up @@ -377,7 +399,6 @@ public function getDevices()
public function getFilter()
{
return $this->filter;

}

// TODO: DOCUMENT ME !
Expand All @@ -402,7 +423,6 @@ public function getIOS()
public function getLink()
{
return $this->link;

}

/**
Expand All @@ -414,7 +434,6 @@ public function getLink()
public function getMac()
{
return $this->mac;

}

/**
Expand All @@ -426,7 +445,6 @@ public function getMac()
public function getMinimizeLink()
{
return $this->minimizeLink;

}

/**
Expand All @@ -438,7 +456,6 @@ public function getMinimizeLink()
public function getPageId()
{
return $this->pageId;

}

/**
Expand All @@ -449,7 +466,36 @@ public function getPageId()
public function getPlatforms()
{
return $this->platforms;

}

/**
* Gets the Push Preset ID from your Control Panel.
*
* @return string the Push Preset ID from your Control Panel.
*/
public function getPreset()
{
return $this->preset;
}

/**
* Gets the remote Rich HTML Page URL. <scheme>://<authority>.
*
* @return string the remote Rich HTML Page URL. <scheme>://<authority>.
*/
public function getRemotePage()
{
return $this->remotePage;
}

/**
* Gets the new Rich HTML page identifier.
*
* @return int the new Rich HTML page identifier.
*/
public function getRichPageId()
{
return $this->richPageId;
}

/**
Expand All @@ -461,7 +507,6 @@ public function getPlatforms()
public function getSafari()
{
return $this->safari;

}

/**
Expand All @@ -475,7 +520,16 @@ public function getSafari()
public function getSendDate()
{
return $this->sendDate;

}

/**
* Gets the throttling, valid values are from 100 to 1000 pushes/second.
*
* @return int The throttling in pushes/second.
*/
public function getSendRate()
{
return $this->sendRate;
}

/**
Expand All @@ -488,7 +542,6 @@ public function getSendDate()
public function getWNS()
{
return $this->wNS;

}

/**
Expand Down Expand Up @@ -516,14 +569,16 @@ public function jsonSerialize()
$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;
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;

if (isset($this->conditions)) {
$conditionsArray = [];
Expand Down Expand Up @@ -730,14 +785,6 @@ public function setIgnoreUserTimezone($ignoreUserTimezone)
return $this;
}

// TODO: DOCUMENT ME !
public function setSendRate($sendRate)
{
$this->sendRate = $sendRate;

return $this;
}

/**
* Sets the object which contains specific Pushwoosh notification informations for IOS (Apple Push Notification
* Service).
Expand Down Expand Up @@ -822,6 +869,48 @@ public function setPlatforms(array $platforms)

return $this;
}

/**
* Sets the Push Preset ID from your Control Panel.
*
* @param string $preset the Push Preset ID from your Control Panel.
*
* @return \Gomoob\Pushwoosh\Model\Notification\Notification this instance.
*/
public function setPreset($preset)
{
$this->preset = $preset;

return $this;
}

/**
* Sets the remote Rich HTML Page URL. <scheme>://<authority>.
*
* @param string $remotePage the remote Rich HTML Page URL. <scheme>://<authority>.
*
* @return \Gomoob\Pushwoosh\Model\Notification\Notification this instance.
*/
public function setRemotePage($remotePage)
{
$this->remotePage = $remotePage;

return $this;
}

/**
* Sets the new Rich HTML page identifier.
*
* @param int $richPageId the new Rich HTML page identifier.
*
* @return \Gomoob\Pushwoosh\Model\Notification\Notification this instance.
*/
public function setRichPageId($richPageId)
{
$this->richPageId = $richPageId;

return $this;
}

/**
* Sets the object which contains specific Pushwoosh notification informations for Safari.
Expand Down Expand Up @@ -856,7 +945,6 @@ public function setSendDate(/* \DateTime */ $sendDate)
// The provided send date string is invalid
if ($newSendDate === false) {
throw new PushwooshException('Invalid send date provided !');

}

$this->sendDate = $newSendDate;
Expand All @@ -872,7 +960,20 @@ public function setSendDate(/* \DateTime */ $sendDate)
}

return $this;

}

/**
* Sets the throttling, valid values are from 100 to 1000 pushes/second.
*
* @param int $sendRate The throttling in pushes/second.
*
* @return \Gomoob\Pushwoosh\Model\Notification\Notification this instance.
*/
public function setSendRate($sendRate)
{
$this->sendRate = $sendRate;

return $this;
}

/**
Expand Down
14 changes: 13 additions & 1 deletion src/test/php/Gomoob/Pushwoosh/Model/Notification/IOSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ public function testGetSetBadges()
$this->assertSame($iOS, $iOS->setBadges(5));
$this->assertSame(5, $iOS->getBadges());
}

/**
* Test method for the <code>#getCategoryId()</code> and <code>#setCategoryId($categoryId)</code> functions.
*/
public function testGetSetCategoryId()
{
$iOS = new IOS();
$this->assertSame($iOS, $iOS->setCategoryId('1'));
$this->assertSame('1', $iOS->getCategoryId());
}

/**
* Test method for the <code>#getRootParams()</code> and <code>#setRootParams($rootParams)</code> functions.
Expand Down Expand Up @@ -95,15 +105,17 @@ public function testJsonSerialize()
$array = IOS::create()
->setApnsTrimContent(true)
->setBadges(5)
->setCategoryId('1')
->setRootParams(['aps' => ['content-available' => '1']])
->setSound('sound file.wav')
->setTtl(3600)
->setTrimContent(true)
->jsonSerialize();

$this->assertCount(6, $array);
$this->assertCount(7, $array);
$this->assertSame(1, $array['apns_trim_content']);
$this->assertSame(5, $array['ios_badges']);
$this->assertSame('1', $array['ios_category_id']);
$this->assertSame(['aps' => ['content-available' => '1']], $array['ios_root_params']);
$this->assertSame('sound file.wav', $array['ios_sound']);
$this->assertSame(3600, $array['ios_ttl']);
Expand Down
Loading

0 comments on commit 0c6785e

Please sign in to comment.