001/*
002 * Copyright (c) 2011-2017 Nexmo Inc
003 *
004 * Permission is hereby granted, free of charge, to any person obtaining a copy
005 * of this software and associated documentation files (the "Software"), to deal
006 * in the Software without restriction, including without limitation the rights
007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008 * copies of the Software, and to permit persons to whom the Software is
009 * furnished to do so, subject to the following conditions:
010 *
011 * The above copyright notice and this permission notice shall be included in
012 * all copies or substantial portions of the Software.
013 *
014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
020 * THE SOFTWARE.
021 */
022package com.nexmo.client.insight.standard;
023
024import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
025import com.fasterxml.jackson.annotation.JsonProperty;
026import com.fasterxml.jackson.databind.ObjectMapper;
027import com.nexmo.client.NexmoUnexpectedException;
028import com.nexmo.client.insight.CallerType;
029import com.nexmo.client.insight.CarrierDetails;
030import com.nexmo.client.insight.basic.BasicInsightResponse;
031
032import java.io.IOException;
033
034@JsonIgnoreProperties(ignoreUnknown = true)
035public class StandardInsightResponse extends BasicInsightResponse {
036    private String requestPrice;
037    private String remainingBalance;
038    private CarrierDetails originalCarrier;
039    private CarrierDetails currentCarrier;
040    private String callerName;
041    private String firstName;
042    private String lastName;
043    private CallerType callerType;
044
045    public static StandardInsightResponse fromJson(String json) {
046        try {
047            ObjectMapper mapper = new ObjectMapper();
048            return mapper.readValue(json, StandardInsightResponse.class);
049        } catch (IOException jpe) {
050            throw new NexmoUnexpectedException("Failed to produce StandardInsightResponse from json.", jpe);
051        }
052    }
053
054    @JsonProperty("request_price")
055    public String getRequestPrice() {
056        return requestPrice;
057    }
058
059    @JsonProperty("remaining_balance")
060    public String getRemainingBalance() {
061        return remainingBalance;
062    }
063
064    @JsonProperty("original_carrier")
065    public CarrierDetails getOriginalCarrier() {
066        return originalCarrier;
067    }
068
069    @JsonProperty("current_carrier")
070    public CarrierDetails getCurrentCarrier() {
071        return currentCarrier;
072    }
073
074    @JsonProperty("caller_name")
075    public String getCallerName() {
076        return callerName;
077    }
078
079    @JsonProperty("first_name")
080    public String getFirstName() {
081        return firstName;
082    }
083
084    @JsonProperty("last_name")
085    public String getLastName() {
086        return lastName;
087    }
088
089    @JsonProperty("caller_type")
090    public CallerType getCallerType() {
091        return callerType;
092    }
093}