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.verify2;
017
018import com.fasterxml.jackson.annotation.JsonCreator;
019import com.fasterxml.jackson.annotation.JsonValue;
020
021/**
022 * Represents the status of an event or update in {@link VerificationCallback#getStatus()}.
023 */
024public enum VerificationStatus {
025        /**
026         * Completed.
027         */
028        COMPLETED,
029
030        /**
031         * Failed.
032         */
033        FAILED,
034
035        /**
036         * Expired.
037         */
038        EXPIRED,
039
040        /**
041         * User rejected.
042         */
043        USER_REJECTED,
044
045        /**
046         * Action pending.
047         */
048        ACTION_PENDING,
049
050        /**
051         * Unused.
052         */
053        UNUSED;
054
055        @JsonCreator
056        public static VerificationStatus fromString(String name) {
057                try {
058                        return VerificationStatus.valueOf(name.toUpperCase());
059                }
060                catch (IllegalArgumentException ex) {
061                        return null;
062                }
063        }
064
065        @JsonValue
066        @Override
067        public String toString() {
068                return name().toLowerCase();
069        }
070}