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.redact; 017 018import com.fasterxml.jackson.annotation.JsonInclude; 019import com.fasterxml.jackson.annotation.JsonValue; 020import com.fasterxml.jackson.core.JsonProcessingException; 021import com.fasterxml.jackson.databind.ObjectMapper; 022import com.vonage.client.VonageUnexpectedException; 023 024/** 025 * Represents a request to the Redact API. 026 */ 027@JsonInclude(JsonInclude.Include.NON_NULL) 028public class RedactRequest { 029 030 private String id; 031 private Product product; 032 private Type type; 033 034 /** 035 * Construct a RedactRequest object with all required fields. 036 * 037 * @param id The transaction id to redact. 038 * @param product The {@link Product} that the id relates to. 039 */ 040 public RedactRequest(String id, Product product) { 041 this.id = id; 042 this.product = product; 043 } 044 045 public String getId() { 046 return id; 047 } 048 049 public void setId(String id) { 050 this.id = id; 051 } 052 053 public Product getProduct() { 054 return product; 055 } 056 057 public void setProduct(Product product) { 058 this.product = product; 059 } 060 061 public Type getType() { 062 return type; 063 } 064 065 public void setType(Type type) { 066 this.type = type; 067 } 068 069 public String toJson() { 070 try { 071 ObjectMapper mapper = new ObjectMapper(); 072 return mapper.writeValueAsString(this); 073 } catch (JsonProcessingException jpe) { 074 throw new VonageUnexpectedException("Failed to produce json from RedactRequest object.", jpe); 075 } 076 } 077 078 public enum Product { 079 SMS("sms"), 080 VOICE("voice"), 081 NUMBER_INSIGHTS("number-insight"), 082 VERIFY("verify"), 083 VERIFY_SDK("verify-sdk"), 084 /** 085 * @deprecated Use {@link Product#MESSAGES} 086 **/ 087 @Deprecated MESSAGE("messages"), 088 MESSAGES("messages"), 089 WORKFLOW("workflow"); 090 091 private String value; 092 093 Product(String value) { 094 this.value = value; 095 } 096 097 @JsonValue 098 public String getValue() { 099 return value; 100 } 101 } 102 103 public enum Type { 104 INBOUND, OUTBOUND; 105 106 @JsonValue 107 public String getValue() { 108 return this.name().toLowerCase(); 109 } 110 } 111}