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.vonage.client.QueryParamsRequest; 019import java.util.LinkedHashMap; 020import java.util.Map; 021 022/** 023 * Request used in {@link VerifyClient#check(CheckRequest)}. 024 * 025 * @deprecated This will be made package-private in the next major release. 026 */ 027@Deprecated 028public class CheckRequest implements QueryParamsRequest { 029 private final String requestId, code; 030 031 /** 032 * Creates a new CheckRequest. 033 * 034 * @param requestId The Verify request to check. 035 * This is the request_id you received in the response to the Verify request. 036 * 037 * @param code The verification code entered by your user. Between 4 and 6 characters. 038 */ 039 public CheckRequest(String requestId, String code) { 040 if ((this.requestId = requestId) == null) { 041 throw new IllegalArgumentException("request_id is required"); 042 } 043 if ((this.code = code) == null) { 044 throw new IllegalArgumentException("code is required"); 045 } 046 if (requestId.length() > 32) { 047 throw new IllegalArgumentException("request_id '"+requestId+"' is longer than 32 characters"); 048 } 049 if (code.length() < 4 || code.length() > 6) { 050 throw new IllegalArgumentException("code '"+code+"' is not between 4 and 6 characters long"); 051 } 052 } 053 054 /** 055 * This is the request_id you received in the response to the Verify request. 056 * 057 * @return The Verify request to check. 058 */ 059 public String getRequestId() { 060 return requestId; 061 } 062 063 /** 064 * PIN code entered by the user. 065 * 066 * @return The verification code entered by your user. 067 */ 068 public String getCode() { 069 return code; 070 } 071 072 @Override 073 public Map<String, String> makeParams() { 074 Map<String, String> params = new LinkedHashMap<>(4); 075 params.put("request_id", requestId); 076 params.put("code", code); 077 return params; 078 } 079}