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.conversion; 017 018import com.vonage.client.QueryParamsRequest; 019import java.text.SimpleDateFormat; 020import java.util.Date; 021import java.util.LinkedHashMap; 022import java.util.Map; 023 024/** 025 * 026 * @deprecated This class will be made package-private in the next major release. 027 */ 028@Deprecated 029public class ConversionRequest implements QueryParamsRequest { 030 private final Type type; 031 private final String messageId; 032 private final boolean delivered; 033 private final Date timestamp; 034 035 public ConversionRequest(Type type, String messageId, boolean delivered, Date timestamp) { 036 this.type = type; 037 this.messageId = messageId; 038 this.delivered = delivered; 039 this.timestamp = timestamp; 040 } 041 042 public Type getType() { 043 return type; 044 } 045 046 public String getMessageId() { 047 return messageId; 048 } 049 050 public boolean isDelivered() { 051 return delivered; 052 } 053 054 public Date getTimestamp() { 055 return timestamp; 056 } 057 058 @Override 059 public Map<String, String> makeParams() { 060 LinkedHashMap<String, String> params = new LinkedHashMap<>(4); 061 params.put("message-id", messageId); 062 params.put("delivered", String.valueOf(delivered)); 063 if (timestamp != null) { 064 params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timestamp)); 065 } 066 return params; 067 } 068 069 /** 070 * This enum will be moved to its own class in the next major release. 071 */ 072 public enum Type { 073 SMS, VOICE 074 } 075}