001/*
002 *   Copyright 2020 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.JsonIgnoreProperties;
019import com.fasterxml.jackson.annotation.JsonProperty;
020import com.fasterxml.jackson.databind.ObjectMapper;
021import com.vonage.client.VonageUnexpectedException;
022
023import java.io.IOException;
024import java.math.BigDecimal;
025
026@JsonIgnoreProperties(ignoreUnknown = true)
027public class StandardInsightResponse extends BasicInsightResponse {
028    private BigDecimal requestPrice;
029    private BigDecimal remainingBalance;
030    private BigDecimal refundPrice;
031    private CarrierDetails originalCarrier;
032    private CarrierDetails currentCarrier;
033    private CallerIdentity callerIdentity;
034
035    public static StandardInsightResponse fromJson(String json) {
036        try {
037            ObjectMapper mapper = new ObjectMapper();
038            return mapper.readValue(json, StandardInsightResponse.class);
039        } catch (IOException jpe) {
040            throw new VonageUnexpectedException("Failed to produce StandardInsightResponse from json.", jpe);
041        }
042    }
043
044    @JsonProperty("request_price")
045    public BigDecimal getRequestPrice() {
046        return requestPrice;
047    }
048
049    @JsonProperty("remaining_balance")
050    public BigDecimal getRemainingBalance() {
051        return remainingBalance;
052    }
053
054    @JsonProperty("original_carrier")
055    public CarrierDetails getOriginalCarrier() {
056        return originalCarrier;
057    }
058
059    @JsonProperty("current_carrier")
060    public CarrierDetails getCurrentCarrier() {
061        return currentCarrier;
062    }
063
064    @JsonProperty("caller_identity")
065    public CallerIdentity getCallerIdentity() {
066        return callerIdentity;
067    }
068
069    @JsonProperty("refund_price")
070    public BigDecimal getRefundPrice() {
071        return refundPrice;
072    }
073}