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; 024 025@JsonIgnoreProperties(ignoreUnknown = true) 026public class BasicInsightResponse { 027 private InsightStatus status; 028 private String statusMessage; 029 private String errorText; 030 031 private String requestId; 032 private String internationalFormatNumber; 033 private String nationalFormatNumber; 034 private String countryCode; 035 private String countryCodeIso3; 036 private String countryName; 037 private String countryPrefix; 038 039 public static BasicInsightResponse fromJson(String json) { 040 try { 041 ObjectMapper mapper = new ObjectMapper(); 042 return mapper.readValue(json, BasicInsightResponse.class); 043 } catch (IOException jpe) { 044 throw new VonageUnexpectedException("Failed to produce BasicInsightResponse from json.", jpe); 045 } 046 } 047 048 public InsightStatus getStatus() { 049 return status; 050 } 051 052 @JsonProperty("status_message") 053 public String getStatusMessage() { 054 return statusMessage; 055 } 056 057 @JsonProperty("error_text") 058 public String getErrorText() { 059 return errorText; 060 } 061 062 @JsonProperty("request_id") 063 public String getRequestId() { 064 return requestId; 065 } 066 067 @JsonProperty("international_format_number") 068 public String getInternationalFormatNumber() { 069 return internationalFormatNumber; 070 } 071 072 @JsonProperty("national_format_number") 073 public String getNationalFormatNumber() { 074 return nationalFormatNumber; 075 } 076 077 @JsonProperty("country_code") 078 public String getCountryCode() { 079 return countryCode; 080 } 081 082 @JsonProperty("country_code_iso3") 083 public String getCountryCodeIso3() { 084 return countryCodeIso3; 085 } 086 087 @JsonProperty("country_name") 088 public String getCountryName() { 089 return countryName; 090 } 091 092 @JsonProperty("country_prefix") 093 public String getCountryPrefix() { 094 return countryPrefix; 095 } 096}