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