|
| 1 | +/* |
| 2 | + * Swagger Petstore |
| 3 | + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ |
| 4 | + * |
| 5 | + * OpenAPI spec version: 1.0.0 |
| 6 | + |
| 7 | + * |
| 8 | + * NOTE: This class is auto generated by the swagger code generator program. |
| 9 | + * https://github.com/swagger-api/swagger-codegen.git |
| 10 | + * Do not edit the class manually. |
| 11 | + */ |
| 12 | + |
| 13 | + |
| 14 | +package io.swagger.client.api; |
| 15 | + |
| 16 | +import io.swagger.client.ApiCallback; |
| 17 | +import io.swagger.client.ApiClient; |
| 18 | +import io.swagger.client.ApiException; |
| 19 | +import io.swagger.client.ApiResponse; |
| 20 | +import io.swagger.client.Configuration; |
| 21 | +import io.swagger.client.Pair; |
| 22 | +import io.swagger.client.ProgressRequestBody; |
| 23 | +import io.swagger.client.ProgressResponseBody; |
| 24 | + |
| 25 | +import com.google.gson.reflect.TypeToken; |
| 26 | + |
| 27 | +import java.io.IOException; |
| 28 | + |
| 29 | + |
| 30 | +import io.swagger.client.model.User; |
| 31 | + |
| 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 | +public class DefaultApi { |
| 39 | + private ApiClient apiClient; |
| 40 | + |
| 41 | + public DefaultApi() { |
| 42 | + this(Configuration.getDefaultApiClient()); |
| 43 | + } |
| 44 | + |
| 45 | + public DefaultApi(ApiClient apiClient) { |
| 46 | + this.apiClient = apiClient; |
| 47 | + } |
| 48 | + |
| 49 | + public ApiClient getApiClient() { |
| 50 | + return apiClient; |
| 51 | + } |
| 52 | + |
| 53 | + public void setApiClient(ApiClient apiClient) { |
| 54 | + this.apiClient = apiClient; |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * Build call for testBodyWithQueryParams |
| 59 | + * @param body (required) |
| 60 | + * @param query (required) |
| 61 | + * @param progressListener Progress listener |
| 62 | + * @param progressRequestListener Progress request listener |
| 63 | + * @return Call to execute |
| 64 | + * @throws ApiException If fail to serialize the request body object |
| 65 | + */ |
| 66 | + public com.squareup.okhttp.Call testBodyWithQueryParamsCall(User body, String query, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 67 | + Object localVarPostBody = body; |
| 68 | + |
| 69 | + // create path and map variables |
| 70 | + String localVarPath = "/fake/body-with-query-params"; |
| 71 | + |
| 72 | + List<Pair> localVarQueryParams = new ArrayList<Pair>(); |
| 73 | + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); |
| 74 | + if (query != null) |
| 75 | + localVarQueryParams.addAll(apiClient.parameterToPair("query", query)); |
| 76 | + |
| 77 | + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 78 | + |
| 79 | + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); |
| 80 | + |
| 81 | + final String[] localVarAccepts = { |
| 82 | + |
| 83 | + }; |
| 84 | + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); |
| 85 | + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); |
| 86 | + |
| 87 | + final String[] localVarContentTypes = { |
| 88 | + "application/json" |
| 89 | + }; |
| 90 | + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); |
| 91 | + localVarHeaderParams.put("Content-Type", localVarContentType); |
| 92 | + |
| 93 | + if(progressListener != null) { |
| 94 | + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { |
| 95 | + @Override |
| 96 | + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { |
| 97 | + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); |
| 98 | + return originalResponse.newBuilder() |
| 99 | + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) |
| 100 | + .build(); |
| 101 | + } |
| 102 | + }); |
| 103 | + } |
| 104 | + |
| 105 | + String[] localVarAuthNames = new String[] { }; |
| 106 | + return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); |
| 107 | + } |
| 108 | + |
| 109 | + @SuppressWarnings("rawtypes") |
| 110 | + private com.squareup.okhttp.Call testBodyWithQueryParamsValidateBeforeCall(User body, String query, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 111 | + |
| 112 | + // verify the required parameter 'body' is set |
| 113 | + if (body == null) { |
| 114 | + throw new ApiException("Missing the required parameter 'body' when calling testBodyWithQueryParams(Async)"); |
| 115 | + } |
| 116 | + |
| 117 | + // verify the required parameter 'query' is set |
| 118 | + if (query == null) { |
| 119 | + throw new ApiException("Missing the required parameter 'query' when calling testBodyWithQueryParams(Async)"); |
| 120 | + } |
| 121 | + |
| 122 | + |
| 123 | + com.squareup.okhttp.Call call = testBodyWithQueryParamsCall(body, query, progressListener, progressRequestListener); |
| 124 | + return call; |
| 125 | + |
| 126 | + } |
| 127 | + |
| 128 | + /** |
| 129 | + * |
| 130 | + * |
| 131 | + * @param body (required) |
| 132 | + * @param query (required) |
| 133 | + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
| 134 | + */ |
| 135 | + public void testBodyWithQueryParams(User body, String query) throws ApiException { |
| 136 | + testBodyWithQueryParamsWithHttpInfo(body, query); |
| 137 | + } |
| 138 | + |
| 139 | + /** |
| 140 | + * |
| 141 | + * |
| 142 | + * @param body (required) |
| 143 | + * @param query (required) |
| 144 | + * @return ApiResponse<Void> |
| 145 | + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
| 146 | + */ |
| 147 | + public ApiResponse<Void> testBodyWithQueryParamsWithHttpInfo(User body, String query) throws ApiException { |
| 148 | + com.squareup.okhttp.Call call = testBodyWithQueryParamsValidateBeforeCall(body, query, null, null); |
| 149 | + return apiClient.execute(call); |
| 150 | + } |
| 151 | + |
| 152 | + /** |
| 153 | + * (asynchronously) |
| 154 | + * |
| 155 | + * @param body (required) |
| 156 | + * @param query (required) |
| 157 | + * @param callback The callback to be executed when the API call finishes |
| 158 | + * @return The request call |
| 159 | + * @throws ApiException If fail to process the API call, e.g. serializing the request body object |
| 160 | + */ |
| 161 | + public com.squareup.okhttp.Call testBodyWithQueryParamsAsync(User body, String query, final ApiCallback<Void> callback) throws ApiException { |
| 162 | + |
| 163 | + ProgressResponseBody.ProgressListener progressListener = null; |
| 164 | + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; |
| 165 | + |
| 166 | + if (callback != null) { |
| 167 | + progressListener = new ProgressResponseBody.ProgressListener() { |
| 168 | + @Override |
| 169 | + public void update(long bytesRead, long contentLength, boolean done) { |
| 170 | + callback.onDownloadProgress(bytesRead, contentLength, done); |
| 171 | + } |
| 172 | + }; |
| 173 | + |
| 174 | + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { |
| 175 | + @Override |
| 176 | + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { |
| 177 | + callback.onUploadProgress(bytesWritten, contentLength, done); |
| 178 | + } |
| 179 | + }; |
| 180 | + } |
| 181 | + |
| 182 | + com.squareup.okhttp.Call call = testBodyWithQueryParamsValidateBeforeCall(body, query, progressListener, progressRequestListener); |
| 183 | + apiClient.executeAsync(call, callback); |
| 184 | + return call; |
| 185 | + } |
| 186 | +} |
0 commit comments