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