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.fasterxml.jackson.databind.annotation.JsonDeserialize;
021import com.vonage.client.JsonableBaseObject;
022
023/**
024 * Information about the roaming status for number. This is applicable to mobile numbers only.
025 */
026@JsonDeserialize(using = RoamingDeseriazlizer.class)
027public class RoamingDetails extends JsonableBaseObject {
028    private final RoamingStatus status;
029    private final String roamingCountryCode, roamingNetworkCode, roamingNetworkName;
030
031    /**
032     * Represents whether the number is outside its home carrier network, as an enum.
033     */
034    public enum RoamingStatus {
035        UNKNOWN, ROAMING, NOT_ROAMING;
036
037        @JsonCreator
038        public static RoamingStatus fromString(String name) {
039            try {
040                return RoamingStatus.valueOf(name.toUpperCase());
041            }
042            catch (IllegalArgumentException ex) {
043                return UNKNOWN;
044            }
045        }
046
047        @Override
048        public String toString() {
049            return name().toLowerCase();
050        }
051    }
052
053    public RoamingDetails(RoamingStatus status, String roamingCountryCode, String roamingNetworkCode, String roamingNetworkName){
054        this.status = status;
055        this.roamingCountryCode = roamingCountryCode;
056        this.roamingNetworkCode = roamingNetworkCode;
057        this.roamingNetworkName = roamingNetworkName;
058    }
059
060    /**
061     * @return The roaming status, as an enum.
062     */
063    @JsonProperty("status")
064    public RoamingStatus getStatus() {
065        return status;
066    }
067
068    /**
069     * @return If number is roaming, this is the code of the country the number is roaming in.
070     */
071    @JsonProperty("roaming_country_code")
072    public String getRoamingCountryCode() {
073        return roamingCountryCode;
074    }
075
076    /**
077     * @return If the number is roaming, this is the ID of the carrier network the number is roaming in.
078     */
079    @JsonProperty("roaming_network_code")
080    public String getRoamingNetworkCode() {
081        return roamingNetworkCode;
082    }
083
084    /**
085     * @return If the number is roaming, this is the name of the carrier network the number is roaming in.
086     */
087    @JsonProperty("roaming_network_name")
088    public String getRoamingNetworkName() {
089        return roamingNetworkName;
090    }
091}