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.voice; 017 018import com.fasterxml.jackson.annotation.JsonCreator; 019import com.fasterxml.jackson.annotation.JsonValue; 020 021/** 022 * Represents the {@code detail} field in {@link EventWebhook#getDetail()}. 023 * 024 * @since 8.2.0 025 */ 026public enum CallStatusDetail { 027 028 /** 029 * No detail field present. 030 */ 031 NO_DETAIL, 032 033 /** 034 * Detail present, but has not been mapped to an enum yet. 035 */ 036 UNMAPPED_DETAIL, 037 038 /** 039 * Number invalid. 040 */ 041 INVALID_NUMBER, 042 043 /** 044 * Rejected by carrier. 045 */ 046 RESTRICTED, 047 048 /** 049 * Call rejected by callee. 050 */ 051 DECLINED, 052 053 /** 054 * Cannot route to the number. 055 */ 056 CANNOT_ROUTE, 057 058 /** 059 * Number is no longer available. 060 */ 061 NUMBER_OUT_OF_SERVICE, 062 063 /** 064 * Server error or failure. 065 */ 066 INTERNAL_ERROR, 067 068 /** 069 * Carrier timed out. 070 */ 071 CARRIER_TIMEOUT, 072 073 /** 074 * Callee is temporarily unavailable. 075 */ 076 UNAVAILABLE; 077 078 @JsonValue 079 @Override 080 public String toString() { 081 return name().toLowerCase(); 082 } 083 084 @JsonCreator 085 public static CallStatusDetail fromString(String detail) { 086 if (detail == null) { 087 return NO_DETAIL; 088 } 089 try { 090 return CallStatusDetail.valueOf(detail.toUpperCase()); 091 } 092 catch (IllegalArgumentException ex) { 093 return UNMAPPED_DETAIL; 094 } 095 } 096}