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.JsonProperty;
019import com.fasterxml.jackson.core.JsonParser;
020import com.fasterxml.jackson.databind.DeserializationContext;
021import com.fasterxml.jackson.databind.JsonDeserializer;
022import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
023import com.vonage.client.JsonableBaseObject;
024import java.io.IOException;
025
026/**
027 * Real time data about the number.
028 */
029public class RealTimeData extends JsonableBaseObject {
030
031        static class ActiveStatusDeserializer extends JsonDeserializer<Boolean> {
032                @Override
033                public Boolean deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
034                        String text = p.getText();
035                        if (text == null) return null;
036                        switch (text.toLowerCase()) {
037                                default:
038                                        return null;
039                                case "true":
040                                case "active":
041                                        return true;
042                                case "false":
043                                case "inactive":
044                                        return false;
045                        }
046                }
047        }
048
049        @JsonDeserialize(using = ActiveStatusDeserializer.class)
050        protected Boolean activeStatus;
051        protected String handsetStatus;
052
053        /**
054         * @return Whether the end-user's phone number is active within an operator's network.
055         * Note that this could be {@code null}.
056         */
057        @JsonProperty("active_status")
058        public Boolean getActiveStatus() {
059                return activeStatus;
060        }
061
062        /**
063         * @return Whether the end-user's handset is turned on or off.
064         */
065        @JsonProperty("handset_status")
066        public String getHandsetStatus() {
067                return handsetStatus;
068        }
069}