|
| 1 | +/** |
| 2 | + * -------------------------------------------------------------------------------------------------------------------- |
| 3 | + * <copyright company="Aspose Pty Ltd" file="InfoApi.java"> |
| 4 | + * Copyright (c) 2003-2019 Aspose Pty Ltd |
| 5 | + * </copyright> |
| 6 | + * <summary> |
| 7 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | + * of this software and associated documentation files (the "Software"), to deal |
| 9 | + * in the Software without restriction, including without limitation the rights |
| 10 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | + * copies of the Software, and to permit persons to whom the Software is |
| 12 | + * furnished to do so, subject to the following conditions: |
| 13 | + * |
| 14 | + * The above copyright notice and this permission notice shall be included in all |
| 15 | + * copies or substantial portions of the Software. |
| 16 | + * |
| 17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | + * SOFTWARE. |
| 24 | + * </summary> |
| 25 | + * -------------------------------------------------------------------------------------------------------------------- |
| 26 | + */ |
| 27 | + |
| 28 | +package com.groupdocs.cloud.viewer.api; |
| 29 | + |
| 30 | +import java.io.File; |
| 31 | +import java.io.IOException; |
| 32 | +import java.lang.reflect.Type; |
| 33 | +import java.util.ArrayList; |
| 34 | +import java.util.HashMap; |
| 35 | +import java.util.List; |
| 36 | +import java.util.Map; |
| 37 | + |
| 38 | +import com.google.gson.reflect.TypeToken; |
| 39 | +import com.groupdocs.cloud.viewer.client.*; |
| 40 | +import com.groupdocs.cloud.viewer.model.*; |
| 41 | +import com.groupdocs.cloud.viewer.model.requests.*; |
| 42 | + |
| 43 | +public class InfoApi { |
| 44 | + private ApiClient apiClient; |
| 45 | + |
| 46 | + /** |
| 47 | + * Initializes new instance of InfoApi |
| 48 | + * @param appSid Application identifier (App SID) |
| 49 | + * @param appKey Application private key (App Key) |
| 50 | + */ |
| 51 | + public InfoApi(String appSid, String appKey) { |
| 52 | + this(new Configuration(appSid, appKey)); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * Initializes new instance of InfoApi |
| 57 | + * @param configuration Configuration The configuration |
| 58 | + */ |
| 59 | + public InfoApi(Configuration configuration) { |
| 60 | + this.apiClient = new ApiClient(configuration); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * Gets ApiClient |
| 65 | + * |
| 66 | + * @return ApiClient The Api client |
| 67 | + */ |
| 68 | + public ApiClient getApiClient() { |
| 69 | + return apiClient; |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Sets ApiClient |
| 74 | + * |
| 75 | + * @param apiClient The Api client |
| 76 | + */ |
| 77 | + public void setApiClient(ApiClient apiClient) { |
| 78 | + this.apiClient = apiClient; |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Build call for getInfo |
| 83 | + * @param request The request model |
| 84 | + * @param progressListener Progress listener |
| 85 | + * @param progressRequestListener Progress request listener |
| 86 | + * @return Call to execute |
| 87 | + * @throws ApiException If fail to serialize the request body object |
| 88 | + */ |
| 89 | + public com.squareup.okhttp.Call getInfoCall(GetInfoRequest request, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 90 | + Object localVarPostBody = request.getviewOptions(); |
| 91 | + |
| 92 | + // create path and map variables |
| 93 | + String localVarPath = "/viewer/info"; |
| 94 | + |
| 95 | + List<Pair> localVarQueryParams = new ArrayList<Pair>(); |
| 96 | + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); |
| 97 | + |
| 98 | + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 99 | + |
| 100 | + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); |
| 101 | + |
| 102 | + final String[] localVarAccepts = { |
| 103 | + "application/json" |
| 104 | + }; |
| 105 | + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); |
| 106 | + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); |
| 107 | + |
| 108 | + final String[] localVarContentTypes = { |
| 109 | + "application/json" |
| 110 | + }; |
| 111 | + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); |
| 112 | + localVarHeaderParams.put("Content-Type", localVarContentType); |
| 113 | + |
| 114 | + if(progressListener != null) { |
| 115 | + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { |
| 116 | + @Override |
| 117 | + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { |
| 118 | + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); |
| 119 | + return originalResponse.newBuilder() |
| 120 | + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) |
| 121 | + .build(); |
| 122 | + } |
| 123 | + }); |
| 124 | + } |
| 125 | + |
| 126 | + String[] localVarAuthNames = new String[] { "JWT" }; |
| 127 | + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); |
| 128 | + } |
| 129 | + |
| 130 | + @SuppressWarnings("rawtypes") |
| 131 | + private com.squareup.okhttp.Call getInfoValidateBeforeCall(GetInfoRequest request, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 132 | + |
| 133 | + // verify the required parameter 'viewOptions' is set |
| 134 | + if (request.getviewOptions() == null) { |
| 135 | + throw new ApiException("Missing the required parameter 'viewOptions' when calling getInfo(Async)"); |
| 136 | + } |
| 137 | + |
| 138 | + |
| 139 | + com.squareup.okhttp.Call call = getInfoCall(request, progressListener, progressRequestListener); |
| 140 | + return call; |
| 141 | + |
| 142 | + } |
| 143 | + |
| 144 | + /** |
| 145 | + * Retrieve information about document pages |
| 146 | + * |
| 147 | + * @param request The request model |
| 148 | + * @return InfoResult |
| 149 | + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
| 150 | + */ |
| 151 | + public InfoResult getInfo(GetInfoRequest request) throws ApiException { |
| 152 | + ApiResponse<InfoResult> resp = getInfoWithHttpInfo(request); |
| 153 | + return resp.getData(); |
| 154 | + } |
| 155 | + |
| 156 | + /** |
| 157 | + * Retrieve information about document pages |
| 158 | + * |
| 159 | + * @param request The request model |
| 160 | + * @return ApiResponse<InfoResult> |
| 161 | + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
| 162 | + */ |
| 163 | + public ApiResponse<InfoResult> getInfoWithHttpInfo(GetInfoRequest request) throws ApiException { |
| 164 | + com.squareup.okhttp.Call call = getInfoValidateBeforeCall(request, null, null); |
| 165 | + Type localVarReturnType = new TypeToken<InfoResult>(){}.getType(); |
| 166 | + return apiClient.execute(call, localVarReturnType); |
| 167 | + } |
| 168 | + |
| 169 | + /** |
| 170 | + * Retrieve information about document pages (asynchronously) |
| 171 | + * |
| 172 | + * @param request The request model |
| 173 | + * @param callback The callback to be executed when the API call finishes |
| 174 | + * @return The request call |
| 175 | + * @throws ApiException If fail to process the API call, e.g. serializing the request body object |
| 176 | + */ |
| 177 | + public com.squareup.okhttp.Call getInfoAsync(GetInfoRequest request, final ApiCallback<InfoResult> callback) throws ApiException { |
| 178 | + |
| 179 | + ProgressResponseBody.ProgressListener progressListener = null; |
| 180 | + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; |
| 181 | + |
| 182 | + if (callback != null) { |
| 183 | + progressListener = new ProgressResponseBody.ProgressListener() { |
| 184 | + @Override |
| 185 | + public void update(long bytesRead, long contentLength, boolean done) { |
| 186 | + callback.onDownloadProgress(bytesRead, contentLength, done); |
| 187 | + } |
| 188 | + }; |
| 189 | + |
| 190 | + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { |
| 191 | + @Override |
| 192 | + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { |
| 193 | + callback.onUploadProgress(bytesWritten, contentLength, done); |
| 194 | + } |
| 195 | + }; |
| 196 | + } |
| 197 | + |
| 198 | + com.squareup.okhttp.Call call = getInfoValidateBeforeCall(request, progressListener, progressRequestListener); |
| 199 | + Type localVarReturnType = new TypeToken<InfoResult>(){}.getType(); |
| 200 | + apiClient.executeAsync(call, localVarReturnType, callback); |
| 201 | + return call; |
| 202 | + } |
| 203 | + /** |
| 204 | + * Build call for getSupportedFileFormats |
| 205 | + * @param progressListener Progress listener |
| 206 | + * @param progressRequestListener Progress request listener |
| 207 | + * @return Call to execute |
| 208 | + * @throws ApiException If fail to serialize the request body object |
| 209 | + */ |
| 210 | + public com.squareup.okhttp.Call getSupportedFileFormatsCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 211 | + Object localVarPostBody = null; |
| 212 | + |
| 213 | + // create path and map variables |
| 214 | + String localVarPath = "/viewer/formats"; |
| 215 | + |
| 216 | + List<Pair> localVarQueryParams = new ArrayList<Pair>(); |
| 217 | + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); |
| 218 | + |
| 219 | + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 220 | + |
| 221 | + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); |
| 222 | + |
| 223 | + final String[] localVarAccepts = { |
| 224 | + "application/json" |
| 225 | + }; |
| 226 | + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); |
| 227 | + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); |
| 228 | + |
| 229 | + final String[] localVarContentTypes = { |
| 230 | + "application/json" |
| 231 | + }; |
| 232 | + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); |
| 233 | + localVarHeaderParams.put("Content-Type", localVarContentType); |
| 234 | + |
| 235 | + if(progressListener != null) { |
| 236 | + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { |
| 237 | + @Override |
| 238 | + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { |
| 239 | + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); |
| 240 | + return originalResponse.newBuilder() |
| 241 | + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) |
| 242 | + .build(); |
| 243 | + } |
| 244 | + }); |
| 245 | + } |
| 246 | + |
| 247 | + String[] localVarAuthNames = new String[] { "JWT" }; |
| 248 | + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); |
| 249 | + } |
| 250 | + |
| 251 | + @SuppressWarnings("rawtypes") |
| 252 | + private com.squareup.okhttp.Call getSupportedFileFormatsValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 253 | + |
| 254 | + |
| 255 | + com.squareup.okhttp.Call call = getSupportedFileFormatsCall(progressListener, progressRequestListener); |
| 256 | + return call; |
| 257 | + |
| 258 | + } |
| 259 | + |
| 260 | + /** |
| 261 | + * List supported file formats |
| 262 | + * |
| 263 | + * @return FormatsResult |
| 264 | + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
| 265 | + */ |
| 266 | + public FormatsResult getSupportedFileFormats() throws ApiException { |
| 267 | + ApiResponse<FormatsResult> resp = getSupportedFileFormatsWithHttpInfo(); |
| 268 | + return resp.getData(); |
| 269 | + } |
| 270 | + |
| 271 | + /** |
| 272 | + * List supported file formats |
| 273 | + * |
| 274 | + * @return ApiResponse<FormatsResult> |
| 275 | + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
| 276 | + */ |
| 277 | + public ApiResponse<FormatsResult> getSupportedFileFormatsWithHttpInfo() throws ApiException { |
| 278 | + com.squareup.okhttp.Call call = getSupportedFileFormatsValidateBeforeCall(null, null); |
| 279 | + Type localVarReturnType = new TypeToken<FormatsResult>(){}.getType(); |
| 280 | + return apiClient.execute(call, localVarReturnType); |
| 281 | + } |
| 282 | + |
| 283 | + /** |
| 284 | + * List supported file formats (asynchronously) |
| 285 | + * |
| 286 | + * @param callback The callback to be executed when the API call finishes |
| 287 | + * @return The request call |
| 288 | + * @throws ApiException If fail to process the API call, e.g. serializing the request body object |
| 289 | + */ |
| 290 | + public com.squareup.okhttp.Call getSupportedFileFormatsAsync(final ApiCallback<FormatsResult> callback) throws ApiException { |
| 291 | + |
| 292 | + ProgressResponseBody.ProgressListener progressListener = null; |
| 293 | + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; |
| 294 | + |
| 295 | + if (callback != null) { |
| 296 | + progressListener = new ProgressResponseBody.ProgressListener() { |
| 297 | + @Override |
| 298 | + public void update(long bytesRead, long contentLength, boolean done) { |
| 299 | + callback.onDownloadProgress(bytesRead, contentLength, done); |
| 300 | + } |
| 301 | + }; |
| 302 | + |
| 303 | + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { |
| 304 | + @Override |
| 305 | + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { |
| 306 | + callback.onUploadProgress(bytesWritten, contentLength, done); |
| 307 | + } |
| 308 | + }; |
| 309 | + } |
| 310 | + |
| 311 | + com.squareup.okhttp.Call call = getSupportedFileFormatsValidateBeforeCall(progressListener, progressRequestListener); |
| 312 | + Type localVarReturnType = new TypeToken<FormatsResult>(){}.getType(); |
| 313 | + apiClient.executeAsync(call, localVarReturnType, callback); |
| 314 | + return call; |
| 315 | + } |
| 316 | +} |
| 317 | + |
0 commit comments