001/* 002 * Copyright 2024 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 018import com.fasterxml.jackson.annotation.JsonValue; 019import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 020import java.util.Arrays; 021import java.util.Map; 022import java.util.function.Function; 023import java.util.stream.Collectors; 024 025@JsonDeserialize(using = VerifyStatusDeserializer.class) 026public enum VerifyStatus { 027 /** 028 * The request was successfully accepted by Vonage. 029 */ 030 OK(0), 031 032 /** 033 * You are trying to send more than the maximum of 30 requests per second. 034 */ 035 THROTTLED(1), 036 037 /** 038 * Your request is incomplete and missing the mandatory parameter(s). 039 */ 040 MISSING_PARAMS(2), 041 042 /** 043 * Invalid value for parameter. If you see Facility not allowed in the error text, 044 * check that you are using the correct Base URL in your request. 045 */ 046 INVALID_PARAMS(3), 047 048 /** 049 * The supplied API key or secret in the request is either invalid or disabled. 050 */ 051 INVALID_CREDENTIALS(4), 052 053 /** 054 * An error occurred processing this request in the Cloud Communications Platform. 055 */ 056 INTERNAL_ERROR(5), 057 058 /** 059 * The request could not be routed. 060 */ 061 INVALID_REQUEST(6), 062 063 /** 064 * The number you are trying to verify is blacklisted for verification. 065 */ 066 NUMBER_BARRED(7), 067 068 /** 069 * The api_key you supplied is for an account that has been barred from submitting messages. 070 */ 071 PARTNER_ACCOUNT_BARRED(8), 072 073 /** 074 * Your account does not have sufficient credit to process this request. 075 */ 076 PARTNER_QUOTA_EXCEEDED(9), 077 078 /** 079 * Concurrent verifications to the same number are not allowed. 080 */ 081 ALREADY_REQUESTED(10), 082 083 /** 084 * The request has been rejected. Find out more about this error in the <a href= 085 * https://help.nexmo.com/hc/en-us/articles/360018406532-Verify-On-demand-Service-to-High-Risk-CountriesKnowledge 086 * >Knowledge Base</a>. 087 */ 088 UNSUPPORTED_NETWORK(15), 089 090 /** 091 * The code inserted does not match the expected value. 092 */ 093 INVALID_CODE(16), 094 095 /** 096 * You can run Verify check on a specific {@code request_id} up to three times unless a new verification code 097 * is generated. If you check a request more than three times, it is set to FAILED and you cannot check it again. 098 */ 099 WRONG_CODE_THROTTLED(17), 100 101 /** 102 * For {@code cancel}: Either you have not waited at least 30 seconds after sending a Verify request 103 * before cancelling or Verify has made too many attempts to deliver the verification code for this request, 104 * and you must now wait for the process to complete. For {@code trigger_next_event}: All attempts to 105 * deliver the verification code for this request have completed and there are no remaining events to advance to. 106 */ 107 WAIT_FOR_COMPLETION(19), 108 109 /** 110 * Only certain accounts have the ability to set the {@code pin_code} parameter. 111 * Please contact your account manager for more information. 112 */ 113 UNSUPPORTED_PIN_CODE(20), 114 115 /** 116 * Your Vonage account is still in demo mode. While in demo mode you must add target numbers to the 117 * approved list for your account. Add funds to your account tO remove this limitation. 118 */ 119 NON_PERMITTED_DESTINATION(29), 120 121 /** 122 * Undefined or unknown value. 123 */ 124 UNKNOWN(Integer.MAX_VALUE); 125 126 private final int verifyStatus; 127 128 private static final Map<Integer, VerifyStatus> VERIFY_STATUS_INDEX = 129 Arrays.stream(VerifyStatus.values()).collect(Collectors.toMap( 130 VerifyStatus::getVerifyStatus, Function.identity() 131 )); 132 133 /** 134 * Look up the VerifyStatus based on the int value. 135 * 136 * @param verifyStatus the int value of the verify status. 137 * 138 * @return VerifyStatus based on the int value given. 139 */ 140 public static VerifyStatus fromInt(int verifyStatus) { 141 return VERIFY_STATUS_INDEX.getOrDefault(verifyStatus, UNKNOWN); 142 } 143 144 VerifyStatus(int verifyStatus) { 145 this.verifyStatus = verifyStatus; 146 } 147 148 @JsonValue 149 public int getVerifyStatus() { 150 return verifyStatus; 151 } 152}