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 024import java.util.Date; 025import java.util.List; 026 027public class SearchResult extends BaseResult { 028 private String requestId; 029 private String accountId; 030 private VerificationStatus verificationStatus; 031 private String number; 032 private float price; 033 private String currency; 034 private String senderId; 035 private Date dateSubmitted; 036 private Date dateFinalized; 037 private Date firstEventDate; 038 private Date lastEventDate; 039 private List<VerifyCheck> checks; 040 041 /** 042 * Used to define a verify check attempt. 043 */ 044 public static class VerifyCheck implements java.io.Serializable { 045 046 private static final long serialVersionUID = -5933303841261513099L; 047 048 public enum Status { 049 VALID, INVALID, 050 } 051 052 private final Date date; 053 private final String code; 054 private final Status status; 055 private final String ipAddress; 056 057 public VerifyCheck(Date date, String code, Status status, String ipAddress) { 058 this.date = date; 059 this.code = code; 060 this.status = status; 061 this.ipAddress = ipAddress; 062 } 063 064 public Date getDate() { 065 return this.date; 066 } 067 068 public String getCode() { 069 return this.code; 070 } 071 072 public Status getStatus() { 073 return this.status; 074 } 075 076 public String getIpAddress() { 077 return this.ipAddress; 078 } 079 080 @Override 081 public String toString() { 082 return "VerifyCheck [status=" + this.status + ", code=" + this.code + ", date=" + this.date + "]"; 083 } 084 085 } 086 087 public enum VerificationStatus { 088 089 IN_PROGRESS("IN PROGRESS"), SUCCESS, FAILED, EXPIRED; 090 091 private final String name; 092 093 VerificationStatus() { 094 this(null); 095 } 096 097 VerificationStatus(String name) { 098 this.name = name; 099 } 100 101 public String getName() { 102 return this.name != null ? this.name : name(); 103 } 104 105 @Override 106 public String toString() { 107 return getName(); 108 } 109 110 } 111 112 public SearchResult(final int status, 113 final String requestId, 114 final String accountId, 115 final VerificationStatus verificationStatus, 116 final String number, 117 final float price, 118 final String currency, 119 final String senderId, 120 final Date dateSubmitted, 121 final Date dateFinalized, 122 final Date firstEventDate, 123 final Date lastEventDate, 124 final List<VerifyCheck> checks, 125 final String errorText, 126 final boolean temporaryError) { 127 super(status, errorText, temporaryError); 128 this.requestId = requestId; 129 this.accountId = accountId; 130 this.verificationStatus = verificationStatus; 131 this.number = number; 132 this.price = price; 133 this.currency = currency; 134 this.senderId = senderId; 135 this.dateSubmitted = dateSubmitted; 136 this.dateFinalized = dateFinalized; 137 this.firstEventDate = firstEventDate; 138 this.lastEventDate = lastEventDate; 139 this.checks = checks; 140 } 141 142 SearchResult(int status, String errorText, boolean temporaryError) { 143 super(status, errorText, temporaryError); 144 } 145 146 public String getRequestId() { 147 return this.requestId; 148 } 149 150 public String getAccountId() { 151 return this.accountId; 152 } 153 154 public VerificationStatus getVerificationStatus() { 155 return this.verificationStatus; 156 } 157 158 public String getNumber() { 159 return this.number; 160 } 161 162 public float getPrice() { 163 return this.price; 164 } 165 166 public String getCurrency() { 167 return this.currency; 168 } 169 170 public String getSenderId() { 171 return this.senderId; 172 } 173 174 public Date getDateSubmitted() { 175 return this.dateSubmitted; 176 } 177 178 public Date getDateFinalized() { 179 return this.dateFinalized; 180 } 181 182 public Date getFirstEventDate() { 183 return this.firstEventDate; 184 } 185 186 public Date getLastEventDate() { 187 return this.lastEventDate; 188 } 189 190 public List<VerifyCheck> getChecks() { 191 return this.checks; 192 } 193 194 @Override 195 public String toString() { 196 return "SearchResult [status=" + getStatus() + ", requestId=" + this.requestId + ", verificationStatus=" + this.verificationStatus + "]"; 197 } 198 199}