Skip to content

Commit f1e3001

Browse files
authored
Add send rate avoid param to master (#21)
* Add send_rate_avoid param
1 parent ab36a21 commit f1e3001

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616

1717
steps:
1818
- name: Checkout code
19-
uses: actions/checkout@v2
19+
uses: actions/checkout@v3
2020

2121
- name: Cache dependencies
22-
uses: actions/cache@v2
22+
uses: actions/cache@v3
2323
with:
2424
path: ~/.composer/cache/files
2525
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

src/main/php/Gomoob/Pushwoosh/Model/Notification/Notification.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ class Notification implements \JsonSerializable
237237
* @var int
238238
*/
239239
private $sendRate;
240+
241+
/**
242+
* If set to true, throttling limit will not be applied to this specific push notification
243+
*
244+
* @var bool
245+
*/
246+
private $sendRateAvoid;
240247

241248
/**
242249
* The timezone to use with the `sendDate` property, if ignored UTC-0 is default in "send_date".
@@ -617,6 +624,14 @@ public function getSendRate()
617624
{
618625
return $this->sendRate;
619626
}
627+
628+
/**
629+
* @return bool
630+
*/
631+
public function getSendRateAvoid()
632+
{
633+
return $this->sendRateAvoid;
634+
}
620635

621636
/**
622637
* Gets the timezone to use with the `sendDate` property, if ignored UTC-0 is default in `sendDate`. See
@@ -685,8 +700,9 @@ public function jsonSerialize(): mixed
685700
isset($this->pageId) ? $json['page_id'] = $this->pageId : false;
686701
isset($this->remotePage) ? $json['remote_page'] = $this->remotePage : false;
687702
isset($this->richPageId) ? $json['rich_page_id'] = $this->richPageId : false;
688-
isset($this->sendRate)? $json['send_rate'] = $this->sendRate : false;
689-
isset($this->timezone)? $json['timezone'] = $this->timezone : false;
703+
isset($this->sendRate) ? $json['send_rate'] = $this->sendRate : false;
704+
isset($this->timezone) ? $json['timezone'] = $this->timezone : false;
705+
isset($this->sendRateAvoid) ? $json['send_rate_avoid'] = $this->sendRateAvoid : false;
690706

691707
if (isset($this->conditions)) {
692708
$conditionsArray = [];
@@ -1131,6 +1147,18 @@ public function setSendRate($sendRate)
11311147
return $this;
11321148
}
11331149

1150+
/**
1151+
* @param bool $sendRateAvoid
1152+
*
1153+
* @return \Gomoob\Pushwoosh\Model\Notification\Notification this instance.
1154+
*/
1155+
public function setSendRateAvoid($sendRateAvoid)
1156+
{
1157+
$this->sendRateAvoid = $sendRateAvoid;
1158+
1159+
return $this;
1160+
}
1161+
11341162
/**
11351163
* Sets the timezone to use with the `sendDate` property, if ignored UTC-0 is default in `sendDate`. See
11361164
* http://php.net/manual/timezones.php for the list of the supported timezones.

src/test/php/Gomoob/Pushwoosh/Model/Notification/NotificationTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,17 @@ public function testGetSetSendRate()
418418
$this->assertSame(200, $notification->getSendRate());
419419
}
420420

421+
/**
422+
* Test method for the `getSendRateAvoid()` and `setSendRateAvoid($sendRateAvoid)` functions.
423+
*/
424+
public function testGetSetSendRateAvoid()
425+
{
426+
$notification = new Notification();
427+
$this->assertNull($notification->getSendRateAvoid());
428+
$this->assertSame($notification, $notification->setSendRateAvoid(true));
429+
$this->assertTrue($notification->getSendRateAvoid());
430+
}
431+
421432
/**
422433
* Test method for the `getTimezone()` and `setTimezone($timezone)` functions.
423434
*/
@@ -485,6 +496,7 @@ public function testJsonSerialize()
485496
->setRemotePage('http://myremoteurl.com')
486497
->setRichPageId(42)
487498
->setSendRate(200)
499+
->setSendRateAvoid(true)
488500
->setLink('http://google.com')
489501
->setMinimizeLink(MinimizeLink::none())
490502
->setData(
@@ -622,7 +634,7 @@ public function testJsonSerialize()
622634
->jsonSerialize();
623635

624636
// Test the generic properties
625-
$this->assertCount(80, $array);
637+
$this->assertCount(81, $array);
626638
$this->assertSame('now', $array['send_date']);
627639
$this->assertSame('America/New_York', $array['timezone']);
628640
$this->assertTrue($array['ignore_user_timezone']);
@@ -635,6 +647,7 @@ public function testJsonSerialize()
635647
$this->assertSame('http://myremoteurl.com', $array['remote_page']);
636648
$this->assertSame(42, $array['rich_page_id']);
637649
$this->assertSame(200, $array['send_rate']);
650+
$this->assertTrue($array['send_rate_avoid']);
638651
$this->assertSame('http://google.com', $array['link']);
639652
$this->assertSame(0, $array['minimize_link']);
640653
$this->assertCount(1, $array['data']);

0 commit comments

Comments
 (0)