001/*
002 *   Copyright 2024 Vonage
003 *
004 *   Licensed under the Apache License, Version 2.0 (the "License");
005 *   you may not use this file except in compliance with the License.
006 *   You may obtain a copy of the License at
007 *
008 *        http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *   Unless required by applicable law or agreed to in writing, software
011 *   distributed under the License is distributed on an "AS IS" BASIS,
012 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *   See the License for the specific language governing permissions and
014 *   limitations under the License.
015 */
016package com.vonage.client.messages.sms;
017
018import com.fasterxml.jackson.annotation.JsonProperty;
019import com.vonage.client.JsonableBaseObject;
020
021/**
022 * Represents optional settings for the SMS message in {@link SmsTextRequest}.
023 *
024 * @since 8.1.0
025 */
026public final class OutboundSettings extends JsonableBaseObject {
027    final EncodingType encodingType;
028    final String contentId, entityId;
029
030    private OutboundSettings(EncodingType encodingType, String contentId, String entityId) {
031        this.encodingType = encodingType;
032        this.contentId = contentId;
033        this.entityId = entityId;
034    }
035
036    static OutboundSettings construct(EncodingType encodingType, String contentId, String entityId) {
037        if (encodingType == null && contentId == null && entityId == null) {
038            return null;
039        }
040        if (contentId != null && contentId.trim().isEmpty()) {
041            throw new IllegalArgumentException("Content ID cannot be blank.");
042        }
043        if (entityId != null && entityId.trim().isEmpty()) {
044            throw new IllegalArgumentException("Entity ID cannot be blank.");
045        }
046        return new OutboundSettings(encodingType, contentId, entityId);
047    }
048
049    @JsonProperty("encoding_type")
050    public EncodingType getEncodingType() {
051        return encodingType;
052    }
053
054    @JsonProperty("content_id")
055    public String getContentId() {
056        return contentId;
057    }
058
059    @JsonProperty("entity_id")
060    public String getEntityId() {
061        return entityId;
062    }
063}