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.account; 017 018import com.fasterxml.jackson.annotation.*; 019import com.vonage.client.JsonableBaseObject; 020import java.math.BigDecimal; 021 022/** 023 * Represents a network in {@link PricingResponse}. 024 */ 025public class Network extends JsonableBaseObject { 026 private Type type; 027 private BigDecimal price; 028 private String currency, mcc, mnc, code, name; 029 030 @Deprecated 031 public Network() { 032 } 033 034 /** 035 * Network type. 036 * 037 * @return The type of network as an enum. 038 */ 039 @JsonProperty("type") 040 public Type getType() { 041 return type; 042 } 043 044 /** 045 * Cost to send a message or make a call to this network 046 * 047 * @return The network price, or {@code null} if unknown. 048 */ 049 @JsonProperty("price") 050 public BigDecimal getPrice() { 051 return price; 052 } 053 054 /** 055 * Currency code for the network price. 056 * 057 * @return The currency code as a string, or {@code null} if unknown. 058 */ 059 @JsonProperty("currency") 060 public String getCurrency() { 061 return currency; 062 } 063 064 /** 065 * Mobile Country Code of the operator. 066 * 067 * @return The network operator's mobile country code as a string, or {@code null} if unknown. 068 */ 069 @JsonProperty("mcc") 070 public String getMcc() { 071 return mcc; 072 } 073 074 /** 075 * Mobile Network Code of the operator. 076 * 077 * @return The network operator's code as a string, or {@code null} if unknown. 078 */ 079 @JsonProperty("mnc") 080 public String getMnc() { 081 return mnc; 082 } 083 084 /** 085 * Mobile Country Code and Mobile Network Code combined to give a unique reference for the operator. 086 * 087 * @return The network code (MCC and MNC) as a string, or {@code null} if unknown. 088 */ 089 @JsonProperty("networkCode") 090 public String getCode() { 091 return code; 092 } 093 094 /** 095 * Company/organisational name of the operator. 096 * 097 * @return The network operator name, or {@code null} if unknown. 098 */ 099 @JsonProperty("networkName") 100 public String getName() { 101 return name; 102 } 103 104 /** 105 * Represents the type of network. 106 */ 107 public enum Type { 108 MOBILE, 109 LANDLINE, 110 @Deprecated PAGER, 111 LANDLINE_TOLLFREE, 112 UNKNOWN; 113 114 @Override 115 @JsonValue 116 public String toString() { 117 return name().toLowerCase(); 118 } 119 120 /** 121 * Converts a string representation of the network type to an enum. 122 * 123 * @param type The network type as a string. 124 * @return The network type as an enum, or {@link Type#UNKNOWN} if unknown. 125 */ 126 @JsonCreator 127 public static Type fromString(String type) { 128 try { 129 return Type.valueOf(type.toUpperCase()); 130 } 131 catch (IllegalArgumentException ex) { 132 return UNKNOWN; 133 } 134 } 135 } 136}