Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "sms-notification", propOrder = {
"overrides",
"alwaysSend",
"ats",
"afterHours"
})
public class SmsNotification {

@XmlElement(name = "overrides")
public final SmsOverrides overrides;
@XmlElement(name = "always-send")
public final boolean alwaysSend;
@XmlElement(name = "at", nillable = false)
public final List<ListedTime> ats;
@XmlElement(name = "after-hours", type = Integer.class, nillable = false)
Expand All @@ -49,21 +52,48 @@ public SmsNotification(int afterHours) {
}

public SmsNotification(List<ListedTime> ats, List<Integer> afterHours) {
this(ats, afterHours, null);
this(ats, afterHours, false);
}

/**
* This constructor requires that the sender is allowed to override the
* recipient's reservation against receiving sender-initiated SMS
* notifications from Digipost. If {@code alwaysSend} is {@code true}, the
* notification will also be sent even if the recipient has already read
* the message before the scheduled notification time, skipping the
* cancellation that would otherwise happen.
*/
public SmsNotification(List<ListedTime> ats, List<Integer> afterHours, boolean alwaysSend) {
this(ats, afterHours, null, alwaysSend);
}

/**
* This constructor requires that the sender is allowed to override SMS
* preferences with {@link SmsOverrides}.
*/
public SmsNotification(List<ListedTime> ats, SmsOverrides overrides) {
this(ats, null, overrides);
this(ats, null, overrides, false);
}

/**
* This constructor requires that the sender is allowed to override SMS
* preferences with {@link SmsOverrides}, and, if {@code alwaysSend}
* is {@code true}, that the sender is allowed to override the recipient's
* reservation against receiving sender-initiated SMS notifications from
* Digipost. If {@code alwaysSend} is {@code true}, the notification will
* also be sent even if the recipient has already read the message before
* the scheduled notification time, skipping the cancellation that would
* otherwise happen.
*/
public SmsNotification(List<ListedTime> ats, SmsOverrides overrides, boolean alwaysSend) {
this(ats, null, overrides, alwaysSend);
}

private SmsNotification(List<ListedTime> ats, List<Integer> afterHours, SmsOverrides overrides) {
private SmsNotification(List<ListedTime> ats, List<Integer> afterHours, SmsOverrides overrides, boolean alwaysSend) {
this.ats = ats != null ? new ArrayList<>(ats) : new ArrayList<ListedTime>();
this.afterHours = afterHours != null ? new ArrayList<>(afterHours) : new ArrayList<Integer>();
this.overrides = overrides;
this.alwaysSend = alwaysSend;
}

}
17 changes: 15 additions & 2 deletions src/main/resources/xsd/api_v8.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -782,18 +782,31 @@
<xsd:complexType name="sms-notification">
<xsd:sequence>
<xsd:element name="overrides" type="sms-overrides" minOccurs="0" maxOccurs="1" nillable="false"/>
<xsd:element name="always-send" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="false">
<xsd:annotation>
<xsd:documentation>
If true, the SMS notification will be sent even if the recipient has reserved
themselves against receiving sender-initiated SMS notifications from Digipost.
It will also be sent even if the recipient has already read the message before
the scheduled notification time - normally a pending notification is cancelled
as soon as the message is read, but that cancellation is skipped when this is set.
Requires special permission for the sending organisation - using this while not
being permitted to will result in an error response.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="at" type="listed-time" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
If the message is unread, a notification will be sent at these times.
If the message is unread (or always-send is activated), a notification will be sent at these times.
SMS is only sent between 9-20. Any notification falling outside this interval, will be sent around 9 the next morning.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="after-hours" type="after-hours" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
If the message is unread, a notification will be sent after the given amount of hours after delivery.
If the message is unread (or always-send is activated), a notification will be sent after the given amount of hours after delivery.
SMS is only sent between 9-20. Any notification falling outside this interval, will be sent around 9 the next morning.
</xsd:documentation>
</xsd:annotation>
Expand Down
Loading