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.verify; 023 024 025/** 026 * An abstract base class for verification results. 027 * 028 * @author Daniele Ricci 029 */ 030public abstract class BaseResult { 031 /** 032 * Verify was successfully submitted to the Nexmo service 033 */ 034 public static final int STATUS_OK = 0; 035 036 /** 037 * Verify was rejected due to exceeding the maximum throughput allowed for this account.<br> 038 * Verify can be re-requested after a short delay 039 */ 040 public static final int STATUS_THROTTLED = 1; 041 042 /** 043 * Verify was rejected due to incomplete data in the submission request 044 */ 045 public static final int STATUS_MISSING_PARAMS = 2; 046 047 /** 048 * Verify was rejected due to an illegal value in one or more elements of the submission request 049 */ 050 public static final int STATUS_INVALID_PARAMS = 3; 051 052 /** 053 * Verify was rejected due to receiving invalid account api key and/or secret 054 */ 055 public static final int STATUS_INVALID_CREDENTIALS = 4; 056 057 /** 058 * Verify was rejected due to a failure within the Nexmo systems.<br> 059 * Verify can be re-submitted after a short delay 060 */ 061 public static final int STATUS_INTERNAL_ERROR = 5; 062 063 /** 064 * Verify was rejected because the Nexmo service was unable to handle this request. eg, the destination was un-routable. 065 */ 066 public static final int STATUS_INVALID_REQUEST = 6; 067 068 /** 069 * Verify was rejected because the phone number you tried to submit to has been blacklisted. 070 */ 071 public static final int STATUS_NUMBER_BARRED = 7; 072 073 /** 074 * Verify was rejected because your account has been barred, or has not yet been activated 075 */ 076 public static final int STATUS_PARTNER_ACCOUNT_BARRED = 8; 077 078 /** 079 * Verify was rejected because your pre-paid balance does not contain enough credit to handle this request.<br> 080 * Please top up your balance before re-submitting this request or subsequent requests. 081 */ 082 public static final int STATUS_PARTNER_QUOTA_EXCEEDED = 9; 083 084 /** 085 * Verify was rejected because another verification to the same number was already requested. 086 */ 087 public static final int STATUS_ALREADY_REQUESTED = 10; 088 089 /** 090 * The destination number is not in a supported network 091 */ 092 public static final int STATUS_UNSUPPORTED_NETWORK = 15; 093 094 /** 095 * The code inserted does not match the expected value 096 */ 097 public static final int STATUS_INVALID_CODE = 16; 098 099 /** 100 * A wrong code was provided too many times 101 */ 102 public static final int STATUS_WRONG_CODE_THROTTLED = 17; 103 104 /** 105 * There are more than the maximum allowed number of destinations in this request 106 */ 107 public static final int STATUS_TOO_MANY_DESTINATIONS = 18; 108 109 /** 110 * There are no matching verification requests 111 */ 112 public static final int STATUS_NO_RESPONSE = 101; 113 114 /** 115 * A network error occurred 116 */ 117 public static final int STATUS_COMMS_FAILURE = -1; 118 119 private final int status; 120 private final String errorText; 121 private final boolean temporaryError; 122 123 protected BaseResult(final int status, 124 final String errorText, 125 final boolean temporaryError) { 126 this.status = status; 127 this.errorText = errorText; 128 this.temporaryError = temporaryError; 129 } 130 131 public int getStatus() { 132 return this.status; 133 } 134 135 public String getErrorText() { 136 return this.errorText; 137 } 138 139 public boolean isTemporaryError() { 140 return this.temporaryError; 141 } 142}