001/*
002 *   Copyright 2020 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.sms;
017
018import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
019import com.fasterxml.jackson.annotation.JsonProperty;
020import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
021
022import java.math.BigDecimal;
023
024@JsonIgnoreProperties(ignoreUnknown = true)
025public class SmsSubmissionResponseMessage {
026    private String to;
027    private String id;
028    private MessageStatus status;
029    private BigDecimal remainingBalance;
030    private BigDecimal messagePrice;
031    private String network;
032    private String errorText;
033    private String clientRef;
034
035    @JsonProperty("to")
036    public String getTo() {
037        return this.to;
038    }
039
040    @JsonProperty("message-id")
041    public String getId() {
042        return this.id;
043    }
044
045    @JsonProperty("status")
046    public MessageStatus getStatus() {
047        return this.status;
048    }
049
050    @JsonProperty("error-text")
051    public String getErrorText() {
052        return this.errorText;
053    }
054
055    @JsonProperty("client-ref")
056    public String getClientRef() {
057        return this.clientRef;
058    }
059
060    @JsonProperty("remaining-balance")
061    public BigDecimal getRemainingBalance() {
062        return this.remainingBalance;
063    }
064
065    @JsonProperty("message-price")
066    public BigDecimal getMessagePrice() {
067        return this.messagePrice;
068    }
069
070    @JsonProperty("network")
071    public String getNetwork() {
072        return this.network;
073    }
074
075    public boolean isTemporaryError() {
076        return this.status == MessageStatus.INTERNAL_ERROR || this.status == MessageStatus.TOO_MANY_BINDS
077                || this.status == MessageStatus.THROTTLED;
078    }
079
080    @Override
081    public String toString() {
082        return ReflectionToStringBuilder.reflectionToString(this);
083    }
084}