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.account;
017
018import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
019import com.fasterxml.jackson.annotation.JsonUnwrapped;
020import com.fasterxml.jackson.databind.ObjectMapper;
021import com.vonage.client.VonageUnexpectedException;
022
023import java.io.IOException;
024import java.math.BigDecimal;
025import java.util.List;
026
027@JsonIgnoreProperties(ignoreUnknown = true)
028public class PricingResponse {
029    private String dialingPrefix;
030    private BigDecimal defaultPrice;
031    private String currency;
032    @JsonUnwrapped
033    private Country country;
034    private List<Network> networks;
035
036    public String getDialingPrefix() {
037        return dialingPrefix;
038    }
039
040    public BigDecimal getDefaultPrice() {
041        return defaultPrice;
042    }
043
044    public String getCurrency() {
045        return currency;
046    }
047
048    public Country getCountry() {
049        return country;
050    }
051
052    public List<Network> getNetworks() {
053        return networks;
054    }
055
056    public static PricingResponse fromJson(String json) {
057        try {
058            return new ObjectMapper().readValue(json, PricingResponse.class);
059        } catch (IOException jpe) {
060            throw new VonageUnexpectedException("Failed to produce PricingResponse from json.", jpe);
061        }
062    }
063}