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.incoming; 017 018import com.fasterxml.jackson.annotation.JsonProperty; 019import com.fasterxml.jackson.databind.ObjectMapper; 020import com.vonage.client.Jsonable; 021import com.vonage.client.VonageUnexpectedException; 022import java.io.IOException; 023import java.text.DateFormat; 024import java.text.SimpleDateFormat; 025import java.util.Date; 026import java.util.TimeZone; 027 028/** 029 * @deprecated Moved to {@link com.vonage.client.sms.MessageEvent}. 030 */ 031@Deprecated 032public class MessageEvent implements Jsonable { 033 private String msisdn, to, messageId, text, keyword, timestamp, nonce, data, udh; 034 private MessageType type; 035 private Date messageTimestamp; 036 private Boolean concat; 037 private int concatRef, concatTotal, concatPart; 038 039 @JsonProperty("msisdn") 040 public String getMsisdn() { 041 return msisdn; 042 } 043 044 @JsonProperty("to") 045 public String getTo() { 046 return to; 047 } 048 049 @JsonProperty("messageId") 050 public String getMessageId() { 051 return messageId; 052 } 053 054 @JsonProperty("text") 055 public String getText() { 056 return text; 057 } 058 059 @JsonProperty("type") 060 public MessageType getType() { 061 return type; 062 } 063 064 @JsonProperty("keyword") 065 public String getKeyword() { 066 return keyword; 067 } 068 069 @JsonProperty("message-timestamp") 070 public Date getMessageTimestamp() { 071 return messageTimestamp; 072 } 073 074 @JsonProperty("timestamp") 075 public String getTimestamp() { 076 return timestamp; 077 } 078 079 @JsonProperty("nonce") 080 public String getNonce() { 081 return nonce; 082 } 083 084 @JsonProperty("concat") 085 public Boolean getConcat() { 086 return concat; 087 } 088 089 @JsonProperty("concat-ref") 090 public int getConcatRef() { 091 return concatRef; 092 } 093 094 @JsonProperty("concat-total") 095 public int getConcatTotal() { 096 return concatTotal; 097 } 098 099 @JsonProperty("concat-part") 100 public int getConcatPart() { 101 return concatPart; 102 } 103 104 @JsonProperty("data") 105 public String getData() { 106 return data; 107 } 108 109 @JsonProperty("udh") 110 public String getUdh() { 111 return udh; 112 } 113 114 @Override 115 public void updateFromJson(String json) { 116 try { 117 DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 118 dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); 119 120 ObjectMapper mapper = new ObjectMapper(); 121 mapper.setDateFormat(dateFormat); 122 mapper.readerForUpdating(this).readValue(json, MessageEvent.class); 123 } 124 catch (IOException jpe) { 125 throw new VonageUnexpectedException("Failed to produce MessageEvent from json.", jpe); 126 } 127 } 128 129 public static MessageEvent fromJson(String json) { 130 return Jsonable.fromJson(json); 131 } 132}