Java tutorial
/** * AS24 API v4.1 * No descripton provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * OpenAPI spec version: v4.1 * * * 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 abtlibrary.utils.as24ApiClient.api; import abtlibrary.utils.as24ApiClient.ApiCallback; import abtlibrary.utils.as24ApiClient.ApiClient; import abtlibrary.utils.as24ApiClient.ApiException; import abtlibrary.utils.as24ApiClient.ApiResponse; import abtlibrary.utils.as24ApiClient.Configuration; import abtlibrary.utils.as24ApiClient.Pair; import abtlibrary.utils.as24ApiClient.ProgressRequestBody; import abtlibrary.utils.as24ApiClient.ProgressResponseBody; import com.google.gson.reflect.TypeToken; import java.io.IOException; import abtlibrary.utils.as24ApiClient.model.ResponseMessageCollectionListNewVehicle; import abtlibrary.utils.as24ApiClient.model.ResponseMessageCount; import abtlibrary.utils.as24ApiClient.model.ResponseMessageNewVehicle; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class NewCarApi { private ApiClient apiClient; public NewCarApi() { this(Configuration.getDefaultApiClient()); } public NewCarApi(ApiClient apiClient) { this.apiClient = apiClient; } public ApiClient getApiClient() { return apiClient; } public void setApiClient(ApiClient apiClient) { this.apiClient = apiClient; } /* Build call for gETpublicV41ConfiguratorNewvehicles */ private com.squareup.okhttp.Call gETpublicV41ConfiguratorNewvehiclesCall(Integer skip, Integer take, String filter, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'skip' is set if (skip == null) { throw new ApiException( "Missing the required parameter 'skip' when calling gETpublicV41ConfiguratorNewvehicles(Async)"); } // verify the required parameter 'take' is set if (take == null) { throw new ApiException( "Missing the required parameter 'take' when calling gETpublicV41ConfiguratorNewvehicles(Async)"); } // create path and map variables String localVarPath = "/public/v4.1/configurator/newvehicles".replaceAll("\\{format\\}", "json"); List<Pair> localVarQueryParams = new ArrayList<Pair>(); if (skip != null) localVarQueryParams.addAll(apiClient.parameterToPairs("", "skip", skip)); if (take != null) localVarQueryParams.addAll(apiClient.parameterToPairs("", "take", take)); if (filter != null) localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter", filter)); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json", "text/json" }; 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[] { "oauth2" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * * * @param skip (required) * @param take (required) * @param filter (optional) * @return ResponseMessageCollectionListNewVehicle * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ResponseMessageCollectionListNewVehicle gETpublicV41ConfiguratorNewvehicles(Integer skip, Integer take, String filter) throws ApiException { ApiResponse<ResponseMessageCollectionListNewVehicle> resp = gETpublicV41ConfiguratorNewvehiclesWithHttpInfo( skip, take, filter); return resp.getData(); } /** * * * @param skip (required) * @param take (required) * @param filter (optional) * @return ApiResponse<ResponseMessageCollectionListNewVehicle> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<ResponseMessageCollectionListNewVehicle> gETpublicV41ConfiguratorNewvehiclesWithHttpInfo( Integer skip, Integer take, String filter) throws ApiException { com.squareup.okhttp.Call call = gETpublicV41ConfiguratorNewvehiclesCall(skip, take, filter, null, null); Type localVarReturnType = new TypeToken<ResponseMessageCollectionListNewVehicle>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * (asynchronously) * * @param skip (required) * @param take (required) * @param filter (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 gETpublicV41ConfiguratorNewvehiclesAsync(Integer skip, Integer take, String filter, final ApiCallback<ResponseMessageCollectionListNewVehicle> 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 = gETpublicV41ConfiguratorNewvehiclesCall(skip, take, filter, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<ResponseMessageCollectionListNewVehicle>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for gETpublicV41ConfiguratorNewvehiclesCount */ private com.squareup.okhttp.Call gETpublicV41ConfiguratorNewvehiclesCountCall(String filter, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // create path and map variables String localVarPath = "/public/v4.1/configurator/newvehicles/count".replaceAll("\\{format\\}", "json"); List<Pair> localVarQueryParams = new ArrayList<Pair>(); if (filter != null) localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter", filter)); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json", "text/json" }; 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[] { "oauth2" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * * * @param filter (optional) * @return ResponseMessageCount * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ResponseMessageCount gETpublicV41ConfiguratorNewvehiclesCount(String filter) throws ApiException { ApiResponse<ResponseMessageCount> resp = gETpublicV41ConfiguratorNewvehiclesCountWithHttpInfo(filter); return resp.getData(); } /** * * * @param filter (optional) * @return ApiResponse<ResponseMessageCount> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<ResponseMessageCount> gETpublicV41ConfiguratorNewvehiclesCountWithHttpInfo(String filter) throws ApiException { com.squareup.okhttp.Call call = gETpublicV41ConfiguratorNewvehiclesCountCall(filter, null, null); Type localVarReturnType = new TypeToken<ResponseMessageCount>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * (asynchronously) * * @param filter (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 gETpublicV41ConfiguratorNewvehiclesCountAsync(String filter, final ApiCallback<ResponseMessageCount> 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 = gETpublicV41ConfiguratorNewvehiclesCountCall(filter, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<ResponseMessageCount>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for gETpublicV41ConfiguratorNewvehiclesNewvehicleid */ private com.squareup.okhttp.Call gETpublicV41ConfiguratorNewvehiclesNewvehicleidCall(Integer newVehicleId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'newVehicleId' is set if (newVehicleId == null) { throw new ApiException( "Missing the required parameter 'newVehicleId' when calling gETpublicV41ConfiguratorNewvehiclesNewvehicleid(Async)"); } // create path and map variables String localVarPath = "/public/v4.1/configurator/newvehicles/{newVehicleId}" .replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "newVehicleId" + "\\}", apiClient.escapeString(newVehicleId.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", "text/json" }; 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[] { "oauth2" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * * * @param newVehicleId (required) * @return ResponseMessageNewVehicle * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ResponseMessageNewVehicle gETpublicV41ConfiguratorNewvehiclesNewvehicleid(Integer newVehicleId) throws ApiException { ApiResponse<ResponseMessageNewVehicle> resp = gETpublicV41ConfiguratorNewvehiclesNewvehicleidWithHttpInfo( newVehicleId); return resp.getData(); } /** * * * @param newVehicleId (required) * @return ApiResponse<ResponseMessageNewVehicle> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<ResponseMessageNewVehicle> gETpublicV41ConfiguratorNewvehiclesNewvehicleidWithHttpInfo( Integer newVehicleId) throws ApiException { com.squareup.okhttp.Call call = gETpublicV41ConfiguratorNewvehiclesNewvehicleidCall(newVehicleId, null, null); Type localVarReturnType = new TypeToken<ResponseMessageNewVehicle>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * (asynchronously) * * @param newVehicleId (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 gETpublicV41ConfiguratorNewvehiclesNewvehicleidAsync(Integer newVehicleId, final ApiCallback<ResponseMessageNewVehicle> 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 = gETpublicV41ConfiguratorNewvehiclesNewvehicleidCall(newVehicleId, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<ResponseMessageNewVehicle>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } }