PluginProbe
Pushly / trunk
Pushly vtrunk
2.4.0 2.3.0 trunk 1.0 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 2.0.0 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1
pushly / src / php / Models / NotificationAudience.php

NotificationAudience.php in Pushly trunk, at src/php/Models/NotificationAudience.php

26 lines 792 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Pushly\Models;
4
5 class NotificationAudience implements \JsonSerializable {
6 public ?bool $all_subscribers = null;
7 public ?array $segment_ids = null;
8 public ?array $excluded_segment_ids = null;
9
10 #[\ReturnTypeWillChange]
11 public function jsonSerialize(): array {
12 $audience = $this->all_subscribers
13 ? [ 'all_subscribers' => $this->all_subscribers ]
14 : [ 'segment_ids' => $this->segment_ids ];
15
16 // Exclusions accompany the audience rather than replacing it: the API
17 // accepts excluded_segment_ids alongside any audience type, so an empty
18 // targeting selection plus exclusions means "all subscribers except these".
19 if ( ! empty( $this->excluded_segment_ids ) ) {
20 $audience['excluded_segment_ids'] = $this->excluded_segment_ids;
21 }
22
23 return $audience;
24 }
25 }
26