-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
235 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/com/vonage/client/messages/sms/EncodingType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2023 Vonage | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.vonage.client.messages.sms; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
/** | ||
* Represents the encoding type for an SMS text message. | ||
* | ||
* @since 8.1.0 | ||
*/ | ||
public enum EncodingType { | ||
TEXT, | ||
UNICODE, | ||
AUTO; | ||
|
||
@JsonCreator | ||
public static EncodingType fromString(String value) { | ||
if (value == null || value.trim().isEmpty()) return null; | ||
return EncodingType.valueOf(value.toUpperCase()); | ||
} | ||
|
||
@JsonValue | ||
@Override | ||
public String toString() { | ||
return name().toLowerCase(); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/vonage/client/messages/sms/OutboundSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2023 Vonage | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.vonage.client.messages.sms; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* Represents optional settings for the SMS message in {@link SmsTextRequest}. | ||
* | ||
* @since 8.1.0 | ||
*/ | ||
@JsonInclude(value = JsonInclude.Include.NON_NULL) | ||
public final class OutboundSettings { | ||
final EncodingType encodingType; | ||
final String contentId, entityId; | ||
|
||
private OutboundSettings(EncodingType encodingType, String contentId, String entityId) { | ||
this.encodingType = encodingType; | ||
this.contentId = contentId; | ||
this.entityId = entityId; | ||
} | ||
|
||
static OutboundSettings construct(EncodingType encodingType, String contentId, String entityId) { | ||
if (encodingType == null && contentId == null && entityId == null) { | ||
return null; | ||
} | ||
if (contentId != null && contentId.trim().isEmpty()) { | ||
throw new IllegalArgumentException("Content ID cannot be blank."); | ||
} | ||
if (entityId != null && entityId.trim().isEmpty()) { | ||
throw new IllegalArgumentException("Entity ID cannot be blank."); | ||
} | ||
return new OutboundSettings(encodingType, contentId, entityId); | ||
} | ||
|
||
@JsonProperty("encoding_type") | ||
public EncodingType getEncodingType() { | ||
return encodingType; | ||
} | ||
|
||
@JsonProperty("content_id") | ||
public String getContentId() { | ||
return contentId; | ||
} | ||
|
||
@JsonProperty("entity_id") | ||
public String getEntityId() { | ||
return entityId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters