-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnotificationBySegment.builder.ts
29 lines (26 loc) · 1.29 KB
/
notificationBySegment.builder.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { NotificationByBaseBuilder } from './notificationByBase.builder';
import { OneSignalError } from '../../errors';
import { INotificationFilterSegments } from '../../dto/notifications';
// https://documentation.onesignal.com/reference#section-send-to-segments
export class NotificationBySegmentBuilder extends NotificationByBaseBuilder<INotificationFilterSegments> {
// The segment names you want to target. Users in these segments will receive a notification.
// This targeting parameter is only compatible with excluded_segments
// Example: ["Active Users", "Inactive Users"]
public setIncludedSegments(value: string[]): NotificationBySegmentBuilder {
this.filter.included_segments = value;
return this;
}
// Segment that will be excluded when sending. Users in these segments will not receive a notification,
// even if they were included in included_segments.
// This targeting parameter is only compatible with included_segments.
// Example: ["Active Users", "Inactive Users"]
public setExcludedSegments(value: string[]): NotificationBySegmentBuilder {
this.filter.excluded_segments = value;
return this;
}
protected checkRequiredVariables() {
if (!this.filter.included_segments) {
throw new OneSignalError('included_segments is required');
}
}
}