Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
Expand Down
32 changes: 30 additions & 2 deletions src/main/php/Gomoob/Pushwoosh/Model/Notification/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ class Notification implements \JsonSerializable
* @var int
*/
private $sendRate;

/**
* If set to true, throttling limit will not be applied to this specific push notification
*
* @var bool
*/
private $sendRateAvoid;

/**
* The timezone to use with the `sendDate` property, if ignored UTC-0 is default in "send_date".
Expand Down Expand Up @@ -617,6 +624,14 @@ public function getSendRate()
{
return $this->sendRate;
}

/**
* @return bool
*/
public function getSendRateAvoid()
{
return $this->sendRateAvoid;
}

/**
* Gets the timezone to use with the `sendDate` property, if ignored UTC-0 is default in `sendDate`. See
Expand Down Expand Up @@ -685,8 +700,9 @@ public function jsonSerialize(): mixed
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;
isset($this->sendRate) ? $json['send_rate'] = $this->sendRate : false;
isset($this->timezone) ? $json['timezone'] = $this->timezone : false;
isset($this->sendRateAvoid) ? $json['send_rate_avoid'] = $this->sendRateAvoid : false;

if (isset($this->conditions)) {
$conditionsArray = [];
Expand Down Expand Up @@ -1131,6 +1147,18 @@ public function setSendRate($sendRate)
return $this;
}

/**
* @param bool $sendRateAvoid
*
* @return \Gomoob\Pushwoosh\Model\Notification\Notification this instance.
*/
public function setSendRateAvoid($sendRateAvoid)
{
$this->sendRateAvoid = $sendRateAvoid;

return $this;
}

/**
* Sets the timezone to use with the `sendDate` property, if ignored UTC-0 is default in `sendDate`. See
* http://php.net/manual/timezones.php for the list of the supported timezones.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,17 @@ public function testGetSetSendRate()
$this->assertSame(200, $notification->getSendRate());
}

/**
* Test method for the `getSendRateAvoid()` and `setSendRateAvoid($sendRateAvoid)` functions.
*/
public function testGetSetSendRateAvoid()
{
$notification = new Notification();
$this->assertNull($notification->getSendRateAvoid());
$this->assertSame($notification, $notification->setSendRateAvoid(true));
$this->assertTrue($notification->getSendRateAvoid());
}

/**
* Test method for the `getTimezone()` and `setTimezone($timezone)` functions.
*/
Expand Down Expand Up @@ -485,6 +496,7 @@ public function testJsonSerialize()
->setRemotePage('http://myremoteurl.com')
->setRichPageId(42)
->setSendRate(200)
->setSendRateAvoid(true)
->setLink('http://google.com')
->setMinimizeLink(MinimizeLink::none())
->setData(
Expand Down Expand Up @@ -622,7 +634,7 @@ public function testJsonSerialize()
->jsonSerialize();

// Test the generic properties
$this->assertCount(80, $array);
$this->assertCount(81, $array);
$this->assertSame('now', $array['send_date']);
$this->assertSame('America/New_York', $array['timezone']);
$this->assertTrue($array['ignore_user_timezone']);
Expand All @@ -635,6 +647,7 @@ public function testJsonSerialize()
$this->assertSame('http://myremoteurl.com', $array['remote_page']);
$this->assertSame(42, $array['rich_page_id']);
$this->assertSame(200, $array['send_rate']);
$this->assertTrue($array['send_rate_avoid']);
$this->assertSame('http://google.com', $array['link']);
$this->assertSame(0, $array['minimize_link']);
$this->assertCount(1, $array['data']);
Expand Down