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.JsonProperty; 019import com.fasterxml.jackson.annotation.JsonValue; 020import com.vonage.client.JsonableBaseObject; 021import java.math.BigDecimal; 022import java.util.*; 023import java.util.function.Function; 024import java.util.stream.Collectors; 025 026public class VerifyDetails extends JsonableBaseObject { 027 private String requestId, accountId, number, senderId, currency; 028 private Date dateSubmitted, dateFinalized, firstEventDate, lastEventDate; 029 private Status status; 030 private BigDecimal price, estimatedPriceMessagesSent; 031 private List<VerifyCheck> checks = new ArrayList<>(0); 032 033 /** 034 * @return The {@code request_id} that you received in the response to the 035 * Verify request and used in the Verify search request. 036 */ 037 @JsonProperty("request_id") 038 public String getRequestId() { 039 return requestId; 040 } 041 042 /** 043 * @return The Vonage account ID the request was for. 044 */ 045 @JsonProperty("account_id") 046 public String getAccountId() { 047 return accountId; 048 } 049 050 /** 051 * @return The phone number this verification request was used for. 052 */ 053 @JsonProperty("number") 054 public String getNumber() { 055 return number; 056 } 057 058 /** 059 * @return The {@code sender_id} you provided in the Verify request. 060 */ 061 @JsonProperty("sender_id") 062 public String getSenderId() { 063 return senderId; 064 } 065 066 /** 067 * @return The date and time the verification request was submitted. 068 */ 069 @JsonProperty("date_submitted") 070 public Date getDateSubmitted() { 071 return dateSubmitted; 072 } 073 074 /** 075 * @return The date and time the verification request was completed. 076 */ 077 @JsonProperty("date_finalized") 078 public Date getDateFinalized() { 079 return dateFinalized; 080 } 081 082 /** 083 * @return The date and time the first verification attempt was made. 084 */ 085 @JsonProperty("first_event_date") 086 public Date getFirstEventDate() { 087 return firstEventDate; 088 } 089 090 /** 091 * @return The date and time the last verification attempt was made. 092 */ 093 @JsonProperty("last_event_date") 094 public Date getLastEventDate() { 095 return lastEventDate; 096 } 097 098 /** 099 * @return The status. 100 */ 101 @JsonProperty("status") 102 public Status getStatus() { 103 return status; 104 } 105 106 /** 107 * @return The cost incurred for this verification request. 108 */ 109 @JsonProperty("price") 110 public BigDecimal getPrice() { 111 return price; 112 } 113 114 /** 115 * @return The currency code. 116 */ 117 @JsonProperty("currency") 118 public String getCurrency() { 119 return currency; 120 } 121 122 /** 123 * @return The list of checks made for this verification and their outcomes. 124 */ 125 @JsonProperty("checks") 126 public List<VerifyCheck> getChecks() { 127 return checks; 128 } 129 130 /** 131 * @return This field may not be present, depending on your pricing model. 132 * The value indicates the cost (in EUR) of the calls made and messages sent for the verification process. 133 * This value may be updated during and shortly after the request completes because user input events can 134 * overlap with message/call events. When this field is present, the total cost of the verification is the 135 * sum of this field and the {@code price} field. 136 * 137 * @since 7.1.0 138 */ 139 @JsonProperty("estimated_price_messages_sent") 140 public BigDecimal getEstimatedPriceMessagesSent() { 141 return estimatedPriceMessagesSent; 142 } 143 144 public enum Status { 145 /** 146 * The search is still in progress. 147 */ 148 IN_PROGRESS("IN PROGRESS"), 149 /** 150 * Your user entered a correct verification code. 151 */ 152 SUCCESS("SUCCESS"), 153 /** 154 * Your user entered an incorrect code more than three times. 155 */ 156 FAILED("FAILED"), 157 /** 158 * Your user did not enter a code before the pin_expiry time elapsed. 159 */ 160 EXPIRED("EXPIRED"), 161 /** 162 * The verification process was cancelled by a Verify control request. 163 */ 164 CANCELLED("CANCELLED"), 165 /** 166 * You supplied an invalid {@code request_id}, or the data is not available. 167 * Note that for recently-completed requests, there can be a delay of up to 1 minute 168 * before the results are available in search. 169 */ 170 INVALID("101"); 171 172 private final String status; 173 174 private static final Map<String, Status> stringStatusValues = 175 Arrays.stream(Status.values()).collect(Collectors.toMap( 176 Status::getStatus, Function.identity() 177 )); 178 179 /** 180 * Look up the Status enum based on the string value. 181 * 182 * @param status the status value to lookup. 183 * @return VerifyStatus based on the int value given. 184 */ 185 public static Status fromString(String status) { 186 return stringStatusValues.get(status); 187 } 188 189 Status(String status) { 190 this.status = status; 191 } 192 193 @JsonValue 194 public String getStatus() { 195 return status; 196 } 197 } 198}