Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC: added possibility to unset fields in sms batch update #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
72 changes: 72 additions & 0 deletions src/main/java/com/sinch/xms/api/MtBatchBinarySmsUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,78 @@ public Builder callbackUrl(URI url) {
return this.callbackUrl(UpdateValue.set(url));
}
}

/**
* Unsets the sender TON property.
*
* @return this builder for use in a chained invocation
*/
public Builder unsetSenderTon() {
return this.senderTon(UpdateValue.unset());
}

/**
* Updates the sender TON parameter. If given a <code>null</code> reference then this is
* equivalent to calling {@link #unsetSenderTon()}.
*
* @param senderTon the new sender TON property
* @return this builder for use in a chained invocation
*/
public Builder senderTon(Integer senderTon) {
if (senderTon == null) {
return this.unsetSenderTon();
} else {
return this.senderTon(UpdateValue.set(senderTon));
}
}

/**
* Unsets the sender NPI property.
*
* @return this builder for use in a chained invocation
*/
public Builder unsetSenderNpi() {
return this.senderNpi(UpdateValue.unset());
}

/**
* Updates the sender NPI parameter. If given a <code>null</code> reference then this is
* equivalent to calling {@link #unsetSenderNpi()}.
*
* @param senderNpi the new sender NPI property
* @return this builder for use in a chained invocation
*/
public Builder senderNpi(Integer senderNpi) {
if (senderNpi == null) {
return this.unsetSenderNpi();
} else {
return this.senderNpi(UpdateValue.set(senderNpi));
}
}

/**
* Unsets the maxNumberOfMessageParts property.
*
* @return this builder for use in a chained invocation
*/
public Builder unsetMaxNumberOfMessageParts() {
return this.maxNumberOfMessageParts(UpdateValue.unset());
}

/**
* Updates the maxNumberOfMessageParts parameter. If given a <code>null</code> reference then
* this is equivalent to calling {@link #unsetSenderTon()}.
*
* @param maxNumberOfMessageParts the new sender ton property
* @return this builder for use in a chained invocation
*/
public Builder maxNumberOfMessageParts(Integer maxNumberOfMessageParts) {
if (maxNumberOfMessageParts == null) {
return this.unsetMaxNumberOfMessageParts();
} else {
return this.maxNumberOfMessageParts(UpdateValue.set(maxNumberOfMessageParts));
}
}
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/sinch/xms/api/MtBatchSmsUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.sinch.xms.UpdateValue;
import javax.annotation.Nullable;

/** Objects of this type can be used to update previously submitted MT SMS batches. */
Expand All @@ -48,7 +49,7 @@ public abstract class MtBatchSmsUpdate extends MtBatchUpdate {
*/
@Nullable
@JsonProperty("max_number_of_message_parts")
public abstract Integer maxNumberOfMessageParts();
public abstract UpdateValue<Integer> maxNumberOfMessageParts();

/**
* The DLT principal entity identifier to attach to this message.
Expand Down Expand Up @@ -77,7 +78,7 @@ public abstract class MtBatchSmsUpdate extends MtBatchUpdate {
*/
@JsonProperty("from_ton")
@Nullable
public abstract Integer senderTon();
public abstract UpdateValue<Integer> senderTon();

/**
* The numbering plan identification of the message originator. Valid values are 0 to 18. This is
Expand All @@ -88,5 +89,5 @@ public abstract class MtBatchSmsUpdate extends MtBatchUpdate {
*/
@JsonProperty("from_npi")
@Nullable
public abstract Integer senderNpi();
public abstract UpdateValue<Integer> senderNpi();
}
72 changes: 72 additions & 0 deletions src/main/java/com/sinch/xms/api/MtBatchTextSmsUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,78 @@ public Builder parameters(Map<String, ParameterValues> params) {
return this.parameters(UpdateValue.set(params));
}
}

/**
* Unsets the sender TON property.
*
* @return this builder for use in a chained invocation
*/
public Builder unsetSenderTon() {
return this.senderTon(UpdateValue.unset());
}

/**
* Updates the sender TON parameter. If given a <code>null</code> reference then this is
* equivalent to calling {@link #unsetSenderTon()}.
*
* @param senderTon the new sender TON property
* @return this builder for use in a chained invocation
*/
public Builder senderTon(Integer senderTon) {
if (senderTon == null) {
return this.unsetSenderTon();
} else {
return this.senderTon(UpdateValue.set(senderTon));
}
}

/**
* Unsets the sender NPI property.
*
* @return this builder for use in a chained invocation
*/
public Builder unsetSenderNpi() {
return this.senderNpi(UpdateValue.unset());
}

/**
* Updates the sender NPI parameter. If given a <code>null</code> reference then this is
* equivalent to calling {@link #unsetSenderNpi()}.
*
* @param senderNpi the new sender NPI property
* @return this builder for use in a chained invocation
*/
public Builder senderNpi(Integer senderNpi) {
if (senderNpi == null) {
return this.unsetSenderNpi();
} else {
return this.senderNpi(UpdateValue.set(senderNpi));
}
}

/**
* Unsets the maxNumberOfMessageParts property.
*
* @return this builder for use in a chained invocation
*/
public Builder unsetMaxNumberOfMessageParts() {
return this.maxNumberOfMessageParts(UpdateValue.unset());
}

/**
* Updates the maxNumberOfMessageParts parameter. If given a <code>null</code> reference then
* this is equivalent to calling {@link #unsetSenderTon()}.
*
* @param maxNumberOfMessageParts the new sender ton property
* @return this builder for use in a chained invocation
*/
public Builder maxNumberOfMessageParts(Integer maxNumberOfMessageParts) {
if (maxNumberOfMessageParts == null) {
return this.unsetMaxNumberOfMessageParts();
} else {
return this.maxNumberOfMessageParts(UpdateValue.set(maxNumberOfMessageParts));
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public void canSerializeWithUpdatedFields() throws Exception {
.body("Hello, world!".getBytes(TestUtils.US_ASCII))
.udh(new byte[] {1, 2, 3, 4})
.deliveryReport(UpdateValue.<ReportType>unset())
.senderTon(UpdateValue.unset())
.senderNpi(UpdateValue.unset())
.maxNumberOfMessageParts(UpdateValue.unset())
.build();

String expected =
Expand All @@ -64,7 +67,10 @@ public void canSerializeWithUpdatedFields() throws Exception {
" 'to_add': [ '987654321' ],",
" 'body': 'SGVsbG8sIHdvcmxkIQ==',",
" 'udh': '01020304',",
" 'delivery_report': null",
" 'delivery_report': null,",
" 'from_ton': null,",
" 'from_npi': null,",
" 'max_number_of_message_parts': null",
"}")
.replace('\'', '"');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public void canSerializeWithUpdatedParameters() throws Exception {
.addRecipientInsertion("987654321")
.body("Hello, world!")
.parameters(UpdateValue.set(params))
.senderTon(UpdateValue.unset())
.senderNpi(UpdateValue.unset())
.maxNumberOfMessageParts(UpdateValue.unset())
.build();

String expected =
Expand All @@ -68,7 +71,10 @@ public void canSerializeWithUpdatedParameters() throws Exception {
" 'from': '1234',",
" 'to_add': [ '987654321' ],",
" 'body': 'Hello, world!',",
" 'parameters': { 'newparam': { 'key1': 'value1' } }",
" 'parameters': { 'newparam': { 'key1': 'value1' } },",
" 'from_ton': null,",
" 'from_npi': null,",
" 'max_number_of_message_parts': null",
"}")
.replace('\'', '"');

Expand Down
Loading