diff --git a/src/main/php/Gomoob/Pushwoosh/Model/Notification/Notification.php b/src/main/php/Gomoob/Pushwoosh/Model/Notification/Notification.php index 152b6f7..df3c19a 100644 --- a/src/main/php/Gomoob/Pushwoosh/Model/Notification/Notification.php +++ b/src/main/php/Gomoob/Pushwoosh/Model/Notification/Notification.php @@ -260,6 +260,13 @@ class Notification implements \JsonSerializable */ private $wP; + /** + * List of strings that contains the users' identifiers responsible to filter who will receive the notification. + * + * @var array + */ + private $users; + /** * Utility function used to create a new notification. * @@ -647,7 +654,17 @@ public function getWP() { return $this->wP; } - + + /** + * Gets the list of strings that contains the users' identifiers responsible to filter who will receive the notification. + * + * @return string[] string list of users identifiers + */ + public function getUsers() + { + return $this->users; + } + /** * Creates a JSON representation of this request. * @@ -674,6 +691,7 @@ public function jsonSerialize() 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->users)? $json['users'] = $this->users : false; if (isset($this->conditions)) { $conditionsArray = []; @@ -1162,4 +1180,18 @@ public function setWP(WP $wP) return $this; } + + /** + * Sets the list of users identifiers + * + * @param array $users + * + * @return \Gomoob\Pushwoosh\Model\Notification\Notification this instance. + */ + public function setUsers($users) + { + $this->users = $users; + + return $this; + } } diff --git a/src/test/php/Gomoob/Pushwoosh/Model/Notification/NotificationTest.php b/src/test/php/Gomoob/Pushwoosh/Model/Notification/NotificationTest.php index 244e711..4ea9100 100644 --- a/src/test/php/Gomoob/Pushwoosh/Model/Notification/NotificationTest.php +++ b/src/test/php/Gomoob/Pushwoosh/Model/Notification/NotificationTest.php @@ -451,6 +451,18 @@ public function testIsSetIgnoreUserTimezone() $this->assertFalse($notification->isIgnoreUserTimezone()); } + /** + * Test method for the `getUsers()` and `setUsers($users)` functions. + */ + public function testGetSetUsers() + { + $notification = new Notification(); + $this->assertEmpty($notification->getUsers()); + $users = ['1', '2', '3', '4']; + $this->assertSame($notification, $notification->setUsers($users)); + $this->assertSame($users, $notification->getUsers()); + } + /** * Test method for the `jsonSerialize()` function. */ @@ -587,10 +599,11 @@ public function testJsonSerialize() ->setCount(3) ->setType('Tile') ) + ->setUsers(['1', '2', '3']) ->jsonSerialize(); // Test the generic properties - $this->assertCount(65, $array); + $this->assertCount(66, $array); $this->assertSame('now', $array['send_date']); $this->assertSame('America/New_York', $array['timezone']); $this->assertTrue($array['ignore_user_timezone']); @@ -635,6 +648,7 @@ public function testJsonSerialize() $this->assertSame('value1', $array['conditions'][2][2][1]); $this->assertSame('value2', $array['conditions'][2][2][2]); $this->assertSame('CAMPAIGN', $array['campaign']); + $this->assertSame(['1', '2', '3'], $array['users']); // Test the ADM parameters $this->assertSame('http://example.com/banner.png', $array['adm_banner']);