Java tutorial
/** * CloudEmotion API v1 * CrowdEmotion API * * OpenAPI spec version: 1.1.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 co.uk.crowdemotion; import co.uk.crowdemotion.ApiCallback; import co.uk.crowdemotion.ApiClient; import co.uk.crowdemotion.ApiException; import co.uk.crowdemotion.ApiResponse; import co.uk.crowdemotion.Configuration; import co.uk.crowdemotion.Pair; import co.uk.crowdemotion.ProgressRequestBody; import co.uk.crowdemotion.ProgressResponseBody; import com.google.gson.reflect.TypeToken; import java.io.IOException; import io.swagger.client.model.Respondent; import io.swagger.client.model.RespondentMetadataResponse; import io.swagger.client.model.RespondentMetadata; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class RespondentApi { private ApiClient apiClient; public RespondentApi() { this(Configuration.getDefaultApiClient()); } public RespondentApi(ApiClient apiClient) { this.apiClient = apiClient; } public ApiClient getApiClient() { return apiClient; } public void setApiClient(ApiClient apiClient) { this.apiClient = apiClient; } /* Build call for respondentGet */ private com.squareup.okhttp.Call respondentGetCall(Integer researchId, Integer skip, Integer limit, String where, String sort, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'researchId' is set if (researchId == null) { throw new ApiException("Missing the required parameter 'researchId' when calling respondentGet(Async)"); } // create path and map variables String localVarPath = "/respondent".replaceAll("\\{format\\}", "json"); List<Pair> localVarQueryParams = new ArrayList<Pair>(); if (researchId != null) localVarQueryParams.addAll(apiClient.parameterToPairs("", "research_id", researchId)); if (skip != null) localVarQueryParams.addAll(apiClient.parameterToPairs("", "skip", skip)); if (limit != null) localVarQueryParams.addAll(apiClient.parameterToPairs("", "limit", limit)); if (where != null) localVarQueryParams.addAll(apiClient.parameterToPairs("", "where", where)); if (sort != null) localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort", sort)); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json" }; 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[] { "api_key" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Find all Respondents of a Research * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param researchId Search by research id. (required) * @param skip The number of results to skip. (optional) * @param limit The maximum number of results to return. (optional) * @param where JSON formatted string. (optional) * @param sort Attribute used to sort results. (optional) * @return List<Respondent> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public List<Respondent> respondentGet(Integer researchId, Integer skip, Integer limit, String where, String sort) throws ApiException { ApiResponse<List<Respondent>> resp = respondentGetWithHttpInfo(researchId, skip, limit, where, sort); return resp.getData(); } /** * Find all Respondents of a Research * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param researchId Search by research id. (required) * @param skip The number of results to skip. (optional) * @param limit The maximum number of results to return. (optional) * @param where JSON formatted string. (optional) * @param sort Attribute used to sort results. (optional) * @return ApiResponse<List<Respondent>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<List<Respondent>> respondentGetWithHttpInfo(Integer researchId, Integer skip, Integer limit, String where, String sort) throws ApiException { com.squareup.okhttp.Call call = respondentGetCall(researchId, skip, limit, where, sort, null, null); Type localVarReturnType = new TypeToken<List<Respondent>>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Find all Respondents of a Research (asynchronously) * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param researchId Search by research id. (required) * @param skip The number of results to skip. (optional) * @param limit The maximum number of results to return. (optional) * @param where JSON formatted string. (optional) * @param sort Attribute used to sort results. (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 respondentGetAsync(Integer researchId, Integer skip, Integer limit, String where, String sort, final ApiCallback<List<Respondent>> 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 = respondentGetCall(researchId, skip, limit, where, sort, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<List<Respondent>>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for respondentPost */ private com.squareup.okhttp.Call respondentPostCall(Respondent body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set if (body == null) { throw new ApiException("Missing the required parameter 'body' when calling respondentPost(Async)"); } // create path and map variables String localVarPath = "/respondent".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" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json" }; 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[] { "api_key" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Create a Respondent * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param body Request body (required) * @return Respondent * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public Respondent respondentPost(Respondent body) throws ApiException { ApiResponse<Respondent> resp = respondentPostWithHttpInfo(body); return resp.getData(); } /** * Create a Respondent * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param body Request body (required) * @return ApiResponse<Respondent> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<Respondent> respondentPostWithHttpInfo(Respondent body) throws ApiException { com.squareup.okhttp.Call call = respondentPostCall(body, null, null); Type localVarReturnType = new TypeToken<Respondent>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Create a Respondent (asynchronously) * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param body Request body (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 respondentPostAsync(Respondent body, final ApiCallback<Respondent> 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 = respondentPostCall(body, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<Respondent>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for respondentRespondentIdDelete */ private com.squareup.okhttp.Call respondentRespondentIdDeleteCall(Integer respondentId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'respondentId' is set if (respondentId == null) { throw new ApiException( "Missing the required parameter 'respondentId' when calling respondentRespondentIdDelete(Async)"); } // create path and map variables String localVarPath = "/respondent/{respondent_id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "respondent_id" + "\\}", apiClient.escapeString(respondentId.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" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json" }; 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[] { "api_key" }; return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Delete a Respondent * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId (required) * @return String * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public String respondentRespondentIdDelete(Integer respondentId) throws ApiException { ApiResponse<String> resp = respondentRespondentIdDeleteWithHttpInfo(respondentId); return resp.getData(); } /** * Delete a Respondent * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId (required) * @return ApiResponse<String> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<String> respondentRespondentIdDeleteWithHttpInfo(Integer respondentId) throws ApiException { com.squareup.okhttp.Call call = respondentRespondentIdDeleteCall(respondentId, null, null); Type localVarReturnType = new TypeToken<String>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Delete a Respondent (asynchronously) * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId (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 respondentRespondentIdDeleteAsync(Integer respondentId, final ApiCallback<String> 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 = respondentRespondentIdDeleteCall(respondentId, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<String>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for respondentRespondentIdGet */ private com.squareup.okhttp.Call respondentRespondentIdGetCall(Integer respondentId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'respondentId' is set if (respondentId == null) { throw new ApiException( "Missing the required parameter 'respondentId' when calling respondentRespondentIdGet(Async)"); } // create path and map variables String localVarPath = "/respondent/{respondent_id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "respondent_id" + "\\}", apiClient.escapeString(respondentId.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" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json" }; 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[] { "api_key" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Find a Respondent * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId Search by research id. (required) * @return Respondent * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public Respondent respondentRespondentIdGet(Integer respondentId) throws ApiException { ApiResponse<Respondent> resp = respondentRespondentIdGetWithHttpInfo(respondentId); return resp.getData(); } /** * Find a Respondent * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId Search by research id. (required) * @return ApiResponse<Respondent> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<Respondent> respondentRespondentIdGetWithHttpInfo(Integer respondentId) throws ApiException { com.squareup.okhttp.Call call = respondentRespondentIdGetCall(respondentId, null, null); Type localVarReturnType = new TypeToken<Respondent>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Find a Respondent (asynchronously) * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId Search by research id. (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 respondentRespondentIdGetAsync(Integer respondentId, final ApiCallback<Respondent> 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 = respondentRespondentIdGetCall(respondentId, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<Respondent>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for respondentRespondentIdMetadataGet */ private com.squareup.okhttp.Call respondentRespondentIdMetadataGetCall(Integer respondentId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'respondentId' is set if (respondentId == null) { throw new ApiException( "Missing the required parameter 'respondentId' when calling respondentRespondentIdMetadataGet(Async)"); } // create path and map variables String localVarPath = "/respondent/{respondent_id}/metadata".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "respondent_id" + "\\}", apiClient.escapeString(respondentId.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" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json" }; 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[] { "api_key" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Find Respondent Metadata * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId ID of the Respondent (required) * @return RespondentMetadataResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public RespondentMetadataResponse respondentRespondentIdMetadataGet(Integer respondentId) throws ApiException { ApiResponse<RespondentMetadataResponse> resp = respondentRespondentIdMetadataGetWithHttpInfo(respondentId); return resp.getData(); } /** * Find Respondent Metadata * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId ID of the Respondent (required) * @return ApiResponse<RespondentMetadataResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<RespondentMetadataResponse> respondentRespondentIdMetadataGetWithHttpInfo( Integer respondentId) throws ApiException { com.squareup.okhttp.Call call = respondentRespondentIdMetadataGetCall(respondentId, null, null); Type localVarReturnType = new TypeToken<RespondentMetadataResponse>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Find Respondent Metadata (asynchronously) * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId ID of the Respondent (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 respondentRespondentIdMetadataGetAsync(Integer respondentId, final ApiCallback<RespondentMetadataResponse> 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 = respondentRespondentIdMetadataGetCall(respondentId, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<RespondentMetadataResponse>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for respondentRespondentIdMetadataPost */ private com.squareup.okhttp.Call respondentRespondentIdMetadataPostCall(Integer respondentId, RespondentMetadata body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'respondentId' is set if (respondentId == null) { throw new ApiException( "Missing the required parameter 'respondentId' when calling respondentRespondentIdMetadataPost(Async)"); } // verify the required parameter 'body' is set if (body == null) { throw new ApiException( "Missing the required parameter 'body' when calling respondentRespondentIdMetadataPost(Async)"); } // create path and map variables String localVarPath = "/respondent/{respondent_id}/metadata".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "respondent_id" + "\\}", apiClient.escapeString(respondentId.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" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json" }; 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[] { "api_key" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Add Respondent Metadata * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId (required) * @param body Request body (required) * @return RespondentMetadataResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public RespondentMetadataResponse respondentRespondentIdMetadataPost(Integer respondentId, RespondentMetadata body) throws ApiException { ApiResponse<RespondentMetadataResponse> resp = respondentRespondentIdMetadataPostWithHttpInfo(respondentId, body); return resp.getData(); } /** * Add Respondent Metadata * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId (required) * @param body Request body (required) * @return ApiResponse<RespondentMetadataResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<RespondentMetadataResponse> respondentRespondentIdMetadataPostWithHttpInfo( Integer respondentId, RespondentMetadata body) throws ApiException { com.squareup.okhttp.Call call = respondentRespondentIdMetadataPostCall(respondentId, body, null, null); Type localVarReturnType = new TypeToken<RespondentMetadataResponse>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Add Respondent Metadata (asynchronously) * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId (required) * @param body Request body (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 respondentRespondentIdMetadataPostAsync(Integer respondentId, RespondentMetadata body, final ApiCallback<RespondentMetadataResponse> 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 = respondentRespondentIdMetadataPostCall(respondentId, body, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<RespondentMetadataResponse>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for respondentRespondentIdPut */ private com.squareup.okhttp.Call respondentRespondentIdPutCall(Integer respondentId, Respondent body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'respondentId' is set if (respondentId == null) { throw new ApiException( "Missing the required parameter 'respondentId' when calling respondentRespondentIdPut(Async)"); } // verify the required parameter 'body' is set if (body == null) { throw new ApiException( "Missing the required parameter 'body' when calling respondentRespondentIdPut(Async)"); } // create path and map variables String localVarPath = "/respondent/{respondent_id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "respondent_id" + "\\}", apiClient.escapeString(respondentId.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" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json" }; 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[] { "api_key" }; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Update a Respondent * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId (required) * @param body Request body (required) * @return Respondent * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public Respondent respondentRespondentIdPut(Integer respondentId, Respondent body) throws ApiException { ApiResponse<Respondent> resp = respondentRespondentIdPutWithHttpInfo(respondentId, body); return resp.getData(); } /** * Update a Respondent * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId (required) * @param body Request body (required) * @return ApiResponse<Respondent> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<Respondent> respondentRespondentIdPutWithHttpInfo(Integer respondentId, Respondent body) throws ApiException { com.squareup.okhttp.Call call = respondentRespondentIdPutCall(respondentId, body, null, null); Type localVarReturnType = new TypeToken<Respondent>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Update a Respondent (asynchronously) * <p><strong>Permissions:</strong> Respondent Customer Manager</p> * @param respondentId (required) * @param body Request body (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 respondentRespondentIdPutAsync(Integer respondentId, Respondent body, final ApiCallback<Respondent> 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 = respondentRespondentIdPutCall(respondentId, body, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<Respondent>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } }