com.sphereon.sdk.template.processor.api.AllApi.java Source code

Java tutorial

Introduction

Here is the source code for com.sphereon.sdk.template.processor.api.AllApi.java

Source

/**
 * Template-Processor
 * <b>The Template-Processor API can generate office, xml and json documents from a template and a JSON data file. Supported templates are MS Office files and freemarker files.<</b>    The flow is generally as follows:      <b>Interactive testing: </b>A web based test console is available in the <a href=\"https://store.sphereon.com\">Sphereon API Store</a>
 *
 * OpenAPI spec version: 0.1
 * Contact: dev@sphereon.com
 *
 * 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.sphereon.sdk.template.processor.api;

import com.sphereon.sdk.template.processor.handler.ApiCallback;
import com.sphereon.sdk.template.processor.handler.ApiClient;
import com.sphereon.sdk.template.processor.handler.ApiException;
import com.sphereon.sdk.template.processor.handler.ApiResponse;
import com.sphereon.sdk.template.processor.handler.Configuration;
import com.sphereon.sdk.template.processor.handler.Pair;
import com.sphereon.sdk.template.processor.handler.ProgressRequestBody;
import com.sphereon.sdk.template.processor.handler.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;

import com.sphereon.sdk.template.processor.model.DataSetResponse;
import com.sphereon.sdk.template.processor.model.ErrorResponse;
import com.sphereon.sdk.template.processor.model.TemplateContextResponse;
import com.sphereon.sdk.template.processor.model.TemplateContextRequest;
import com.sphereon.sdk.template.processor.model.MergeJobResponse;
import com.sphereon.sdk.template.processor.model.OutputSettings;
import com.sphereon.sdk.template.processor.model.MergeSettings;
import java.io.File;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AllApi {
    private ApiClient apiClient;

    public AllApi() {
        this(Configuration.getDefaultApiClient());
    }

    public AllApi(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return apiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    /* Build call for createDataSet */
    private com.squareup.okhttp.Call createDataSetCall(String payload,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = payload;

        // verify the required parameter 'payload' is set
        if (payload == null) {
            throw new ApiException("Missing the required parameter 'payload' when calling createDataSet(Async)");
        }

        // create path and map variables
        String localVarPath = "/template/processor/0.1/datasets".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 = { "application/json;charset=UTF-8" };
        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[] { "oauth2schema" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody,
                localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Store dataset
     * Upload and store a data set. Currently only JSON is supported. This call returns an id which can be specified when submitting a merge job.
     * @param payload The dates for the merge [   {     \&quot;Field1\&quot;: \&quot;Field1 value\&quot;,     \&quot;Field2\&quot;: \&quot;Field2 value\&quot;,   },   {     \&quot;Field1\&quot;: \&quot;Field1 value\&quot;,     \&quot;Field2\&quot;: \&quot;Field2 value\&quot;,   } ] (required)
     * @return DataSetResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public DataSetResponse createDataSet(String payload) throws ApiException {
        ApiResponse<DataSetResponse> resp = createDataSetWithHttpInfo(payload);
        return resp.getData();
    }

    /**
     * Store dataset
     * Upload and store a data set. Currently only JSON is supported. This call returns an id which can be specified when submitting a merge job.
     * @param payload The dates for the merge [   {     \&quot;Field1\&quot;: \&quot;Field1 value\&quot;,     \&quot;Field2\&quot;: \&quot;Field2 value\&quot;,   },   {     \&quot;Field1\&quot;: \&quot;Field1 value\&quot;,     \&quot;Field2\&quot;: \&quot;Field2 value\&quot;,   } ] (required)
     * @return ApiResponse&lt;DataSetResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<DataSetResponse> createDataSetWithHttpInfo(String payload) throws ApiException {
        com.squareup.okhttp.Call call = createDataSetCall(payload, null, null);
        Type localVarReturnType = new TypeToken<DataSetResponse>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Store dataset (asynchronously)
     * Upload and store a data set. Currently only JSON is supported. This call returns an id which can be specified when submitting a merge job.
     * @param payload The dates for the merge [   {     \&quot;Field1\&quot;: \&quot;Field1 value\&quot;,     \&quot;Field2\&quot;: \&quot;Field2 value\&quot;,   },   {     \&quot;Field1\&quot;: \&quot;Field1 value\&quot;,     \&quot;Field2\&quot;: \&quot;Field2 value\&quot;,   } ] (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 createDataSetAsync(String payload, final ApiCallback<DataSetResponse> 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 = createDataSetCall(payload, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<DataSetResponse>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for createTemplateContext */
    private com.squareup.okhttp.Call createTemplateContextCall(TemplateContextRequest templateRequest,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = templateRequest;

        // verify the required parameter 'templateRequest' is set
        if (templateRequest == null) {
            throw new ApiException(
                    "Missing the required parameter 'templateRequest' when calling createTemplateContext(Async)");
        }

        // create path and map variables
        String localVarPath = "/template/processor/0.1/templates".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 = { "application/json;charset=UTF-8" };
        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[] { "oauth2schema" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody,
                localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Create template context
     * Create a unique template context for your environment
     * @param templateRequest The template request (required)
     * @return TemplateContextResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TemplateContextResponse createTemplateContext(TemplateContextRequest templateRequest)
            throws ApiException {
        ApiResponse<TemplateContextResponse> resp = createTemplateContextWithHttpInfo(templateRequest);
        return resp.getData();
    }

    /**
     * Create template context
     * Create a unique template context for your environment
     * @param templateRequest The template request (required)
     * @return ApiResponse&lt;TemplateContextResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TemplateContextResponse> createTemplateContextWithHttpInfo(
            TemplateContextRequest templateRequest) throws ApiException {
        com.squareup.okhttp.Call call = createTemplateContextCall(templateRequest, null, null);
        Type localVarReturnType = new TypeToken<TemplateContextResponse>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Create template context (asynchronously)
     * Create a unique template context for your environment
     * @param templateRequest The template request (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 createTemplateContextAsync(TemplateContextRequest templateRequest,
            final ApiCallback<TemplateContextResponse> 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 = createTemplateContextCall(templateRequest, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<TemplateContextResponse>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for deleteDataSet */
    private com.squareup.okhttp.Call deleteDataSetCall(String dataSetId,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // verify the required parameter 'dataSetId' is set
        if (dataSetId == null) {
            throw new ApiException("Missing the required parameter 'dataSetId' when calling deleteDataSet(Async)");
        }

        // create path and map variables
        String localVarPath = "/template/processor/0.1/datasets/{dataSetId}".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "dataSetId" + "\\}", apiClient.escapeString(dataSetId.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 = { "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[] { "oauth2schema" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
                localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Delete a stored data set
     * Delete a stored data set
     * @param dataSetId dataSetId (required)
     * @return DataSetResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public DataSetResponse deleteDataSet(String dataSetId) throws ApiException {
        ApiResponse<DataSetResponse> resp = deleteDataSetWithHttpInfo(dataSetId);
        return resp.getData();
    }

    /**
     * Delete a stored data set
     * Delete a stored data set
     * @param dataSetId dataSetId (required)
     * @return ApiResponse&lt;DataSetResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<DataSetResponse> deleteDataSetWithHttpInfo(String dataSetId) throws ApiException {
        com.squareup.okhttp.Call call = deleteDataSetCall(dataSetId, null, null);
        Type localVarReturnType = new TypeToken<DataSetResponse>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Delete a stored data set (asynchronously)
     * Delete a stored data set
     * @param dataSetId dataSetId (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 deleteDataSetAsync(String dataSetId,
            final ApiCallback<DataSetResponse> 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 = deleteDataSetCall(dataSetId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<DataSetResponse>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for deleteJob */
    private com.squareup.okhttp.Call deleteJobCall(String jobId,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // verify the required parameter 'jobId' is set
        if (jobId == null) {
            throw new ApiException("Missing the required parameter 'jobId' when calling deleteJob(Async)");
        }

        // create path and map variables
        String localVarPath = "/template/processor/0.1/jobs/{jobId}".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "jobId" + "\\}", apiClient.escapeString(jobId.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 = { "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[] { "oauth2schema" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
                localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Delete a job manually
     * Delete the merge job and all related files
     * @param jobId jobId (required)
     * @return MergeJobResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public MergeJobResponse deleteJob(String jobId) throws ApiException {
        ApiResponse<MergeJobResponse> resp = deleteJobWithHttpInfo(jobId);
        return resp.getData();
    }

    /**
     * Delete a job manually
     * Delete the merge job and all related files
     * @param jobId jobId (required)
     * @return ApiResponse&lt;MergeJobResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<MergeJobResponse> deleteJobWithHttpInfo(String jobId) throws ApiException {
        com.squareup.okhttp.Call call = deleteJobCall(jobId, null, null);
        Type localVarReturnType = new TypeToken<MergeJobResponse>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Delete a job manually (asynchronously)
     * Delete the merge job and all related files
     * @param jobId jobId (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 deleteJobAsync(String jobId, final ApiCallback<MergeJobResponse> 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 = deleteJobCall(jobId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<MergeJobResponse>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for deleteTemplateContext */
    private com.squareup.okhttp.Call deleteTemplateContextCall(String templateId,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // verify the required parameter 'templateId' is set
        if (templateId == null) {
            throw new ApiException(
                    "Missing the required parameter 'templateId' when calling deleteTemplateContext(Async)");
        }

        // create path and map variables
        String localVarPath = "/template/processor/0.1/templates/{templateId}".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "templateId" + "\\}", apiClient.escapeString(templateId.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 = { "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[] { "oauth2schema" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
                localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Delete template context
     * Delete a template context with all history
     * @param templateId templateId (required)
     * @return TemplateContextResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TemplateContextResponse deleteTemplateContext(String templateId) throws ApiException {
        ApiResponse<TemplateContextResponse> resp = deleteTemplateContextWithHttpInfo(templateId);
        return resp.getData();
    }

    /**
     * Delete template context
     * Delete a template context with all history
     * @param templateId templateId (required)
     * @return ApiResponse&lt;TemplateContextResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TemplateContextResponse> deleteTemplateContextWithHttpInfo(String templateId)
            throws ApiException {
        com.squareup.okhttp.Call call = deleteTemplateContextCall(templateId, null, null);
        Type localVarReturnType = new TypeToken<TemplateContextResponse>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Delete template context (asynchronously)
     * Delete a template context with all history
     * @param templateId templateId (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 deleteTemplateContextAsync(String templateId,
            final ApiCallback<TemplateContextResponse> 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 = deleteTemplateContextCall(templateId, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<TemplateContextResponse>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for getJob */
    private com.squareup.okhttp.Call getJobCall(String jobId,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // verify the required parameter 'jobId' is set
        if (jobId == null) {
            throw new ApiException("Missing the required parameter 'jobId' when calling getJob(Async)");
        }

        // create path and map variables
        String localVarPath = "/template/processor/0.1/jobs/{jobId}".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "jobId" + "\\}", apiClient.escapeString(jobId.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 = { "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[] { "oauth2schema" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Job definition and state
     * Get the merge job definition and current state. Please not that you can differentiate based on http response status
     * @param jobId jobId (required)
     * @return MergeJobResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public MergeJobResponse getJob(String jobId) throws ApiException {
        ApiResponse<MergeJobResponse> resp = getJobWithHttpInfo(jobId);
        return resp.getData();
    }

    /**
     * Job definition and state
     * Get the merge job definition and current state. Please not that you can differentiate based on http response status
     * @param jobId jobId (required)
     * @return ApiResponse&lt;MergeJobResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<MergeJobResponse> getJobWithHttpInfo(String jobId) throws ApiException {
        com.squareup.okhttp.Call call = getJobCall(jobId, null, null);
        Type localVarReturnType = new TypeToken<MergeJobResponse>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Job definition and state (asynchronously)
     * Get the merge job definition and current state. Please not that you can differentiate based on http response status
     * @param jobId jobId (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 getJobAsync(String jobId, final ApiCallback<MergeJobResponse> 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 = getJobCall(jobId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<MergeJobResponse>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for getJobs */
    private com.squareup.okhttp.Call getJobsCall(List<String> status,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/template/processor/0.1/jobs".replaceAll("\\{format\\}", "json");

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        if (status != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "status", status));

        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 = { "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[] { "oauth2schema" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Get all jobs
     * Get all office text job definitions and their current state.
     * @param status A list of status to filter on. (optional)
     * @return List&lt;MergeJobResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public List<MergeJobResponse> getJobs(List<String> status) throws ApiException {
        ApiResponse<List<MergeJobResponse>> resp = getJobsWithHttpInfo(status);
        return resp.getData();
    }

    /**
     * Get all jobs
     * Get all office text job definitions and their current state.
     * @param status A list of status to filter on. (optional)
     * @return ApiResponse&lt;List&lt;MergeJobResponse&gt;&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<List<MergeJobResponse>> getJobsWithHttpInfo(List<String> status) throws ApiException {
        com.squareup.okhttp.Call call = getJobsCall(status, null, null);
        Type localVarReturnType = new TypeToken<List<MergeJobResponse>>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all jobs (asynchronously)
     * Get all office text job definitions and their current state.
     * @param status A list of status to filter on. (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 getJobsAsync(List<String> status,
            final ApiCallback<List<MergeJobResponse>> 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 = getJobsCall(status, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<List<MergeJobResponse>>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for getResultStreamById */
    private com.squareup.okhttp.Call getResultStreamByIdCall(String jobId, String streamId,
            OutputSettings outputSettings, final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = outputSettings;

        // verify the required parameter 'jobId' is set
        if (jobId == null) {
            throw new ApiException(
                    "Missing the required parameter 'jobId' when calling getResultStreamById(Async)");
        }

        // verify the required parameter 'streamId' is set
        if (streamId == null) {
            throw new ApiException(
                    "Missing the required parameter 'streamId' when calling getResultStreamById(Async)");
        }

        // create path and map variables
        String localVarPath = "/template/processor/0.1/jobs/{jobId}/result/file/{streamId}"
                .replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "jobId" + "\\}", apiClient.escapeString(jobId.toString()))
                .replaceAll("\\{" + "streamId" + "\\}", apiClient.escapeString(streamId.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/octet-stream" };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null)
            localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = { "application/json;charset=UTF-8" };
        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[] { "oauth2schema" };
        return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Get the result file
     * Get a merge result document as a binary stream.   
     * @param jobId jobId (required)
     * @param streamId streamId (required)
     * @param outputSettings outputSettings (optional)
     * @return byte[]
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public byte[] getResultStreamById(String jobId, String streamId, OutputSettings outputSettings)
            throws ApiException {
        ApiResponse<byte[]> resp = getResultStreamByIdWithHttpInfo(jobId, streamId, outputSettings);
        return resp.getData();
    }

    /**
     * Get the result file
     * Get a merge result document as a binary stream.   
     * @param jobId jobId (required)
     * @param streamId streamId (required)
     * @param outputSettings outputSettings (optional)
     * @return ApiResponse&lt;byte[]&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<byte[]> getResultStreamByIdWithHttpInfo(String jobId, String streamId,
            OutputSettings outputSettings) throws ApiException {
        com.squareup.okhttp.Call call = getResultStreamByIdCall(jobId, streamId, outputSettings, null, null);
        Type localVarReturnType = new TypeToken<byte[]>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the result file (asynchronously)
     * Get a merge result document as a binary stream.   
     * @param jobId jobId (required)
     * @param streamId streamId (required)
     * @param outputSettings outputSettings (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 getResultStreamByIdAsync(String jobId, String streamId,
            OutputSettings outputSettings, final ApiCallback<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 = getResultStreamByIdCall(jobId, streamId, outputSettings, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<byte[]>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for getResultStreamsAsContainer */
    private com.squareup.okhttp.Call getResultStreamsAsContainerCall(String jobId, OutputSettings outputSettings,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = outputSettings;

        // verify the required parameter 'jobId' is set
        if (jobId == null) {
            throw new ApiException(
                    "Missing the required parameter 'jobId' when calling getResultStreamsAsContainer(Async)");
        }

        // create path and map variables
        String localVarPath = "/template/processor/0.1/jobs/{jobId}/result/container"
                .replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "jobId" + "\\}", apiClient.escapeString(jobId.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/octet-stream" };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null)
            localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = { "application/json;charset=UTF-8" };
        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[] { "oauth2schema" };
        return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Get the result file
     * Get all documents inside a compressed container as a binary stream.   
     * @param jobId jobId (required)
     * @param outputSettings outputSettings (optional)
     * @return byte[]
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public byte[] getResultStreamsAsContainer(String jobId, OutputSettings outputSettings) throws ApiException {
        ApiResponse<byte[]> resp = getResultStreamsAsContainerWithHttpInfo(jobId, outputSettings);
        return resp.getData();
    }

    /**
     * Get the result file
     * Get all documents inside a compressed container as a binary stream.   
     * @param jobId jobId (required)
     * @param outputSettings outputSettings (optional)
     * @return ApiResponse&lt;byte[]&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<byte[]> getResultStreamsAsContainerWithHttpInfo(String jobId, OutputSettings outputSettings)
            throws ApiException {
        com.squareup.okhttp.Call call = getResultStreamsAsContainerCall(jobId, outputSettings, null, null);
        Type localVarReturnType = new TypeToken<byte[]>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the result file (asynchronously)
     * Get all documents inside a compressed container as a binary stream.   
     * @param jobId jobId (required)
     * @param outputSettings outputSettings (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 getResultStreamsAsContainerAsync(String jobId, OutputSettings outputSettings,
            final ApiCallback<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 = getResultStreamsAsContainerCall(jobId, outputSettings, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<byte[]>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for getTemplateContext */
    private com.squareup.okhttp.Call getTemplateContextCall(String templateId,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // verify the required parameter 'templateId' is set
        if (templateId == null) {
            throw new ApiException(
                    "Missing the required parameter 'templateId' when calling getTemplateContext(Async)");
        }

        // create path and map variables
        String localVarPath = "/template/processor/0.1/templates/{templateId}".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "templateId" + "\\}", apiClient.escapeString(templateId.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 = { "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[] { "oauth2schema" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Get template context
     * Get an existing template context
     * @param templateId The template context name unique for your environment (required)
     * @return TemplateContextResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TemplateContextResponse getTemplateContext(String templateId) throws ApiException {
        ApiResponse<TemplateContextResponse> resp = getTemplateContextWithHttpInfo(templateId);
        return resp.getData();
    }

    /**
     * Get template context
     * Get an existing template context
     * @param templateId The template context name unique for your environment (required)
     * @return ApiResponse&lt;TemplateContextResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TemplateContextResponse> getTemplateContextWithHttpInfo(String templateId)
            throws ApiException {
        com.squareup.okhttp.Call call = getTemplateContextCall(templateId, null, null);
        Type localVarReturnType = new TypeToken<TemplateContextResponse>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get template context (asynchronously)
     * Get an existing template context
     * @param templateId The template context name unique for your environment (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 getTemplateContextAsync(String templateId,
            final ApiCallback<TemplateContextResponse> 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 = getTemplateContextCall(templateId, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<TemplateContextResponse>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for submitJob */
    private com.squareup.okhttp.Call submitJobCall(MergeSettings mergesettings,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = mergesettings;

        // verify the required parameter 'mergesettings' is set
        if (mergesettings == null) {
            throw new ApiException("Missing the required parameter 'mergesettings' when calling submitJob(Async)");
        }

        // create path and map variables
        String localVarPath = "/template/processor/0.1/jobs".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 = { "application/json;charset=UTF-8" };
        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[] { "oauth2schema" };
        return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Submit merge job for processing
     * Submit merge job run.
     * @param mergesettings The merge- and output settings (required)
     * @return MergeJobResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public MergeJobResponse submitJob(MergeSettings mergesettings) throws ApiException {
        ApiResponse<MergeJobResponse> resp = submitJobWithHttpInfo(mergesettings);
        return resp.getData();
    }

    /**
     * Submit merge job for processing
     * Submit merge job run.
     * @param mergesettings The merge- and output settings (required)
     * @return ApiResponse&lt;MergeJobResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<MergeJobResponse> submitJobWithHttpInfo(MergeSettings mergesettings) throws ApiException {
        com.squareup.okhttp.Call call = submitJobCall(mergesettings, null, null);
        Type localVarReturnType = new TypeToken<MergeJobResponse>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Submit merge job for processing (asynchronously)
     * Submit merge job run.
     * @param mergesettings The merge- and output settings (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 submitJobAsync(MergeSettings mergesettings,
            final ApiCallback<MergeJobResponse> 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 = submitJobCall(mergesettings, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<MergeJobResponse>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for updateTemplateContext */
    private com.squareup.okhttp.Call updateTemplateContextCall(TemplateContextRequest templateContextRequest,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = templateContextRequest;

        // verify the required parameter 'templateContextRequest' is set
        if (templateContextRequest == null) {
            throw new ApiException(
                    "Missing the required parameter 'templateContextRequest' when calling updateTemplateContext(Async)");
        }

        // create path and map variables
        String localVarPath = "/template/processor/0.1/templates".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 = { "application/json;charset=UTF-8" };
        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[] { "oauth2schema" };
        return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Update template context
     * Update an existing template context for your environment
     * @param templateContextRequest templateContextRequest (required)
     * @return TemplateContextResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TemplateContextResponse updateTemplateContext(TemplateContextRequest templateContextRequest)
            throws ApiException {
        ApiResponse<TemplateContextResponse> resp = updateTemplateContextWithHttpInfo(templateContextRequest);
        return resp.getData();
    }

    /**
     * Update template context
     * Update an existing template context for your environment
     * @param templateContextRequest templateContextRequest (required)
     * @return ApiResponse&lt;TemplateContextResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TemplateContextResponse> updateTemplateContextWithHttpInfo(
            TemplateContextRequest templateContextRequest) throws ApiException {
        com.squareup.okhttp.Call call = updateTemplateContextCall(templateContextRequest, null, null);
        Type localVarReturnType = new TypeToken<TemplateContextResponse>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Update template context (asynchronously)
     * Update an existing template context for your environment
     * @param templateContextRequest templateContextRequest (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 updateTemplateContextAsync(TemplateContextRequest templateContextRequest,
            final ApiCallback<TemplateContextResponse> 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 = updateTemplateContextCall(templateContextRequest, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<TemplateContextResponse>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for uploadTemplateFile */
    private com.squareup.okhttp.Call uploadTemplateFileCall(String templateId, File stream,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // verify the required parameter 'templateId' is set
        if (templateId == null) {
            throw new ApiException(
                    "Missing the required parameter 'templateId' when calling uploadTemplateFile(Async)");
        }

        // verify the required parameter 'stream' is set
        if (stream == null) {
            throw new ApiException(
                    "Missing the required parameter 'stream' when calling uploadTemplateFile(Async)");
        }

        // create path and map variables
        String localVarPath = "/template/processor/0.1/templates/{templateId}".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "templateId" + "\\}", apiClient.escapeString(templateId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();
        if (stream != null)
            localVarFormParams.put("stream", stream);

        final String[] localVarAccepts = { "application/json;charset=UTF-8" };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null)
            localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = { "multipart/form-data" };
        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[] { "oauth2schema" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody,
                localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Upload template file
     * Upload the Office template file
     * @param templateId The template context name unique for your environment (required)
     * @param stream The template (file/inputstream) to store (required)
     * @return TemplateContextResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TemplateContextResponse uploadTemplateFile(String templateId, File stream) throws ApiException {
        ApiResponse<TemplateContextResponse> resp = uploadTemplateFileWithHttpInfo(templateId, stream);
        return resp.getData();
    }

    /**
     * Upload template file
     * Upload the Office template file
     * @param templateId The template context name unique for your environment (required)
     * @param stream The template (file/inputstream) to store (required)
     * @return ApiResponse&lt;TemplateContextResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TemplateContextResponse> uploadTemplateFileWithHttpInfo(String templateId, File stream)
            throws ApiException {
        com.squareup.okhttp.Call call = uploadTemplateFileCall(templateId, stream, null, null);
        Type localVarReturnType = new TypeToken<TemplateContextResponse>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Upload template file (asynchronously)
     * Upload the Office template file
     * @param templateId The template context name unique for your environment (required)
     * @param stream The template (file/inputstream) to store (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 uploadTemplateFileAsync(String templateId, File stream,
            final ApiCallback<TemplateContextResponse> 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 = uploadTemplateFileCall(templateId, stream, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<TemplateContextResponse>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}