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.insight; 017 018import com.fasterxml.jackson.annotation.JsonCreator; 019import com.fasterxml.jackson.annotation.JsonProperty; 020import com.vonage.client.JsonableBaseObject; 021 022public class CarrierDetails extends JsonableBaseObject { 023 private String networkCode, name, country; 024 private NetworkType networkType; 025 026 /** 027 * @return The mobile country code for the carrier the number is associated with. 028 * Unreal numbers are marked as null and the request is rejected altogether if 029 * the number is impossible according to the E.164 guidelines. 030 */ 031 @JsonProperty("network_code") 032 public String getNetworkCode() { 033 return networkCode; 034 } 035 036 /** 037 * @return The full name of the carrier that the number is associated with. 038 */ 039 @JsonProperty("name") 040 public String getName() { 041 return name; 042 } 043 044 /** 045 * @return The country that the number is associated with. This is in ISO 3166-1 alpha-2 format. 046 */ 047 @JsonProperty("country") 048 public String getCountry() { 049 return country; 050 } 051 052 /** 053 * @return The network type, as an enum. 054 */ 055 @JsonProperty("network_type") 056 public NetworkType getNetworkType() { 057 return networkType; 058 } 059 060 /** 061 * Enum representing the type of network that the number is associated with. 062 * Note that this enum may be {@code null}. 063 */ 064 public enum NetworkType { 065 MOBILE, 066 LANDLINE, 067 LANDLINE_PREMIUM, 068 LANDLINE_TOLLFREE, 069 VIRTUAL, 070 UNKNOWN, 071 PAGER; 072 073 @JsonCreator 074 public static NetworkType fromString(String name) { 075 if (name.equalsIgnoreCase("null")) { 076 return null; 077 } 078 try { 079 return NetworkType.valueOf(name.toUpperCase()); 080 } 081 catch (IllegalArgumentException iax) { 082 return UNKNOWN; 083 } 084 } 085 086 @Override 087 public String toString() { 088 return name().toLowerCase(); 089 } 090 } 091}