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.sms; 017 018import com.fasterxml.jackson.annotation.JsonProperty; 019import com.vonage.client.JsonableBaseObject; 020import java.math.BigDecimal; 021 022public class SmsSubmissionResponseMessage extends JsonableBaseObject { 023 private MessageStatus status; 024 private String to, id, network, errorText, clientRef, accountRef; 025 private BigDecimal remainingBalance, messagePrice; 026 027 /** 028 * @return The number the message was sent to. Numbers are specified in E.164 format. 029 */ 030 @JsonProperty("to") 031 public String getTo() { 032 return to; 033 } 034 035 /** 036 * @return The ID of the message. 037 */ 038 @JsonProperty("message-id") 039 public String getId() { 040 return id; 041 } 042 043 /** 044 * @return The status of the message. A non-zero code (i.e. anything that isn't 045 * {@link MessageStatus#OK} indicates an error. See 046 * <a href=https://developer.vonage.com/messaging/sms/guides/troubleshooting-sms>Troubleshooting Failed SMS</a>. 047 */ 048 @JsonProperty("status") 049 public MessageStatus getStatus() { 050 return status; 051 } 052 053 /** 054 * @return The description of the error, if present. 055 */ 056 @JsonProperty("error-text") 057 public String getErrorText() { 058 return errorText; 059 } 060 061 /** 062 * @return Your estimated remaining balance. 063 */ 064 @JsonProperty("remaining-balance") 065 public BigDecimal getRemainingBalance() { 066 return remainingBalance; 067 } 068 069 /** 070 * @return The estimated cost of the message. 071 */ 072 @JsonProperty("message-price") 073 public BigDecimal getMessagePrice() { 074 return messagePrice; 075 } 076 077 /** 078 * @return The estimated ID of the network of the recipient. 079 */ 080 @JsonProperty("network") 081 public String getNetwork() { 082 return network; 083 } 084 085 /** 086 * @return If a client-ref was included when sending the SMS, 087 * this field will be included and hold the value that was sent. 088 */ 089 @JsonProperty("client-ref") 090 public String getClientRef() { 091 return clientRef; 092 } 093 094 /** 095 * This is an advanced feature and requires activation via a support request before it can be used. 096 * 097 * @return An optional string used to identify separate accounts using the SMS endpoint for billing purposes. 098 */ 099 @JsonProperty("account-ref") 100 public String getAccountRef() { 101 return accountRef; 102 } 103 104 public boolean isTemporaryError() { 105 return status == MessageStatus.INTERNAL_ERROR || status == MessageStatus.TOO_MANY_BINDS 106 || status == MessageStatus.THROTTLED; 107 } 108 109 @Override 110 public String toString() { 111 return "SmsSubmissionResponseMessage {" + 112 "to='" + to + '\'' + 113 ", id='" + id + '\'' + 114 ", status=" + status + 115 ", remainingBalance=" + remainingBalance + 116 ", messagePrice=" + messagePrice + 117 ", network='" + network + '\'' + 118 ", errorText='" + errorText + '\'' + 119 ", clientRef='" + clientRef + '\'' + 120 '}'; 121 } 122}