Java tutorial
/** * IdCheck.IO API * Check identity documents * * OpenAPI spec version: 0.0 * * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.ariadnext.idcheckio.api; import com.ariadnext.idcheckio.invoker.ApiCallback; import com.ariadnext.idcheckio.invoker.ApiClient; import com.ariadnext.idcheckio.invoker.ApiException; import com.ariadnext.idcheckio.invoker.ApiResponse; import com.ariadnext.idcheckio.invoker.Configuration; import com.ariadnext.idcheckio.invoker.Pair; import com.ariadnext.idcheckio.invoker.ProgressRequestBody; import com.ariadnext.idcheckio.invoker.ProgressResponseBody; import com.google.gson.reflect.TypeToken; import java.io.IOException; import com.ariadnext.idcheckio.model.ErrorResponse; import com.ariadnext.idcheckio.model.ImageListResponse; import com.ariadnext.idcheckio.model.MrzResponse; import com.ariadnext.idcheckio.model.MrzListResponse; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class SandboxApi { private ApiClient apiClient; public SandboxApi() { this(Configuration.getDefaultApiClient()); } public SandboxApi(ApiClient apiClient) { this.apiClient = apiClient; } public ApiClient getApiClient() { return apiClient; } public void setApiClient(ApiClient apiClient) { this.apiClient = apiClient; } /* Build call for getImage */ private com.squareup.okhttp.Call getImageCall(String imageUid, String rawType, String face, String light, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'imageUid' is set if (imageUid == null) { throw new ApiException("Missing the required parameter 'imageUid' when calling getImage(Async)"); } // create path and map variables String localVarPath = "/v0/sandbox/image/{imageUid}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "imageUid" + "\\}", apiClient.escapeString(imageUid.toString())); List<Pair> localVarQueryParams = new ArrayList<Pair>(); if (rawType != null) localVarQueryParams.addAll(apiClient.parameterToPairs("", "rawType", rawType)); if (face != null) localVarQueryParams.addAll(apiClient.parameterToPairs("", "face", face)); if (light != null) localVarQueryParams.addAll(apiClient.parameterToPairs("", "light", light)); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "*_/_*" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); if (progressListener != null) { apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { @Override public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build(); } }); } String[] localVarAuthNames = new String[] {}; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * HTTP GET image * GET image * @param imageUid EnumDemoDocsImage (required) * @param rawType Image raw type (optional) * @param face Image face (optional) * @param light Image light (optional) * @return List<byte[]> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public List<byte[]> getImage(String imageUid, String rawType, String face, String light) throws ApiException { ApiResponse<List<byte[]>> resp = getImageWithHttpInfo(imageUid, rawType, face, light); return resp.getData(); } /** * HTTP GET image * GET image * @param imageUid EnumDemoDocsImage (required) * @param rawType Image raw type (optional) * @param face Image face (optional) * @param light Image light (optional) * @return ApiResponse<List<byte[]>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<List<byte[]>> getImageWithHttpInfo(String imageUid, String rawType, String face, String light) throws ApiException { com.squareup.okhttp.Call call = getImageCall(imageUid, rawType, face, light, null, null); Type localVarReturnType = new TypeToken<List<byte[]>>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * HTTP GET image (asynchronously) * GET image * @param imageUid EnumDemoDocsImage (required) * @param rawType Image raw type (optional) * @param face Image face (optional) * @param light Image light (optional) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call getImageAsync(String imageUid, String rawType, String face, String light, final ApiCallback<List<byte[]>> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = getImageCall(imageUid, rawType, face, light, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<List<byte[]>>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for getImageList */ private com.squareup.okhttp.Call getImageListCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // create path and map variables String localVarPath = "/v0/sandbox/imagelist".replaceAll("\\{format\\}", "json"); List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json; charset=utf-8" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); if (progressListener != null) { apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { @Override public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build(); } }); } String[] localVarAuthNames = new String[] {}; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * HTTP GET images list * GET images list * @return ImageListResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ImageListResponse getImageList() throws ApiException { ApiResponse<ImageListResponse> resp = getImageListWithHttpInfo(); return resp.getData(); } /** * HTTP GET images list * GET images list * @return ApiResponse<ImageListResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<ImageListResponse> getImageListWithHttpInfo() throws ApiException { com.squareup.okhttp.Call call = getImageListCall(null, null); Type localVarReturnType = new TypeToken<ImageListResponse>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * HTTP GET images list (asynchronously) * GET images list * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call getImageListAsync(final ApiCallback<ImageListResponse> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = getImageListCall(progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<ImageListResponse>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for getMrz */ private com.squareup.okhttp.Call getMrzCall(String mrzUid, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'mrzUid' is set if (mrzUid == null) { throw new ApiException("Missing the required parameter 'mrzUid' when calling getMrz(Async)"); } // create path and map variables String localVarPath = "/v0/sandbox/mrz/{mrzUid}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "mrzUid" + "\\}", apiClient.escapeString(mrzUid.toString())); List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json; charset=utf-8" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); if (progressListener != null) { apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { @Override public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build(); } }); } String[] localVarAuthNames = new String[] {}; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * HTTP GET mrz * GET mrz * @param mrzUid EnumDemoDocsMrz (required) * @return MrzResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public MrzResponse getMrz(String mrzUid) throws ApiException { ApiResponse<MrzResponse> resp = getMrzWithHttpInfo(mrzUid); return resp.getData(); } /** * HTTP GET mrz * GET mrz * @param mrzUid EnumDemoDocsMrz (required) * @return ApiResponse<MrzResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<MrzResponse> getMrzWithHttpInfo(String mrzUid) throws ApiException { com.squareup.okhttp.Call call = getMrzCall(mrzUid, null, null); Type localVarReturnType = new TypeToken<MrzResponse>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * HTTP GET mrz (asynchronously) * GET mrz * @param mrzUid EnumDemoDocsMrz (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call getMrzAsync(String mrzUid, final ApiCallback<MrzResponse> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = getMrzCall(mrzUid, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<MrzResponse>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for getMrzList */ private com.squareup.okhttp.Call getMrzListCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // create path and map variables String localVarPath = "/v0/sandbox/mrzlist".replaceAll("\\{format\\}", "json"); List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json; charset=utf-8" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); if (progressListener != null) { apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { @Override public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build(); } }); } String[] localVarAuthNames = new String[] {}; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * HTTP GET mrz list * GET mrz list * @return MrzListResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public MrzListResponse getMrzList() throws ApiException { ApiResponse<MrzListResponse> resp = getMrzListWithHttpInfo(); return resp.getData(); } /** * HTTP GET mrz list * GET mrz list * @return ApiResponse<MrzListResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<MrzListResponse> getMrzListWithHttpInfo() throws ApiException { com.squareup.okhttp.Call call = getMrzListCall(null, null); Type localVarReturnType = new TypeToken<MrzListResponse>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * HTTP GET mrz list (asynchronously) * GET mrz list * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call getMrzListAsync(final ApiCallback<MrzListResponse> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = getMrzListCall(progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<MrzListResponse>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } }