All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.textmagic.sdk.api.TextMagicApi Maven / Gradle / Ivy

There is a newer version: 2.0.2456
Show newest version
/*
 * TextMagic API
 * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
 *
 * OpenAPI spec version: 2
 * 
 *
 * 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.
 */


package com.textmagic.sdk.api;

import com.textmagic.sdk.ApiCallback;
import com.textmagic.sdk.ApiClient;
import com.textmagic.sdk.ApiException;
import com.textmagic.sdk.ApiResponse;
import com.textmagic.sdk.Configuration;
import com.textmagic.sdk.Pair;
import com.textmagic.sdk.ProgressRequestBody;
import com.textmagic.sdk.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import com.textmagic.sdk.model.AssignContactsToListInputObject;
import com.textmagic.sdk.model.BadRequestResponse;
import java.math.BigDecimal;
import com.textmagic.sdk.model.BlockContactInputObject;
import com.textmagic.sdk.model.BulkSession;
import com.textmagic.sdk.model.BuyDedicatedNumberInputObject;
import com.textmagic.sdk.model.Chat;
import com.textmagic.sdk.model.CheckPhoneVerificationCodeInputObject;
import com.textmagic.sdk.model.ClearAndAssignContactsToListInputObject;
import com.textmagic.sdk.model.CloseChatsBulkInputObject;
import com.textmagic.sdk.model.Contact;
import com.textmagic.sdk.model.ContactNote;
import com.textmagic.sdk.model.CreateContactInputObject;
import com.textmagic.sdk.model.CreateContactNoteInputObject;
import com.textmagic.sdk.model.CreateCustomFieldInputObject;
import com.textmagic.sdk.model.CreateListInputObject;
import com.textmagic.sdk.model.CreateTemplateInputObject;
import com.textmagic.sdk.model.DeleteChatMessagesBulkInputObject;
import com.textmagic.sdk.model.DeleteChatsBulkInputObject;
import com.textmagic.sdk.model.DeleteContacsFromListObject;
import com.textmagic.sdk.model.DeleteContactNotesBulkInputObject;
import com.textmagic.sdk.model.DeleteContactsByIdsInputObject;
import com.textmagic.sdk.model.DeleteInboundMessagesBulkInputObject;
import com.textmagic.sdk.model.DeleteListContactsBulkInputObject;
import com.textmagic.sdk.model.DeleteListsBulkInputObject;
import com.textmagic.sdk.model.DeleteMessageSessionsBulkInputObject;
import com.textmagic.sdk.model.DeleteOutboundMessagesBulkInputObject;
import com.textmagic.sdk.model.DeleteScheduledMessagesBulkInputObject;
import com.textmagic.sdk.model.DeleteTemplatesBulkInputObject;
import com.textmagic.sdk.model.DoCarrierLookupResponse;
import com.textmagic.sdk.model.DoEmailLookupResponse;
import java.io.File;
import com.textmagic.sdk.model.GetAllBulkSessionsPaginatedResponse;
import com.textmagic.sdk.model.GetAllChatsPaginatedResponse;
import com.textmagic.sdk.model.GetAllInboundMessagesPaginatedResponse;
import com.textmagic.sdk.model.GetAllMessageSessionsPaginatedResponse;
import com.textmagic.sdk.model.GetAllOutboundMessagesPaginatedResponse;
import com.textmagic.sdk.model.GetAllScheduledMessagesPaginatedResponse;
import com.textmagic.sdk.model.GetAllTemplatesPaginatedResponse;
import com.textmagic.sdk.model.GetAvailableDedicatedNumbersResponse;
import com.textmagic.sdk.model.GetAvailableSenderSettingOptionsResponse;
import com.textmagic.sdk.model.GetBalanceNotificationOptionsResponse;
import com.textmagic.sdk.model.GetBalanceNotificationSettingsResponse;
import com.textmagic.sdk.model.GetBlockedContactsPaginatedResponse;
import com.textmagic.sdk.model.GetCallbackSettingsResponse;
import com.textmagic.sdk.model.GetChatMessagesPaginatedResponse;
import com.textmagic.sdk.model.GetContactImportSessionProgressResponse;
import com.textmagic.sdk.model.GetContactNotesPaginatedResponse;
import com.textmagic.sdk.model.GetContactsAutocompleteResponse;
import com.textmagic.sdk.model.GetContactsByListIdPaginatedResponse;
import com.textmagic.sdk.model.GetContactsPaginatedResponse;
import com.textmagic.sdk.model.GetCountriesResponse;
import com.textmagic.sdk.model.GetCustomFieldsPaginatedResponse;
import com.textmagic.sdk.model.GetFavoritesPaginatedResponse;
import com.textmagic.sdk.model.GetInboundMessagesNotificationSettingsResponse;
import com.textmagic.sdk.model.GetInvoicesPaginatedResponse;
import com.textmagic.sdk.model.GetListContactsIdsResponse;
import com.textmagic.sdk.model.GetListsOfContactPaginatedResponse;
import com.textmagic.sdk.model.GetListsPaginatedResponse;
import com.textmagic.sdk.model.GetMessagePreviewResponse;
import com.textmagic.sdk.model.GetMessagePriceResponse;
import com.textmagic.sdk.model.GetMessageSessionStatResponse;
import com.textmagic.sdk.model.GetMessagesBySessionIdPaginatedResponse;
import com.textmagic.sdk.model.GetMessagingCountersResponse;
import com.textmagic.sdk.model.GetMessagingStatResponse;
import com.textmagic.sdk.model.GetOutboundMessagesHistoryPaginatedResponse;
import com.textmagic.sdk.model.GetSenderIdsPaginatedResponse;
import com.textmagic.sdk.model.GetSenderSettingsResponse;
import com.textmagic.sdk.model.GetSpendingStatPaginatedResponse;
import com.textmagic.sdk.model.GetSubaccountsWithTokensInputObject;
import com.textmagic.sdk.model.GetSubaccountsWithTokensResponse;
import com.textmagic.sdk.model.GetTimezonesResponse;
import com.textmagic.sdk.model.GetUnreadMessagesTotalResponse;
import com.textmagic.sdk.model.GetUnsubscribersPaginatedResponse;
import com.textmagic.sdk.model.GetUserDedicatedNumbersPaginatedResponse;
import com.textmagic.sdk.model.InviteSubaccountInputObject;
import com.textmagic.sdk.model.MarkChatsReadBulkInputObject;
import com.textmagic.sdk.model.MarkChatsUnreadBulkInputObject;
import com.textmagic.sdk.model.MessageIn;
import com.textmagic.sdk.model.MessageOut;
import com.textmagic.sdk.model.MessageSession;
import com.textmagic.sdk.model.MessageTemplate;
import com.textmagic.sdk.model.MessagesIcs;
import com.textmagic.sdk.model.MuteChatInputObject;
import com.textmagic.sdk.model.MuteChatsBulkInputObject;
import com.textmagic.sdk.model.NotFoundResponse;
import com.textmagic.sdk.model.PingResponse;
import com.textmagic.sdk.model.ReopenChatsBulkInputObject;
import com.textmagic.sdk.model.RequestNewSubaccountTokenInputObject;
import com.textmagic.sdk.model.RequestSenderIdInputObject;
import com.textmagic.sdk.model.ResourceLinkResponse;
import com.textmagic.sdk.model.SearchChatsByIdsPaginatedResponse;
import com.textmagic.sdk.model.SearchChatsByReceipentPaginatedResponse;
import com.textmagic.sdk.model.SearchChatsPaginatedResponse;
import com.textmagic.sdk.model.SearchContactsPaginatedResponse;
import com.textmagic.sdk.model.SearchInboundMessagesPaginatedResponse;
import com.textmagic.sdk.model.SearchListsPaginatedResponse;
import com.textmagic.sdk.model.SearchOutboundMessagesPaginatedResponse;
import com.textmagic.sdk.model.SearchScheduledMessagesPaginatedResponse;
import com.textmagic.sdk.model.SearchTemplatesPaginatedResponse;
import com.textmagic.sdk.model.SendMessageInputObject;
import com.textmagic.sdk.model.SendMessageResponse;
import com.textmagic.sdk.model.SendPhoneVerificationCodeInputObject;
import com.textmagic.sdk.model.SendPhoneVerificationCodeResponse;
import com.textmagic.sdk.model.SenderId;
import com.textmagic.sdk.model.SetChatStatusInputObject;
import com.textmagic.sdk.model.UnauthorizedResponse;
import com.textmagic.sdk.model.UnblockContactInputObject;
import com.textmagic.sdk.model.UnblockContactsBulkInputObject;
import com.textmagic.sdk.model.UnmuteChatsBulkInputObject;
import com.textmagic.sdk.model.UnsubscribeContactInputObject;
import com.textmagic.sdk.model.UnsubscribedContact;
import com.textmagic.sdk.model.UpdateBalanceNotificationSettingsInputObject;
import com.textmagic.sdk.model.UpdateCallbackSettingsInputObject;
import com.textmagic.sdk.model.UpdateChatDesktopNotificationSettingsInputObject;
import com.textmagic.sdk.model.UpdateContactInputObject;
import com.textmagic.sdk.model.UpdateContactNoteInputObject;
import com.textmagic.sdk.model.UpdateCurrentUserInputObject;
import com.textmagic.sdk.model.UpdateCurrentUserResponse;
import com.textmagic.sdk.model.UpdateCustomFieldInputObject;
import com.textmagic.sdk.model.UpdateCustomFieldValueInputObject;
import com.textmagic.sdk.model.UpdateInboundMessagesNotificationSettingsInputObject;
import com.textmagic.sdk.model.UpdateListObject;
import com.textmagic.sdk.model.UpdateSenderSettingInputObject;
import com.textmagic.sdk.model.UpdateTemplateInputObject;
import com.textmagic.sdk.model.UploadMessageAttachmentResponse;
import com.textmagic.sdk.model.User;
import com.textmagic.sdk.model.UserCustomField;
import com.textmagic.sdk.model.UsersInbound;

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

public class TextMagicApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for assignContactsToList
     * @param assignContactsToListInputObject  (required)
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call assignContactsToListCall(AssignContactsToListInputObject assignContactsToListInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = assignContactsToListInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/lists/{id}/contacts"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call assignContactsToListValidateBeforeCall(AssignContactsToListInputObject assignContactsToListInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'assignContactsToListInputObject' is set
        if (assignContactsToListInputObject == null) {
            throw new ApiException("Missing the required parameter 'assignContactsToListInputObject' when calling assignContactsToList(Async)");
        }
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling assignContactsToList(Async)");
        }
        

        com.squareup.okhttp.Call call = assignContactsToListCall(assignContactsToListInputObject, id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Assign contacts to a list
     * > Unlike all other PUT requests, this command does not need old contact IDs to be submitted. For example, if you have a list with contacts 150, 151 and 152 and you want to add contact ID 153, you only need to submit 153 as a parameter of PUT /api/v2/lists/{id}/contacts. 
     * @param assignContactsToListInputObject  (required)
     * @param id  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse assignContactsToList(AssignContactsToListInputObject assignContactsToListInputObject, Integer id) throws ApiException {
        ApiResponse resp = assignContactsToListWithHttpInfo(assignContactsToListInputObject, id);
        return resp.getData();
    }

    /**
     * Assign contacts to a list
     * > Unlike all other PUT requests, this command does not need old contact IDs to be submitted. For example, if you have a list with contacts 150, 151 and 152 and you want to add contact ID 153, you only need to submit 153 as a parameter of PUT /api/v2/lists/{id}/contacts. 
     * @param assignContactsToListInputObject  (required)
     * @param id  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse assignContactsToListWithHttpInfo(AssignContactsToListInputObject assignContactsToListInputObject, Integer id) throws ApiException {
        com.squareup.okhttp.Call call = assignContactsToListValidateBeforeCall(assignContactsToListInputObject, id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Assign contacts to a list (asynchronously)
     * > Unlike all other PUT requests, this command does not need old contact IDs to be submitted. For example, if you have a list with contacts 150, 151 and 152 and you want to add contact ID 153, you only need to submit 153 as a parameter of PUT /api/v2/lists/{id}/contacts. 
     * @param assignContactsToListInputObject  (required)
     * @param 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 assignContactsToListAsync(AssignContactsToListInputObject assignContactsToListInputObject, Integer id, final ApiCallback 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 = assignContactsToListValidateBeforeCall(assignContactsToListInputObject, id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for blockContact
     * @param blockContactInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call blockContactCall(BlockContactInputObject blockContactInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = blockContactInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/block";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call blockContactValidateBeforeCall(BlockContactInputObject blockContactInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'blockContactInputObject' is set
        if (blockContactInputObject == null) {
            throw new ApiException("Missing the required parameter 'blockContactInputObject' when calling blockContact(Async)");
        }
        

        com.squareup.okhttp.Call call = blockContactCall(blockContactInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Block a contact by phone number
     * Block a contact from inbound and outbound communication by phone number.
     * @param blockContactInputObject  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse blockContact(BlockContactInputObject blockContactInputObject) throws ApiException {
        ApiResponse resp = blockContactWithHttpInfo(blockContactInputObject);
        return resp.getData();
    }

    /**
     * Block a contact by phone number
     * Block a contact from inbound and outbound communication by phone number.
     * @param blockContactInputObject  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse blockContactWithHttpInfo(BlockContactInputObject blockContactInputObject) throws ApiException {
        com.squareup.okhttp.Call call = blockContactValidateBeforeCall(blockContactInputObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Block a contact by phone number (asynchronously)
     * Block a contact from inbound and outbound communication by phone number.
     * @param blockContactInputObject  (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 blockContactAsync(BlockContactInputObject blockContactInputObject, final ApiCallback 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 = blockContactValidateBeforeCall(blockContactInputObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for buyDedicatedNumber
     * @param buyDedicatedNumberInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call buyDedicatedNumberCall(BuyDedicatedNumberInputObject buyDedicatedNumberInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = buyDedicatedNumberInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/numbers";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call buyDedicatedNumberValidateBeforeCall(BuyDedicatedNumberInputObject buyDedicatedNumberInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'buyDedicatedNumberInputObject' is set
        if (buyDedicatedNumberInputObject == null) {
            throw new ApiException("Missing the required parameter 'buyDedicatedNumberInputObject' when calling buyDedicatedNumber(Async)");
        }
        

        com.squareup.okhttp.Call call = buyDedicatedNumberCall(buyDedicatedNumberInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Buy a dedicated number
     * To buy a dedicated number, you first need to find an available number matching your criteria using the `/api/v2/numbers/available` command described above.
     * @param buyDedicatedNumberInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void buyDedicatedNumber(BuyDedicatedNumberInputObject buyDedicatedNumberInputObject) throws ApiException {
        buyDedicatedNumberWithHttpInfo(buyDedicatedNumberInputObject);
    }

    /**
     * Buy a dedicated number
     * To buy a dedicated number, you first need to find an available number matching your criteria using the `/api/v2/numbers/available` command described above.
     * @param buyDedicatedNumberInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse buyDedicatedNumberWithHttpInfo(BuyDedicatedNumberInputObject buyDedicatedNumberInputObject) throws ApiException {
        com.squareup.okhttp.Call call = buyDedicatedNumberValidateBeforeCall(buyDedicatedNumberInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Buy a dedicated number (asynchronously)
     * To buy a dedicated number, you first need to find an available number matching your criteria using the `/api/v2/numbers/available` command described above.
     * @param buyDedicatedNumberInputObject  (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 buyDedicatedNumberAsync(BuyDedicatedNumberInputObject buyDedicatedNumberInputObject, final ApiCallback 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 = buyDedicatedNumberValidateBeforeCall(buyDedicatedNumberInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for cancelVerification
     * @param verifyId The verifyId that you received in Step 1. (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call cancelVerificationCall(String verifyId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/verify/{verifyId}"
            .replaceAll("\\{" + "verifyId" + "\\}", apiClient.escapeString(verifyId.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call cancelVerificationValidateBeforeCall(String verifyId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'verifyId' is set
        if (verifyId == null) {
            throw new ApiException("Missing the required parameter 'verifyId' when calling cancelVerification(Async)");
        }
        

        com.squareup.okhttp.Call call = cancelVerificationCall(verifyId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Cancel verification process
     * You can cancel the verification not earlier than 30 seconds after the initial request.
     * @param verifyId The verifyId that you received in Step 1. (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void cancelVerification(String verifyId) throws ApiException {
        cancelVerificationWithHttpInfo(verifyId);
    }

    /**
     * Cancel verification process
     * You can cancel the verification not earlier than 30 seconds after the initial request.
     * @param verifyId The verifyId that you received in Step 1. (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse cancelVerificationWithHttpInfo(String verifyId) throws ApiException {
        com.squareup.okhttp.Call call = cancelVerificationValidateBeforeCall(verifyId, null, null);
        return apiClient.execute(call);
    }

    /**
     * Cancel verification process (asynchronously)
     * You can cancel the verification not earlier than 30 seconds after the initial request.
     * @param verifyId The verifyId that you received in Step 1. (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 cancelVerificationAsync(String verifyId, final ApiCallback 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 = cancelVerificationValidateBeforeCall(verifyId, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for checkPhoneVerificationCodeTFA
     * @param checkPhoneVerificationCodeInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call checkPhoneVerificationCodeTFACall(CheckPhoneVerificationCodeInputObject checkPhoneVerificationCodeInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = checkPhoneVerificationCodeInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/verify";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call checkPhoneVerificationCodeTFAValidateBeforeCall(CheckPhoneVerificationCodeInputObject checkPhoneVerificationCodeInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'checkPhoneVerificationCodeInputObject' is set
        if (checkPhoneVerificationCodeInputObject == null) {
            throw new ApiException("Missing the required parameter 'checkPhoneVerificationCodeInputObject' when calling checkPhoneVerificationCodeTFA(Async)");
        }
        

        com.squareup.okhttp.Call call = checkPhoneVerificationCodeTFACall(checkPhoneVerificationCodeInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Step 2: Check the verification code 
     * Check received code from user with the code which was actually sent.
     * @param checkPhoneVerificationCodeInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void checkPhoneVerificationCodeTFA(CheckPhoneVerificationCodeInputObject checkPhoneVerificationCodeInputObject) throws ApiException {
        checkPhoneVerificationCodeTFAWithHttpInfo(checkPhoneVerificationCodeInputObject);
    }

    /**
     * Step 2: Check the verification code 
     * Check received code from user with the code which was actually sent.
     * @param checkPhoneVerificationCodeInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse checkPhoneVerificationCodeTFAWithHttpInfo(CheckPhoneVerificationCodeInputObject checkPhoneVerificationCodeInputObject) throws ApiException {
        com.squareup.okhttp.Call call = checkPhoneVerificationCodeTFAValidateBeforeCall(checkPhoneVerificationCodeInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Step 2: Check the verification code  (asynchronously)
     * Check received code from user with the code which was actually sent.
     * @param checkPhoneVerificationCodeInputObject  (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 checkPhoneVerificationCodeTFAAsync(CheckPhoneVerificationCodeInputObject checkPhoneVerificationCodeInputObject, final ApiCallback 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 = checkPhoneVerificationCodeTFAValidateBeforeCall(checkPhoneVerificationCodeInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for clearAndAssignContactsToList
     * @param clearAndAssignContactsToListInputObject  (required)
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call clearAndAssignContactsToListCall(ClearAndAssignContactsToListInputObject clearAndAssignContactsToListInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = clearAndAssignContactsToListInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/lists/{id}/contacts"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call clearAndAssignContactsToListValidateBeforeCall(ClearAndAssignContactsToListInputObject clearAndAssignContactsToListInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'clearAndAssignContactsToListInputObject' is set
        if (clearAndAssignContactsToListInputObject == null) {
            throw new ApiException("Missing the required parameter 'clearAndAssignContactsToListInputObject' when calling clearAndAssignContactsToList(Async)");
        }
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling clearAndAssignContactsToList(Async)");
        }
        

        com.squareup.okhttp.Call call = clearAndAssignContactsToListCall(clearAndAssignContactsToListInputObject, id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Reset list members to the specified contacts
     * 
     * @param clearAndAssignContactsToListInputObject  (required)
     * @param id  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse clearAndAssignContactsToList(ClearAndAssignContactsToListInputObject clearAndAssignContactsToListInputObject, Integer id) throws ApiException {
        ApiResponse resp = clearAndAssignContactsToListWithHttpInfo(clearAndAssignContactsToListInputObject, id);
        return resp.getData();
    }

    /**
     * Reset list members to the specified contacts
     * 
     * @param clearAndAssignContactsToListInputObject  (required)
     * @param id  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse clearAndAssignContactsToListWithHttpInfo(ClearAndAssignContactsToListInputObject clearAndAssignContactsToListInputObject, Integer id) throws ApiException {
        com.squareup.okhttp.Call call = clearAndAssignContactsToListValidateBeforeCall(clearAndAssignContactsToListInputObject, id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Reset list members to the specified contacts (asynchronously)
     * 
     * @param clearAndAssignContactsToListInputObject  (required)
     * @param 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 clearAndAssignContactsToListAsync(ClearAndAssignContactsToListInputObject clearAndAssignContactsToListInputObject, Integer id, final ApiCallback 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 = clearAndAssignContactsToListValidateBeforeCall(clearAndAssignContactsToListInputObject, id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for closeChatsBulk
     * @param closeChatsBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call closeChatsBulkCall(CloseChatsBulkInputObject closeChatsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = closeChatsBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/chats/close/bulk";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call closeChatsBulkValidateBeforeCall(CloseChatsBulkInputObject closeChatsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'closeChatsBulkInputObject' is set
        if (closeChatsBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'closeChatsBulkInputObject' when calling closeChatsBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = closeChatsBulkCall(closeChatsBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Close chats (bulk)
     * Close chats by chat IDs or close all chats
     * @param closeChatsBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void closeChatsBulk(CloseChatsBulkInputObject closeChatsBulkInputObject) throws ApiException {
        closeChatsBulkWithHttpInfo(closeChatsBulkInputObject);
    }

    /**
     * Close chats (bulk)
     * Close chats by chat IDs or close all chats
     * @param closeChatsBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse closeChatsBulkWithHttpInfo(CloseChatsBulkInputObject closeChatsBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = closeChatsBulkValidateBeforeCall(closeChatsBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Close chats (bulk) (asynchronously)
     * Close chats by chat IDs or close all chats
     * @param closeChatsBulkInputObject  (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 closeChatsBulkAsync(CloseChatsBulkInputObject closeChatsBulkInputObject, final ApiCallback 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 = closeChatsBulkValidateBeforeCall(closeChatsBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for closeReadChats
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call closeReadChatsCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/chats/close/read";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call closeReadChatsValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = closeReadChatsCall(progressListener, progressRequestListener);
        return call;

    }

    /**
     * Close read chats
     * Close all chats that have no unread messages.
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void closeReadChats() throws ApiException {
        closeReadChatsWithHttpInfo();
    }

    /**
     * Close read chats
     * Close all chats that have no unread messages.
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse closeReadChatsWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = closeReadChatsValidateBeforeCall(null, null);
        return apiClient.execute(call);
    }

    /**
     * Close read chats (asynchronously)
     * Close all chats that have no unread messages.
     * @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 closeReadChatsAsync(final ApiCallback 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 = closeReadChatsValidateBeforeCall(progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for closeSubaccount
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call closeSubaccountCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/subaccounts/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call closeSubaccountValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling closeSubaccount(Async)");
        }
        

        com.squareup.okhttp.Call call = closeSubaccountCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Close sub-account
     * 
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void closeSubaccount(Integer id) throws ApiException {
        closeSubaccountWithHttpInfo(id);
    }

    /**
     * Close sub-account
     * 
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse closeSubaccountWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = closeSubaccountValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Close sub-account (asynchronously)
     * 
     * @param 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 closeSubaccountAsync(Integer id, final ApiCallback 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 = closeSubaccountValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for createContact
     * @param createContactInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call createContactCall(CreateContactInputObject createContactInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = createContactInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/normalized";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call createContactValidateBeforeCall(CreateContactInputObject createContactInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'createContactInputObject' is set
        if (createContactInputObject == null) {
            throw new ApiException("Missing the required parameter 'createContactInputObject' when calling createContact(Async)");
        }
        

        com.squareup.okhttp.Call call = createContactCall(createContactInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Add a new contact
     * 
     * @param createContactInputObject  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse createContact(CreateContactInputObject createContactInputObject) throws ApiException {
        ApiResponse resp = createContactWithHttpInfo(createContactInputObject);
        return resp.getData();
    }

    /**
     * Add a new contact
     * 
     * @param createContactInputObject  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse createContactWithHttpInfo(CreateContactInputObject createContactInputObject) throws ApiException {
        com.squareup.okhttp.Call call = createContactValidateBeforeCall(createContactInputObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Add a new contact (asynchronously)
     * 
     * @param createContactInputObject  (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 createContactAsync(CreateContactInputObject createContactInputObject, final ApiCallback 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 = createContactValidateBeforeCall(createContactInputObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for createContactNote
     * @param createContactNoteInputObject  (required)
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call createContactNoteCall(CreateContactNoteInputObject createContactNoteInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = createContactNoteInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/{id}/notes"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call createContactNoteValidateBeforeCall(CreateContactNoteInputObject createContactNoteInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'createContactNoteInputObject' is set
        if (createContactNoteInputObject == null) {
            throw new ApiException("Missing the required parameter 'createContactNoteInputObject' when calling createContactNote(Async)");
        }
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling createContactNote(Async)");
        }
        

        com.squareup.okhttp.Call call = createContactNoteCall(createContactNoteInputObject, id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Create a new contact note
     * 
     * @param createContactNoteInputObject  (required)
     * @param id  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse createContactNote(CreateContactNoteInputObject createContactNoteInputObject, Integer id) throws ApiException {
        ApiResponse resp = createContactNoteWithHttpInfo(createContactNoteInputObject, id);
        return resp.getData();
    }

    /**
     * Create a new contact note
     * 
     * @param createContactNoteInputObject  (required)
     * @param id  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse createContactNoteWithHttpInfo(CreateContactNoteInputObject createContactNoteInputObject, Integer id) throws ApiException {
        com.squareup.okhttp.Call call = createContactNoteValidateBeforeCall(createContactNoteInputObject, id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Create a new contact note (asynchronously)
     * 
     * @param createContactNoteInputObject  (required)
     * @param 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 createContactNoteAsync(CreateContactNoteInputObject createContactNoteInputObject, Integer id, final ApiCallback 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 = createContactNoteValidateBeforeCall(createContactNoteInputObject, id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for createCustomField
     * @param createCustomFieldInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call createCustomFieldCall(CreateCustomFieldInputObject createCustomFieldInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = createCustomFieldInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/customfields";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call createCustomFieldValidateBeforeCall(CreateCustomFieldInputObject createCustomFieldInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'createCustomFieldInputObject' is set
        if (createCustomFieldInputObject == null) {
            throw new ApiException("Missing the required parameter 'createCustomFieldInputObject' when calling createCustomField(Async)");
        }
        

        com.squareup.okhttp.Call call = createCustomFieldCall(createCustomFieldInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Add a new custom field
     * 
     * @param createCustomFieldInputObject  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse createCustomField(CreateCustomFieldInputObject createCustomFieldInputObject) throws ApiException {
        ApiResponse resp = createCustomFieldWithHttpInfo(createCustomFieldInputObject);
        return resp.getData();
    }

    /**
     * Add a new custom field
     * 
     * @param createCustomFieldInputObject  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse createCustomFieldWithHttpInfo(CreateCustomFieldInputObject createCustomFieldInputObject) throws ApiException {
        com.squareup.okhttp.Call call = createCustomFieldValidateBeforeCall(createCustomFieldInputObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Add a new custom field (asynchronously)
     * 
     * @param createCustomFieldInputObject  (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 createCustomFieldAsync(CreateCustomFieldInputObject createCustomFieldInputObject, final ApiCallback 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 = createCustomFieldValidateBeforeCall(createCustomFieldInputObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for createList
     * @param createListInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call createListCall(CreateListInputObject createListInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = createListInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/lists";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call createListValidateBeforeCall(CreateListInputObject createListInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'createListInputObject' is set
        if (createListInputObject == null) {
            throw new ApiException("Missing the required parameter 'createListInputObject' when calling createList(Async)");
        }
        

        com.squareup.okhttp.Call call = createListCall(createListInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Create a new list
     * 
     * @param createListInputObject  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse createList(CreateListInputObject createListInputObject) throws ApiException {
        ApiResponse resp = createListWithHttpInfo(createListInputObject);
        return resp.getData();
    }

    /**
     * Create a new list
     * 
     * @param createListInputObject  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse createListWithHttpInfo(CreateListInputObject createListInputObject) throws ApiException {
        com.squareup.okhttp.Call call = createListValidateBeforeCall(createListInputObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Create a new list (asynchronously)
     * 
     * @param createListInputObject  (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 createListAsync(CreateListInputObject createListInputObject, final ApiCallback 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 = createListValidateBeforeCall(createListInputObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for createTemplate
     * @param createTemplateInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call createTemplateCall(CreateTemplateInputObject createTemplateInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = createTemplateInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/templates";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call createTemplateValidateBeforeCall(CreateTemplateInputObject createTemplateInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'createTemplateInputObject' is set
        if (createTemplateInputObject == null) {
            throw new ApiException("Missing the required parameter 'createTemplateInputObject' when calling createTemplate(Async)");
        }
        

        com.squareup.okhttp.Call call = createTemplateCall(createTemplateInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Create a template
     * There are times when creating a new template makes sense (such as when targeting specific clients or improving your business strategies).  You can create new SMS templates for marketing purposes or SMS templates for business campaigns. 
     * @param createTemplateInputObject  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse createTemplate(CreateTemplateInputObject createTemplateInputObject) throws ApiException {
        ApiResponse resp = createTemplateWithHttpInfo(createTemplateInputObject);
        return resp.getData();
    }

    /**
     * Create a template
     * There are times when creating a new template makes sense (such as when targeting specific clients or improving your business strategies).  You can create new SMS templates for marketing purposes or SMS templates for business campaigns. 
     * @param createTemplateInputObject  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse createTemplateWithHttpInfo(CreateTemplateInputObject createTemplateInputObject) throws ApiException {
        com.squareup.okhttp.Call call = createTemplateValidateBeforeCall(createTemplateInputObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Create a template (asynchronously)
     * There are times when creating a new template makes sense (such as when targeting specific clients or improving your business strategies).  You can create new SMS templates for marketing purposes or SMS templates for business campaigns. 
     * @param createTemplateInputObject  (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 createTemplateAsync(CreateTemplateInputObject createTemplateInputObject, final ApiCallback 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 = createTemplateValidateBeforeCall(createTemplateInputObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for deleteAllContacts
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteAllContactsCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contact/all";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteAllContactsValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = deleteAllContactsCall(progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete contacts (bulk)
     * 
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteAllContacts() throws ApiException {
        deleteAllContactsWithHttpInfo();
    }

    /**
     * Delete contacts (bulk)
     * 
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteAllContactsWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = deleteAllContactsValidateBeforeCall(null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete contacts (bulk) (asynchronously)
     * 
     * @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 deleteAllContactsAsync(final ApiCallback 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 = deleteAllContactsValidateBeforeCall(progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteAllOutboundMessages
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteAllOutboundMessagesCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/message/all";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteAllOutboundMessagesValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = deleteAllOutboundMessagesCall(progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete all messages
     * Delete all messages.
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteAllOutboundMessages() throws ApiException {
        deleteAllOutboundMessagesWithHttpInfo();
    }

    /**
     * Delete all messages
     * Delete all messages.
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteAllOutboundMessagesWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = deleteAllOutboundMessagesValidateBeforeCall(null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete all messages (asynchronously)
     * Delete all messages.
     * @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 deleteAllOutboundMessagesAsync(final ApiCallback 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 = deleteAllOutboundMessagesValidateBeforeCall(progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteAvatar
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteAvatarCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/user/avatar";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteAvatarValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = deleteAvatarCall(progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete an avatar
     * 
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteAvatar() throws ApiException {
        deleteAvatarWithHttpInfo();
    }

    /**
     * Delete an avatar
     * 
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteAvatarWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = deleteAvatarValidateBeforeCall(null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete an avatar (asynchronously)
     * 
     * @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 deleteAvatarAsync(final ApiCallback 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 = deleteAvatarValidateBeforeCall(progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteChatMessages
     * @param deleteChatMessagesBulkInputObject  (required)
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteChatMessagesCall(DeleteChatMessagesBulkInputObject deleteChatMessagesBulkInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deleteChatMessagesBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/chats/{id}/messages/delete"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteChatMessagesValidateBeforeCall(DeleteChatMessagesBulkInputObject deleteChatMessagesBulkInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'deleteChatMessagesBulkInputObject' is set
        if (deleteChatMessagesBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'deleteChatMessagesBulkInputObject' when calling deleteChatMessages(Async)");
        }
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteChatMessages(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteChatMessagesCall(deleteChatMessagesBulkInputObject, id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete chat messages by ID(s)
     * Delete messages from chat by given message IDs.
     * @param deleteChatMessagesBulkInputObject  (required)
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteChatMessages(DeleteChatMessagesBulkInputObject deleteChatMessagesBulkInputObject, Integer id) throws ApiException {
        deleteChatMessagesWithHttpInfo(deleteChatMessagesBulkInputObject, id);
    }

    /**
     * Delete chat messages by ID(s)
     * Delete messages from chat by given message IDs.
     * @param deleteChatMessagesBulkInputObject  (required)
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteChatMessagesWithHttpInfo(DeleteChatMessagesBulkInputObject deleteChatMessagesBulkInputObject, Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteChatMessagesValidateBeforeCall(deleteChatMessagesBulkInputObject, id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete chat messages by ID(s) (asynchronously)
     * Delete messages from chat by given message IDs.
     * @param deleteChatMessagesBulkInputObject  (required)
     * @param 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 deleteChatMessagesAsync(DeleteChatMessagesBulkInputObject deleteChatMessagesBulkInputObject, Integer id, final ApiCallback 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 = deleteChatMessagesValidateBeforeCall(deleteChatMessagesBulkInputObject, id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteChatsBulk
     * @param deleteChatsBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteChatsBulkCall(DeleteChatsBulkInputObject deleteChatsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deleteChatsBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/chats/delete";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteChatsBulkValidateBeforeCall(DeleteChatsBulkInputObject deleteChatsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'deleteChatsBulkInputObject' is set
        if (deleteChatsBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'deleteChatsBulkInputObject' when calling deleteChatsBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteChatsBulkCall(deleteChatsBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete chats (bulk)
     * Delete chats by given IDs or delete all chats.
     * @param deleteChatsBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteChatsBulk(DeleteChatsBulkInputObject deleteChatsBulkInputObject) throws ApiException {
        deleteChatsBulkWithHttpInfo(deleteChatsBulkInputObject);
    }

    /**
     * Delete chats (bulk)
     * Delete chats by given IDs or delete all chats.
     * @param deleteChatsBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteChatsBulkWithHttpInfo(DeleteChatsBulkInputObject deleteChatsBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = deleteChatsBulkValidateBeforeCall(deleteChatsBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete chats (bulk) (asynchronously)
     * Delete chats by given IDs or delete all chats.
     * @param deleteChatsBulkInputObject  (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 deleteChatsBulkAsync(DeleteChatsBulkInputObject deleteChatsBulkInputObject, final ApiCallback 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 = deleteChatsBulkValidateBeforeCall(deleteChatsBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteContact
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteContactCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteContactValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteContact(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteContactCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete a contact
     * > This command removes your contact completely. If it was assigned or saved to a shared list, it will disappear from there too. If you only need to remove a contact from selected lists, use the Contact assignment command in the Lists section instead, rather than deleting the contact. 
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteContact(Integer id) throws ApiException {
        deleteContactWithHttpInfo(id);
    }

    /**
     * Delete a contact
     * > This command removes your contact completely. If it was assigned or saved to a shared list, it will disappear from there too. If you only need to remove a contact from selected lists, use the Contact assignment command in the Lists section instead, rather than deleting the contact. 
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteContactWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteContactValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete a contact (asynchronously)
     * > This command removes your contact completely. If it was assigned or saved to a shared list, it will disappear from there too. If you only need to remove a contact from selected lists, use the Contact assignment command in the Lists section instead, rather than deleting the contact. 
     * @param 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 deleteContactAsync(Integer id, final ApiCallback 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 = deleteContactValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteContactAvatar
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteContactAvatarCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/{id}/avatar"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteContactAvatarValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteContactAvatar(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteContactAvatarCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete an avatar
     * 
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteContactAvatar(Integer id) throws ApiException {
        deleteContactAvatarWithHttpInfo(id);
    }

    /**
     * Delete an avatar
     * 
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteContactAvatarWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteContactAvatarValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete an avatar (asynchronously)
     * 
     * @param 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 deleteContactAvatarAsync(Integer id, final ApiCallback 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 = deleteContactAvatarValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteContactNote
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteContactNoteCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/notes/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteContactNoteValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteContactNote(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteContactNoteCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete a contact note
     * 
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteContactNote(Integer id) throws ApiException {
        deleteContactNoteWithHttpInfo(id);
    }

    /**
     * Delete a contact note
     * 
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteContactNoteWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteContactNoteValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete a contact note (asynchronously)
     * 
     * @param 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 deleteContactNoteAsync(Integer id, final ApiCallback 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 = deleteContactNoteValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteContactNotesBulk
     * @param id  (required)
     * @param deleteContactNotesBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteContactNotesBulkCall(Integer id, DeleteContactNotesBulkInputObject deleteContactNotesBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deleteContactNotesBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/{id}/notes/delete"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteContactNotesBulkValidateBeforeCall(Integer id, DeleteContactNotesBulkInputObject deleteContactNotesBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteContactNotesBulk(Async)");
        }
        
        // verify the required parameter 'deleteContactNotesBulkInputObject' is set
        if (deleteContactNotesBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'deleteContactNotesBulkInputObject' when calling deleteContactNotesBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteContactNotesBulkCall(id, deleteContactNotesBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete contact notes (bulk)
     * 
     * @param id  (required)
     * @param deleteContactNotesBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteContactNotesBulk(Integer id, DeleteContactNotesBulkInputObject deleteContactNotesBulkInputObject) throws ApiException {
        deleteContactNotesBulkWithHttpInfo(id, deleteContactNotesBulkInputObject);
    }

    /**
     * Delete contact notes (bulk)
     * 
     * @param id  (required)
     * @param deleteContactNotesBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteContactNotesBulkWithHttpInfo(Integer id, DeleteContactNotesBulkInputObject deleteContactNotesBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = deleteContactNotesBulkValidateBeforeCall(id, deleteContactNotesBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete contact notes (bulk) (asynchronously)
     * 
     * @param id  (required)
     * @param deleteContactNotesBulkInputObject  (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 deleteContactNotesBulkAsync(Integer id, DeleteContactNotesBulkInputObject deleteContactNotesBulkInputObject, final ApiCallback 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 = deleteContactNotesBulkValidateBeforeCall(id, deleteContactNotesBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteContactsByIds
     * @param deleteContactsByIdsInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteContactsByIdsCall(DeleteContactsByIdsInputObject deleteContactsByIdsInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deleteContactsByIdsInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/delete";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteContactsByIdsValidateBeforeCall(DeleteContactsByIdsInputObject deleteContactsByIdsInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'deleteContactsByIdsInputObject' is set
        if (deleteContactsByIdsInputObject == null) {
            throw new ApiException("Missing the required parameter 'deleteContactsByIdsInputObject' when calling deleteContactsByIds(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteContactsByIdsCall(deleteContactsByIdsInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete contacts by IDs (bulk)
     * 
     * @param deleteContactsByIdsInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteContactsByIds(DeleteContactsByIdsInputObject deleteContactsByIdsInputObject) throws ApiException {
        deleteContactsByIdsWithHttpInfo(deleteContactsByIdsInputObject);
    }

    /**
     * Delete contacts by IDs (bulk)
     * 
     * @param deleteContactsByIdsInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteContactsByIdsWithHttpInfo(DeleteContactsByIdsInputObject deleteContactsByIdsInputObject) throws ApiException {
        com.squareup.okhttp.Call call = deleteContactsByIdsValidateBeforeCall(deleteContactsByIdsInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete contacts by IDs (bulk) (asynchronously)
     * 
     * @param deleteContactsByIdsInputObject  (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 deleteContactsByIdsAsync(DeleteContactsByIdsInputObject deleteContactsByIdsInputObject, final ApiCallback 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 = deleteContactsByIdsValidateBeforeCall(deleteContactsByIdsInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteContactsFromList
     * @param deleteContacsFromListObject  (required)
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteContactsFromListCall(DeleteContacsFromListObject deleteContacsFromListObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deleteContacsFromListObject;

        // create path and map variables
        String localVarPath = "/api/v2/lists/{id}/contacts"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteContactsFromListValidateBeforeCall(DeleteContacsFromListObject deleteContacsFromListObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'deleteContacsFromListObject' is set
        if (deleteContacsFromListObject == null) {
            throw new ApiException("Missing the required parameter 'deleteContacsFromListObject' when calling deleteContactsFromList(Async)");
        }
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteContactsFromList(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteContactsFromListCall(deleteContacsFromListObject, id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Unassign contacts from a list
     * > When you remove contacts from a specific list, they will be deleted permanently, unless they are first saved in another list. 
     * @param deleteContacsFromListObject  (required)
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteContactsFromList(DeleteContacsFromListObject deleteContacsFromListObject, Integer id) throws ApiException {
        deleteContactsFromListWithHttpInfo(deleteContacsFromListObject, id);
    }

    /**
     * Unassign contacts from a list
     * > When you remove contacts from a specific list, they will be deleted permanently, unless they are first saved in another list. 
     * @param deleteContacsFromListObject  (required)
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteContactsFromListWithHttpInfo(DeleteContacsFromListObject deleteContacsFromListObject, Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteContactsFromListValidateBeforeCall(deleteContacsFromListObject, id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Unassign contacts from a list (asynchronously)
     * > When you remove contacts from a specific list, they will be deleted permanently, unless they are first saved in another list. 
     * @param deleteContacsFromListObject  (required)
     * @param 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 deleteContactsFromListAsync(DeleteContacsFromListObject deleteContacsFromListObject, Integer id, final ApiCallback 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 = deleteContactsFromListValidateBeforeCall(deleteContacsFromListObject, id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteCustomField
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteCustomFieldCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/customfields/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteCustomFieldValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteCustomField(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteCustomFieldCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete a custom field
     * > When a custom field is deleted, all the information that was added to contacts under this custom field will also be lost. 
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteCustomField(Integer id) throws ApiException {
        deleteCustomFieldWithHttpInfo(id);
    }

    /**
     * Delete a custom field
     * > When a custom field is deleted, all the information that was added to contacts under this custom field will also be lost. 
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteCustomFieldWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteCustomFieldValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete a custom field (asynchronously)
     * > When a custom field is deleted, all the information that was added to contacts under this custom field will also be lost. 
     * @param 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 deleteCustomFieldAsync(Integer id, final ApiCallback 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 = deleteCustomFieldValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteDedicatedNumber
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteDedicatedNumberCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/numbers/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteDedicatedNumberValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteDedicatedNumber(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteDedicatedNumberCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Cancel a dedicated number subscription
     * 
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteDedicatedNumber(Integer id) throws ApiException {
        deleteDedicatedNumberWithHttpInfo(id);
    }

    /**
     * Cancel a dedicated number subscription
     * 
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteDedicatedNumberWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteDedicatedNumberValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Cancel a dedicated number subscription (asynchronously)
     * 
     * @param 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 deleteDedicatedNumberAsync(Integer id, final ApiCallback 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 = deleteDedicatedNumberValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteInboundMessage
     * @param id The unique numeric ID for the inbound message. (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteInboundMessageCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/replies/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteInboundMessageValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteInboundMessage(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteInboundMessageCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete a single inbound message
     * > Note: deleted inbound messages will disappear from TextMagic Online, chats, and any other place they are referenced.  So, be careful! 
     * @param id The unique numeric ID for the inbound message. (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteInboundMessage(Integer id) throws ApiException {
        deleteInboundMessageWithHttpInfo(id);
    }

    /**
     * Delete a single inbound message
     * > Note: deleted inbound messages will disappear from TextMagic Online, chats, and any other place they are referenced.  So, be careful! 
     * @param id The unique numeric ID for the inbound message. (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteInboundMessageWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteInboundMessageValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete a single inbound message (asynchronously)
     * > Note: deleted inbound messages will disappear from TextMagic Online, chats, and any other place they are referenced.  So, be careful! 
     * @param id The unique numeric ID for the inbound message. (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 deleteInboundMessageAsync(Integer id, final ApiCallback 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 = deleteInboundMessageValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteInboundMessagesBulk
     * @param deleteInboundMessagesBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteInboundMessagesBulkCall(DeleteInboundMessagesBulkInputObject deleteInboundMessagesBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deleteInboundMessagesBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/replies/delete";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteInboundMessagesBulkValidateBeforeCall(DeleteInboundMessagesBulkInputObject deleteInboundMessagesBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'deleteInboundMessagesBulkInputObject' is set
        if (deleteInboundMessagesBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'deleteInboundMessagesBulkInputObject' when calling deleteInboundMessagesBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteInboundMessagesBulkCall(deleteInboundMessagesBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete inbound messages (bulk)
     * > Note: deleted inbound messages will disappear from TextMagic Online, chats, and any other place they are referenced.  So, be careful! 
     * @param deleteInboundMessagesBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteInboundMessagesBulk(DeleteInboundMessagesBulkInputObject deleteInboundMessagesBulkInputObject) throws ApiException {
        deleteInboundMessagesBulkWithHttpInfo(deleteInboundMessagesBulkInputObject);
    }

    /**
     * Delete inbound messages (bulk)
     * > Note: deleted inbound messages will disappear from TextMagic Online, chats, and any other place they are referenced.  So, be careful! 
     * @param deleteInboundMessagesBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteInboundMessagesBulkWithHttpInfo(DeleteInboundMessagesBulkInputObject deleteInboundMessagesBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = deleteInboundMessagesBulkValidateBeforeCall(deleteInboundMessagesBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete inbound messages (bulk) (asynchronously)
     * > Note: deleted inbound messages will disappear from TextMagic Online, chats, and any other place they are referenced.  So, be careful! 
     * @param deleteInboundMessagesBulkInputObject  (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 deleteInboundMessagesBulkAsync(DeleteInboundMessagesBulkInputObject deleteInboundMessagesBulkInputObject, final ApiCallback 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 = deleteInboundMessagesBulkValidateBeforeCall(deleteInboundMessagesBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteList
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteListCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/lists/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteListValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteList(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteListCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete a list
     * This command has no parameters. If successful, this command will return the standard delete response (204 No Content); otherwise, a standard error response will be returned.  When you delete a list, the contacts in it are deleted as well, unless they were saved in another list.
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteList(Integer id) throws ApiException {
        deleteListWithHttpInfo(id);
    }

    /**
     * Delete a list
     * This command has no parameters. If successful, this command will return the standard delete response (204 No Content); otherwise, a standard error response will be returned.  When you delete a list, the contacts in it are deleted as well, unless they were saved in another list.
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteListWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteListValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete a list (asynchronously)
     * This command has no parameters. If successful, this command will return the standard delete response (204 No Content); otherwise, a standard error response will be returned.  When you delete a list, the contacts in it are deleted as well, unless they were saved in another list.
     * @param 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 deleteListAsync(Integer id, final ApiCallback 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 = deleteListValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteListAvatar
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteListAvatarCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/lists/{id}/avatar"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteListAvatarValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteListAvatar(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteListAvatarCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete an avatar for a list
     * Delete an avatar for a list
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteListAvatar(Integer id) throws ApiException {
        deleteListAvatarWithHttpInfo(id);
    }

    /**
     * Delete an avatar for a list
     * Delete an avatar for a list
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteListAvatarWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteListAvatarValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete an avatar for a list (asynchronously)
     * Delete an avatar for a list
     * @param 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 deleteListAvatarAsync(Integer id, final ApiCallback 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 = deleteListAvatarValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteListContactsBulk
     * @param deleteListContactsBulkInputObject  (required)
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteListContactsBulkCall(DeleteListContactsBulkInputObject deleteListContactsBulkInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deleteListContactsBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/lists/{id}/contacts/delete"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteListContactsBulkValidateBeforeCall(DeleteListContactsBulkInputObject deleteListContactsBulkInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'deleteListContactsBulkInputObject' is set
        if (deleteListContactsBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'deleteListContactsBulkInputObject' when calling deleteListContactsBulk(Async)");
        }
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteListContactsBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteListContactsBulkCall(deleteListContactsBulkInputObject, id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete contacts from a list (bulk)
     * Delete contacts from a list (bulk)
     * @param deleteListContactsBulkInputObject  (required)
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteListContactsBulk(DeleteListContactsBulkInputObject deleteListContactsBulkInputObject, Integer id) throws ApiException {
        deleteListContactsBulkWithHttpInfo(deleteListContactsBulkInputObject, id);
    }

    /**
     * Delete contacts from a list (bulk)
     * Delete contacts from a list (bulk)
     * @param deleteListContactsBulkInputObject  (required)
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteListContactsBulkWithHttpInfo(DeleteListContactsBulkInputObject deleteListContactsBulkInputObject, Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteListContactsBulkValidateBeforeCall(deleteListContactsBulkInputObject, id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete contacts from a list (bulk) (asynchronously)
     * Delete contacts from a list (bulk)
     * @param deleteListContactsBulkInputObject  (required)
     * @param 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 deleteListContactsBulkAsync(DeleteListContactsBulkInputObject deleteListContactsBulkInputObject, Integer id, final ApiCallback 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 = deleteListContactsBulkValidateBeforeCall(deleteListContactsBulkInputObject, id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteListsBulk
     * @param deleteListsBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteListsBulkCall(DeleteListsBulkInputObject deleteListsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deleteListsBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/lists/delete";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteListsBulkValidateBeforeCall(DeleteListsBulkInputObject deleteListsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'deleteListsBulkInputObject' is set
        if (deleteListsBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'deleteListsBulkInputObject' when calling deleteListsBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteListsBulkCall(deleteListsBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete lists (bulk)
     * 
     * @param deleteListsBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteListsBulk(DeleteListsBulkInputObject deleteListsBulkInputObject) throws ApiException {
        deleteListsBulkWithHttpInfo(deleteListsBulkInputObject);
    }

    /**
     * Delete lists (bulk)
     * 
     * @param deleteListsBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteListsBulkWithHttpInfo(DeleteListsBulkInputObject deleteListsBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = deleteListsBulkValidateBeforeCall(deleteListsBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete lists (bulk) (asynchronously)
     * 
     * @param deleteListsBulkInputObject  (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 deleteListsBulkAsync(DeleteListsBulkInputObject deleteListsBulkInputObject, final ApiCallback 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 = deleteListsBulkValidateBeforeCall(deleteListsBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteMessageSession
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteMessageSessionCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/sessions/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteMessageSessionValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteMessageSession(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteMessageSessionCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete a session
     * Delete a message session, together with all nested messages. > You will not be refunded for any deleted sent sessions. 
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteMessageSession(Integer id) throws ApiException {
        deleteMessageSessionWithHttpInfo(id);
    }

    /**
     * Delete a session
     * Delete a message session, together with all nested messages. > You will not be refunded for any deleted sent sessions. 
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteMessageSessionWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteMessageSessionValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete a session (asynchronously)
     * Delete a message session, together with all nested messages. > You will not be refunded for any deleted sent sessions. 
     * @param 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 deleteMessageSessionAsync(Integer id, final ApiCallback 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 = deleteMessageSessionValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteMessageSessionsBulk
     * @param deleteMessageSessionsBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteMessageSessionsBulkCall(DeleteMessageSessionsBulkInputObject deleteMessageSessionsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deleteMessageSessionsBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/sessions/delete";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteMessageSessionsBulkValidateBeforeCall(DeleteMessageSessionsBulkInputObject deleteMessageSessionsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'deleteMessageSessionsBulkInputObject' is set
        if (deleteMessageSessionsBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'deleteMessageSessionsBulkInputObject' when calling deleteMessageSessionsBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteMessageSessionsBulkCall(deleteMessageSessionsBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete sessions (bulk)
     * Delete message sessions, together with all nested messages, by given ID(s) or delete all message sessions.
     * @param deleteMessageSessionsBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteMessageSessionsBulk(DeleteMessageSessionsBulkInputObject deleteMessageSessionsBulkInputObject) throws ApiException {
        deleteMessageSessionsBulkWithHttpInfo(deleteMessageSessionsBulkInputObject);
    }

    /**
     * Delete sessions (bulk)
     * Delete message sessions, together with all nested messages, by given ID(s) or delete all message sessions.
     * @param deleteMessageSessionsBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteMessageSessionsBulkWithHttpInfo(DeleteMessageSessionsBulkInputObject deleteMessageSessionsBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = deleteMessageSessionsBulkValidateBeforeCall(deleteMessageSessionsBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete sessions (bulk) (asynchronously)
     * Delete message sessions, together with all nested messages, by given ID(s) or delete all message sessions.
     * @param deleteMessageSessionsBulkInputObject  (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 deleteMessageSessionsBulkAsync(DeleteMessageSessionsBulkInputObject deleteMessageSessionsBulkInputObject, final ApiCallback 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 = deleteMessageSessionsBulkValidateBeforeCall(deleteMessageSessionsBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteOutboundMessage
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteOutboundMessageCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/messages/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteOutboundMessageValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteOutboundMessage(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteOutboundMessageCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete message
     * Delete a single message.
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteOutboundMessage(Integer id) throws ApiException {
        deleteOutboundMessageWithHttpInfo(id);
    }

    /**
     * Delete message
     * Delete a single message.
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteOutboundMessageWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteOutboundMessageValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete message (asynchronously)
     * Delete a single message.
     * @param 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 deleteOutboundMessageAsync(Integer id, final ApiCallback 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 = deleteOutboundMessageValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteOutboundMessagesBulk
     * @param deleteOutboundMessagesBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteOutboundMessagesBulkCall(DeleteOutboundMessagesBulkInputObject deleteOutboundMessagesBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deleteOutboundMessagesBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/messages/delete";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteOutboundMessagesBulkValidateBeforeCall(DeleteOutboundMessagesBulkInputObject deleteOutboundMessagesBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'deleteOutboundMessagesBulkInputObject' is set
        if (deleteOutboundMessagesBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'deleteOutboundMessagesBulkInputObject' when calling deleteOutboundMessagesBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteOutboundMessagesBulkCall(deleteOutboundMessagesBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete messages (bulk)
     * Delete outbound messages by the given ID(s) or delete all outbound messages.
     * @param deleteOutboundMessagesBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteOutboundMessagesBulk(DeleteOutboundMessagesBulkInputObject deleteOutboundMessagesBulkInputObject) throws ApiException {
        deleteOutboundMessagesBulkWithHttpInfo(deleteOutboundMessagesBulkInputObject);
    }

    /**
     * Delete messages (bulk)
     * Delete outbound messages by the given ID(s) or delete all outbound messages.
     * @param deleteOutboundMessagesBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteOutboundMessagesBulkWithHttpInfo(DeleteOutboundMessagesBulkInputObject deleteOutboundMessagesBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = deleteOutboundMessagesBulkValidateBeforeCall(deleteOutboundMessagesBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete messages (bulk) (asynchronously)
     * Delete outbound messages by the given ID(s) or delete all outbound messages.
     * @param deleteOutboundMessagesBulkInputObject  (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 deleteOutboundMessagesBulkAsync(DeleteOutboundMessagesBulkInputObject deleteOutboundMessagesBulkInputObject, final ApiCallback 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 = deleteOutboundMessagesBulkValidateBeforeCall(deleteOutboundMessagesBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteScheduledMessage
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteScheduledMessageCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/schedules/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteScheduledMessageValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteScheduledMessage(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteScheduledMessageCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete a single scheduled message
     * 
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteScheduledMessage(Integer id) throws ApiException {
        deleteScheduledMessageWithHttpInfo(id);
    }

    /**
     * Delete a single scheduled message
     * 
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteScheduledMessageWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteScheduledMessageValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete a single scheduled message (asynchronously)
     * 
     * @param 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 deleteScheduledMessageAsync(Integer id, final ApiCallback 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 = deleteScheduledMessageValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteScheduledMessagesBulk
     * @param deleteScheduledMessagesBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteScheduledMessagesBulkCall(DeleteScheduledMessagesBulkInputObject deleteScheduledMessagesBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deleteScheduledMessagesBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/schedules/delete";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteScheduledMessagesBulkValidateBeforeCall(DeleteScheduledMessagesBulkInputObject deleteScheduledMessagesBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'deleteScheduledMessagesBulkInputObject' is set
        if (deleteScheduledMessagesBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'deleteScheduledMessagesBulkInputObject' when calling deleteScheduledMessagesBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteScheduledMessagesBulkCall(deleteScheduledMessagesBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete scheduled messages (bulk)
     * 
     * @param deleteScheduledMessagesBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteScheduledMessagesBulk(DeleteScheduledMessagesBulkInputObject deleteScheduledMessagesBulkInputObject) throws ApiException {
        deleteScheduledMessagesBulkWithHttpInfo(deleteScheduledMessagesBulkInputObject);
    }

    /**
     * Delete scheduled messages (bulk)
     * 
     * @param deleteScheduledMessagesBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteScheduledMessagesBulkWithHttpInfo(DeleteScheduledMessagesBulkInputObject deleteScheduledMessagesBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = deleteScheduledMessagesBulkValidateBeforeCall(deleteScheduledMessagesBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete scheduled messages (bulk) (asynchronously)
     * 
     * @param deleteScheduledMessagesBulkInputObject  (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 deleteScheduledMessagesBulkAsync(DeleteScheduledMessagesBulkInputObject deleteScheduledMessagesBulkInputObject, final ApiCallback 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 = deleteScheduledMessagesBulkValidateBeforeCall(deleteScheduledMessagesBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteSenderId
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteSenderIdCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/senderids/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteSenderIdValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteSenderId(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteSenderIdCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete a Sender ID
     * 
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteSenderId(Integer id) throws ApiException {
        deleteSenderIdWithHttpInfo(id);
    }

    /**
     * Delete a Sender ID
     * 
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteSenderIdWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteSenderIdValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete a Sender ID (asynchronously)
     * 
     * @param 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 deleteSenderIdAsync(Integer id, final ApiCallback 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 = deleteSenderIdValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteTemplate
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteTemplateCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/templates/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteTemplateValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteTemplate(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteTemplateCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete a template
     * 
     * @param id  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteTemplate(Integer id) throws ApiException {
        deleteTemplateWithHttpInfo(id);
    }

    /**
     * Delete a template
     * 
     * @param id  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteTemplateWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = deleteTemplateValidateBeforeCall(id, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete a template (asynchronously)
     * 
     * @param 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 deleteTemplateAsync(Integer id, final ApiCallback 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 = deleteTemplateValidateBeforeCall(id, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for deleteTemplatesBulk
     * @param deleteTemplatesBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteTemplatesBulkCall(DeleteTemplatesBulkInputObject deleteTemplatesBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deleteTemplatesBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/templates/delete";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteTemplatesBulkValidateBeforeCall(DeleteTemplatesBulkInputObject deleteTemplatesBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'deleteTemplatesBulkInputObject' is set
        if (deleteTemplatesBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'deleteTemplatesBulkInputObject' when calling deleteTemplatesBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteTemplatesBulkCall(deleteTemplatesBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete templates (bulk)
     * Delete templates by given IDs or delete all templates.
     * @param deleteTemplatesBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void deleteTemplatesBulk(DeleteTemplatesBulkInputObject deleteTemplatesBulkInputObject) throws ApiException {
        deleteTemplatesBulkWithHttpInfo(deleteTemplatesBulkInputObject);
    }

    /**
     * Delete templates (bulk)
     * Delete templates by given IDs or delete all templates.
     * @param deleteTemplatesBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteTemplatesBulkWithHttpInfo(DeleteTemplatesBulkInputObject deleteTemplatesBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = deleteTemplatesBulkValidateBeforeCall(deleteTemplatesBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete templates (bulk) (asynchronously)
     * Delete templates by given IDs or delete all templates.
     * @param deleteTemplatesBulkInputObject  (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 deleteTemplatesBulkAsync(DeleteTemplatesBulkInputObject deleteTemplatesBulkInputObject, final ApiCallback 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 = deleteTemplatesBulkValidateBeforeCall(deleteTemplatesBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for doCarrierLookup
     * @param phone Phone number in [E.164 format](https://en.wikipedia.org/wiki/E.164) or in [National format](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers).  (required)
     * @param country This option must be specified only if the phone number is in a **[National format](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers)**.  (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call doCarrierLookupCall(String phone, String country, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/lookups/{phone}"
            .replaceAll("\\{" + "phone" + "\\}", apiClient.escapeString(phone.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (country != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("country", country));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call doCarrierLookupValidateBeforeCall(String phone, String country, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'phone' is set
        if (phone == null) {
            throw new ApiException("Missing the required parameter 'phone' when calling doCarrierLookup(Async)");
        }
        

        com.squareup.okhttp.Call call = doCarrierLookupCall(phone, country, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Carrier Lookup
     * This API call allows you to retrieve additional information about a phone number: region-specific phone number formatting, carrier, phone type (landline/mobile) and country information.  > Numbers must be checked one by one. You cannot check multiple numbers in one request.   
     * @param phone Phone number in [E.164 format](https://en.wikipedia.org/wiki/E.164) or in [National format](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers).  (required)
     * @param country This option must be specified only if the phone number is in a **[National format](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers)**.  (optional)
     * @return DoCarrierLookupResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public DoCarrierLookupResponse doCarrierLookup(String phone, String country) throws ApiException {
        ApiResponse resp = doCarrierLookupWithHttpInfo(phone, country);
        return resp.getData();
    }

    /**
     * Carrier Lookup
     * This API call allows you to retrieve additional information about a phone number: region-specific phone number formatting, carrier, phone type (landline/mobile) and country information.  > Numbers must be checked one by one. You cannot check multiple numbers in one request.   
     * @param phone Phone number in [E.164 format](https://en.wikipedia.org/wiki/E.164) or in [National format](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers).  (required)
     * @param country This option must be specified only if the phone number is in a **[National format](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers)**.  (optional)
     * @return ApiResponse<DoCarrierLookupResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse doCarrierLookupWithHttpInfo(String phone, String country) throws ApiException {
        com.squareup.okhttp.Call call = doCarrierLookupValidateBeforeCall(phone, country, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Carrier Lookup (asynchronously)
     * This API call allows you to retrieve additional information about a phone number: region-specific phone number formatting, carrier, phone type (landline/mobile) and country information.  > Numbers must be checked one by one. You cannot check multiple numbers in one request.   
     * @param phone Phone number in [E.164 format](https://en.wikipedia.org/wiki/E.164) or in [National format](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers).  (required)
     * @param country This option must be specified only if the phone number is in a **[National format](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers)**.  (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 doCarrierLookupAsync(String phone, String country, final ApiCallback 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 = doCarrierLookupValidateBeforeCall(phone, country, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for doEmailLookup
     * @param email Email address. (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call doEmailLookupCall(String email, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/email-lookups/{email}"
            .replaceAll("\\{" + "email" + "\\}", apiClient.escapeString(email.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call doEmailLookupValidateBeforeCall(String email, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'email' is set
        if (email == null) {
            throw new ApiException("Missing the required parameter 'email' when calling doEmailLookup(Async)");
        }
        

        com.squareup.okhttp.Call call = doEmailLookupCall(email, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Email Lookup
     * To get more details about an email address or to check whether it is a valid email or not, you can use the Email Lookup command. To upload and check emails in bulk, please use our [Web app](https://my.textmagic.com/online/email-lookup/).  This API call allows you to retrieve additional information about an email address, such as mailbox detection, syntax checks, DNS validation, deliverability status, and many more helpful values (see the table below).  > Emails must be checked one by one. You cannot check multiple emails in one request. To upload and check emails in bulk, please use our [Web app](https://my.textmagic.com/online/email-lookup/).
     * @param email Email address. (required)
     * @return DoEmailLookupResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public DoEmailLookupResponse doEmailLookup(String email) throws ApiException {
        ApiResponse resp = doEmailLookupWithHttpInfo(email);
        return resp.getData();
    }

    /**
     * Email Lookup
     * To get more details about an email address or to check whether it is a valid email or not, you can use the Email Lookup command. To upload and check emails in bulk, please use our [Web app](https://my.textmagic.com/online/email-lookup/).  This API call allows you to retrieve additional information about an email address, such as mailbox detection, syntax checks, DNS validation, deliverability status, and many more helpful values (see the table below).  > Emails must be checked one by one. You cannot check multiple emails in one request. To upload and check emails in bulk, please use our [Web app](https://my.textmagic.com/online/email-lookup/).
     * @param email Email address. (required)
     * @return ApiResponse<DoEmailLookupResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse doEmailLookupWithHttpInfo(String email) throws ApiException {
        com.squareup.okhttp.Call call = doEmailLookupValidateBeforeCall(email, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Email Lookup (asynchronously)
     * To get more details about an email address or to check whether it is a valid email or not, you can use the Email Lookup command. To upload and check emails in bulk, please use our [Web app](https://my.textmagic.com/online/email-lookup/).  This API call allows you to retrieve additional information about an email address, such as mailbox detection, syntax checks, DNS validation, deliverability status, and many more helpful values (see the table below).  > Emails must be checked one by one. You cannot check multiple emails in one request. To upload and check emails in bulk, please use our [Web app](https://my.textmagic.com/online/email-lookup/).
     * @param email Email address. (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 doEmailLookupAsync(String email, final ApiCallback 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 = doEmailLookupValidateBeforeCall(email, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getAllBulkSessions
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getAllBulkSessionsCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/bulks";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getAllBulkSessionsValidateBeforeCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getAllBulkSessionsCall(page, limit, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all bulk sessions
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return GetAllBulkSessionsPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetAllBulkSessionsPaginatedResponse getAllBulkSessions(Integer page, Integer limit) throws ApiException {
        ApiResponse resp = getAllBulkSessionsWithHttpInfo(page, limit);
        return resp.getData();
    }

    /**
     * Get all bulk sessions
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return ApiResponse<GetAllBulkSessionsPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getAllBulkSessionsWithHttpInfo(Integer page, Integer limit) throws ApiException {
        com.squareup.okhttp.Call call = getAllBulkSessionsValidateBeforeCall(page, limit, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all bulk sessions (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @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 getAllBulkSessionsAsync(Integer page, Integer limit, final ApiCallback 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 = getAllBulkSessionsValidateBeforeCall(page, limit, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getAllChats
     * @param status Fetch only (a)ctive, (c)losed or (d)eleted chats. (optional)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param voice Fetch results with voice calls. (optional, default to 0)
     * @param flat Should additional contact info be included? (optional, default to 0)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getAllChatsCall(String status, Integer page, Integer limit, String orderBy, Integer voice, Integer flat, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/chats";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (status != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("status", status));
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (orderBy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("orderBy", orderBy));
        if (voice != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("voice", voice));
        if (flat != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("flat", flat));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getAllChatsValidateBeforeCall(String status, Integer page, Integer limit, String orderBy, Integer voice, Integer flat, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getAllChatsCall(status, page, limit, orderBy, voice, flat, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all chats
     * 
     * @param status Fetch only (a)ctive, (c)losed or (d)eleted chats. (optional)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param voice Fetch results with voice calls. (optional, default to 0)
     * @param flat Should additional contact info be included? (optional, default to 0)
     * @return GetAllChatsPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetAllChatsPaginatedResponse getAllChats(String status, Integer page, Integer limit, String orderBy, Integer voice, Integer flat) throws ApiException {
        ApiResponse resp = getAllChatsWithHttpInfo(status, page, limit, orderBy, voice, flat);
        return resp.getData();
    }

    /**
     * Get all chats
     * 
     * @param status Fetch only (a)ctive, (c)losed or (d)eleted chats. (optional)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param voice Fetch results with voice calls. (optional, default to 0)
     * @param flat Should additional contact info be included? (optional, default to 0)
     * @return ApiResponse<GetAllChatsPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getAllChatsWithHttpInfo(String status, Integer page, Integer limit, String orderBy, Integer voice, Integer flat) throws ApiException {
        com.squareup.okhttp.Call call = getAllChatsValidateBeforeCall(status, page, limit, orderBy, voice, flat, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all chats (asynchronously)
     * 
     * @param status Fetch only (a)ctive, (c)losed or (d)eleted chats. (optional)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param voice Fetch results with voice calls. (optional, default to 0)
     * @param flat Should additional contact info be included? (optional, default to 0)
     * @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 getAllChatsAsync(String status, Integer page, Integer limit, String orderBy, Integer voice, Integer flat, final ApiCallback 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 = getAllChatsValidateBeforeCall(status, page, limit, orderBy, voice, flat, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getAllInboundMessages
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getAllInboundMessagesCall(Integer page, Integer limit, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/replies";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (orderBy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("orderBy", orderBy));
        if (direction != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("direction", direction));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getAllInboundMessagesValidateBeforeCall(Integer page, Integer limit, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getAllInboundMessagesCall(page, limit, orderBy, direction, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all inbound messages
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return GetAllInboundMessagesPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetAllInboundMessagesPaginatedResponse getAllInboundMessages(Integer page, Integer limit, String orderBy, String direction) throws ApiException {
        ApiResponse resp = getAllInboundMessagesWithHttpInfo(page, limit, orderBy, direction);
        return resp.getData();
    }

    /**
     * Get all inbound messages
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return ApiResponse<GetAllInboundMessagesPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getAllInboundMessagesWithHttpInfo(Integer page, Integer limit, String orderBy, String direction) throws ApiException {
        com.squareup.okhttp.Call call = getAllInboundMessagesValidateBeforeCall(page, limit, orderBy, direction, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all inbound messages (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @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 getAllInboundMessagesAsync(Integer page, Integer limit, String orderBy, String direction, final ApiCallback 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 = getAllInboundMessagesValidateBeforeCall(page, limit, orderBy, direction, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getAllMessageSessions
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getAllMessageSessionsCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/sessions";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getAllMessageSessionsValidateBeforeCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getAllMessageSessionsCall(page, limit, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all sessions
     * Get all message sending sessions. > This list contains all of your sessions, including those which were sent but not via API 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return GetAllMessageSessionsPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetAllMessageSessionsPaginatedResponse getAllMessageSessions(Integer page, Integer limit) throws ApiException {
        ApiResponse resp = getAllMessageSessionsWithHttpInfo(page, limit);
        return resp.getData();
    }

    /**
     * Get all sessions
     * Get all message sending sessions. > This list contains all of your sessions, including those which were sent but not via API 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return ApiResponse<GetAllMessageSessionsPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getAllMessageSessionsWithHttpInfo(Integer page, Integer limit) throws ApiException {
        com.squareup.okhttp.Call call = getAllMessageSessionsValidateBeforeCall(page, limit, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all sessions (asynchronously)
     * Get all message sending sessions. > This list contains all of your sessions, including those which were sent but not via API 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @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 getAllMessageSessionsAsync(Integer page, Integer limit, final ApiCallback 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 = getAllMessageSessionsValidateBeforeCall(page, limit, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getAllOutboundMessages
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param lastId Filter results by ID, selecting all values lesser than the specified ID. Note that the \\'page\\' parameter is ignored when \\'lastId\\' is specified. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getAllOutboundMessagesCall(Integer page, Integer limit, Integer lastId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/messages";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (lastId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("lastId", lastId));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getAllOutboundMessagesValidateBeforeCall(Integer page, Integer limit, Integer lastId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getAllOutboundMessagesCall(page, limit, lastId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all messages
     * Get all user oubound messages.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param lastId Filter results by ID, selecting all values lesser than the specified ID. Note that the \\'page\\' parameter is ignored when \\'lastId\\' is specified. (optional)
     * @return GetAllOutboundMessagesPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetAllOutboundMessagesPaginatedResponse getAllOutboundMessages(Integer page, Integer limit, Integer lastId) throws ApiException {
        ApiResponse resp = getAllOutboundMessagesWithHttpInfo(page, limit, lastId);
        return resp.getData();
    }

    /**
     * Get all messages
     * Get all user oubound messages.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param lastId Filter results by ID, selecting all values lesser than the specified ID. Note that the \\'page\\' parameter is ignored when \\'lastId\\' is specified. (optional)
     * @return ApiResponse<GetAllOutboundMessagesPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getAllOutboundMessagesWithHttpInfo(Integer page, Integer limit, Integer lastId) throws ApiException {
        com.squareup.okhttp.Call call = getAllOutboundMessagesValidateBeforeCall(page, limit, lastId, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all messages (asynchronously)
     * Get all user oubound messages.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param lastId Filter results by ID, selecting all values lesser than the specified ID. Note that the \\'page\\' parameter is ignored when \\'lastId\\' is specified. (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 getAllOutboundMessagesAsync(Integer page, Integer limit, Integer lastId, final ApiCallback 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 = getAllOutboundMessagesValidateBeforeCall(page, limit, lastId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getAllScheduledMessages
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param status Fetch schedules with a specific status: a - actual, c - completed, x - all. (optional, default to x)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getAllScheduledMessagesCall(Integer page, Integer limit, String status, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/schedules";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (status != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("status", status));
        if (orderBy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("orderBy", orderBy));
        if (direction != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("direction", direction));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getAllScheduledMessagesValidateBeforeCall(Integer page, Integer limit, String status, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getAllScheduledMessagesCall(page, limit, status, orderBy, direction, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all scheduled messages
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param status Fetch schedules with a specific status: a - actual, c - completed, x - all. (optional, default to x)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return GetAllScheduledMessagesPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetAllScheduledMessagesPaginatedResponse getAllScheduledMessages(Integer page, Integer limit, String status, String orderBy, String direction) throws ApiException {
        ApiResponse resp = getAllScheduledMessagesWithHttpInfo(page, limit, status, orderBy, direction);
        return resp.getData();
    }

    /**
     * Get all scheduled messages
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param status Fetch schedules with a specific status: a - actual, c - completed, x - all. (optional, default to x)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return ApiResponse<GetAllScheduledMessagesPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getAllScheduledMessagesWithHttpInfo(Integer page, Integer limit, String status, String orderBy, String direction) throws ApiException {
        com.squareup.okhttp.Call call = getAllScheduledMessagesValidateBeforeCall(page, limit, status, orderBy, direction, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all scheduled messages (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param status Fetch schedules with a specific status: a - actual, c - completed, x - all. (optional, default to x)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @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 getAllScheduledMessagesAsync(Integer page, Integer limit, String status, String orderBy, String direction, final ApiCallback 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 = getAllScheduledMessagesValidateBeforeCall(page, limit, status, orderBy, direction, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getAllTemplates
     * @param page Fetch specified results page. (optional)
     * @param limit The number of results per page. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getAllTemplatesCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/templates";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getAllTemplatesValidateBeforeCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getAllTemplatesCall(page, limit, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all templates
     * 
     * @param page Fetch specified results page. (optional)
     * @param limit The number of results per page. (optional)
     * @return GetAllTemplatesPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetAllTemplatesPaginatedResponse getAllTemplates(Integer page, Integer limit) throws ApiException {
        ApiResponse resp = getAllTemplatesWithHttpInfo(page, limit);
        return resp.getData();
    }

    /**
     * Get all templates
     * 
     * @param page Fetch specified results page. (optional)
     * @param limit The number of results per page. (optional)
     * @return ApiResponse<GetAllTemplatesPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getAllTemplatesWithHttpInfo(Integer page, Integer limit) throws ApiException {
        com.squareup.okhttp.Call call = getAllTemplatesValidateBeforeCall(page, limit, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all templates (asynchronously)
     * 
     * @param page Fetch specified results page. (optional)
     * @param limit The number of results per page. (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 getAllTemplatesAsync(Integer page, Integer limit, final ApiCallback 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 = getAllTemplatesValidateBeforeCall(page, limit, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getAvailableDedicatedNumbers
     * @param country The 2-letter dedicated number country ISO code. (required)
     * @param prefix Desired number prefix. Should include the country code (i.e. 447 for UK phone number format). Leave blank to get all the available numbers for the specified country. (optional)
     * @param tollfree Should we show only tollfree numbers (tollfree available only for US). (optional, default to 0)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getAvailableDedicatedNumbersCall(String country, Integer prefix, Integer tollfree, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/numbers/available";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (prefix != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("prefix", prefix));
        if (tollfree != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("tollfree", tollfree));
        if (country != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("country", country));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getAvailableDedicatedNumbersValidateBeforeCall(String country, Integer prefix, Integer tollfree, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'country' is set
        if (country == null) {
            throw new ApiException("Missing the required parameter 'country' when calling getAvailableDedicatedNumbers(Async)");
        }
        

        com.squareup.okhttp.Call call = getAvailableDedicatedNumbersCall(country, prefix, tollfree, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Find dedicated numbers available for purchase
     * 
     * @param country The 2-letter dedicated number country ISO code. (required)
     * @param prefix Desired number prefix. Should include the country code (i.e. 447 for UK phone number format). Leave blank to get all the available numbers for the specified country. (optional)
     * @param tollfree Should we show only tollfree numbers (tollfree available only for US). (optional, default to 0)
     * @return GetAvailableDedicatedNumbersResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetAvailableDedicatedNumbersResponse getAvailableDedicatedNumbers(String country, Integer prefix, Integer tollfree) throws ApiException {
        ApiResponse resp = getAvailableDedicatedNumbersWithHttpInfo(country, prefix, tollfree);
        return resp.getData();
    }

    /**
     * Find dedicated numbers available for purchase
     * 
     * @param country The 2-letter dedicated number country ISO code. (required)
     * @param prefix Desired number prefix. Should include the country code (i.e. 447 for UK phone number format). Leave blank to get all the available numbers for the specified country. (optional)
     * @param tollfree Should we show only tollfree numbers (tollfree available only for US). (optional, default to 0)
     * @return ApiResponse<GetAvailableDedicatedNumbersResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getAvailableDedicatedNumbersWithHttpInfo(String country, Integer prefix, Integer tollfree) throws ApiException {
        com.squareup.okhttp.Call call = getAvailableDedicatedNumbersValidateBeforeCall(country, prefix, tollfree, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Find dedicated numbers available for purchase (asynchronously)
     * 
     * @param country The 2-letter dedicated number country ISO code. (required)
     * @param prefix Desired number prefix. Should include the country code (i.e. 447 for UK phone number format). Leave blank to get all the available numbers for the specified country. (optional)
     * @param tollfree Should we show only tollfree numbers (tollfree available only for US). (optional, default to 0)
     * @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 getAvailableDedicatedNumbersAsync(String country, Integer prefix, Integer tollfree, final ApiCallback 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 = getAvailableDedicatedNumbersValidateBeforeCall(country, prefix, tollfree, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getAvailableSenderSettingOptions
     * @param country The 2-letter ISO country ID. If not specified, it returns all the available sender settings. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getAvailableSenderSettingOptionsCall(String country, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/sources";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (country != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("country", country));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getAvailableSenderSettingOptionsValidateBeforeCall(String country, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getAvailableSenderSettingOptionsCall(country, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get available sender settings
     * Get all available sender setting options which can be used in the \"from\" parameter of the POST messages method.
     * @param country The 2-letter ISO country ID. If not specified, it returns all the available sender settings. (optional)
     * @return GetAvailableSenderSettingOptionsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetAvailableSenderSettingOptionsResponse getAvailableSenderSettingOptions(String country) throws ApiException {
        ApiResponse resp = getAvailableSenderSettingOptionsWithHttpInfo(country);
        return resp.getData();
    }

    /**
     * Get available sender settings
     * Get all available sender setting options which can be used in the \"from\" parameter of the POST messages method.
     * @param country The 2-letter ISO country ID. If not specified, it returns all the available sender settings. (optional)
     * @return ApiResponse<GetAvailableSenderSettingOptionsResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getAvailableSenderSettingOptionsWithHttpInfo(String country) throws ApiException {
        com.squareup.okhttp.Call call = getAvailableSenderSettingOptionsValidateBeforeCall(country, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get available sender settings (asynchronously)
     * Get all available sender setting options which can be used in the \"from\" parameter of the POST messages method.
     * @param country The 2-letter ISO country ID. If not specified, it returns all the available sender settings. (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 getAvailableSenderSettingOptionsAsync(String country, final ApiCallback 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 = getAvailableSenderSettingOptionsValidateBeforeCall(country, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getBalanceNotificationOptions
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getBalanceNotificationOptionsCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/user/notification/balance/bundles";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getBalanceNotificationOptionsValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getBalanceNotificationOptionsCall(progressListener, progressRequestListener);
        return call;

    }

    /**
     * Returns the list of available balance options which can be used as a bound to determine when to send email to user with low balance notification. See https://my.textmagic.com/online/account/notifications/balance
     * 
     * @return GetBalanceNotificationOptionsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetBalanceNotificationOptionsResponse getBalanceNotificationOptions() throws ApiException {
        ApiResponse resp = getBalanceNotificationOptionsWithHttpInfo();
        return resp.getData();
    }

    /**
     * Returns the list of available balance options which can be used as a bound to determine when to send email to user with low balance notification. See https://my.textmagic.com/online/account/notifications/balance
     * 
     * @return ApiResponse<GetBalanceNotificationOptionsResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getBalanceNotificationOptionsWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = getBalanceNotificationOptionsValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns the list of available balance options which can be used as a bound to determine when to send email to user with low balance notification. See https://my.textmagic.com/online/account/notifications/balance (asynchronously)
     * 
     * @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 getBalanceNotificationOptionsAsync(final ApiCallback 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 = getBalanceNotificationOptionsValidateBeforeCall(progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getBalanceNotificationSettings
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getBalanceNotificationSettingsCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/user/notification/balance";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getBalanceNotificationSettingsValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getBalanceNotificationSettingsCall(progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get balance notification settings
     * 
     * @return GetBalanceNotificationSettingsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetBalanceNotificationSettingsResponse getBalanceNotificationSettings() throws ApiException {
        ApiResponse resp = getBalanceNotificationSettingsWithHttpInfo();
        return resp.getData();
    }

    /**
     * Get balance notification settings
     * 
     * @return ApiResponse<GetBalanceNotificationSettingsResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getBalanceNotificationSettingsWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = getBalanceNotificationSettingsValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get balance notification settings (asynchronously)
     * 
     * @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 getBalanceNotificationSettingsAsync(final ApiCallback 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 = getBalanceNotificationSettingsValidateBeforeCall(progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getBlockedContacts
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find blocked contacts by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getBlockedContactsCall(Integer page, Integer limit, String query, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/block/list";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));
        if (orderBy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("orderBy", orderBy));
        if (direction != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("direction", direction));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getBlockedContactsValidateBeforeCall(Integer page, Integer limit, String query, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getBlockedContactsCall(page, limit, query, orderBy, direction, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get blocked contacts
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find blocked contacts by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return GetBlockedContactsPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetBlockedContactsPaginatedResponse getBlockedContacts(Integer page, Integer limit, String query, String orderBy, String direction) throws ApiException {
        ApiResponse resp = getBlockedContactsWithHttpInfo(page, limit, query, orderBy, direction);
        return resp.getData();
    }

    /**
     * Get blocked contacts
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find blocked contacts by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return ApiResponse<GetBlockedContactsPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getBlockedContactsWithHttpInfo(Integer page, Integer limit, String query, String orderBy, String direction) throws ApiException {
        com.squareup.okhttp.Call call = getBlockedContactsValidateBeforeCall(page, limit, query, orderBy, direction, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get blocked contacts (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find blocked contacts by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @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 getBlockedContactsAsync(Integer page, Integer limit, String query, String orderBy, String direction, final ApiCallback 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 = getBlockedContactsValidateBeforeCall(page, limit, query, orderBy, direction, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getBulkSession
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getBulkSessionCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/bulks/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getBulkSessionValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getBulkSession(Async)");
        }
        

        com.squareup.okhttp.Call call = getBulkSessionCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get bulk session status
     * 
     * @param id  (required)
     * @return BulkSession
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public BulkSession getBulkSession(Integer id) throws ApiException {
        ApiResponse resp = getBulkSessionWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get bulk session status
     * 
     * @param id  (required)
     * @return ApiResponse<BulkSession>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getBulkSessionWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getBulkSessionValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get bulk session status (asynchronously)
     * 
     * @param 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 getBulkSessionAsync(Integer id, final ApiCallback 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 = getBulkSessionValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getCallbackSettings
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getCallbackSettingsCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/callback/settings";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getCallbackSettingsValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getCallbackSettingsCall(progressListener, progressRequestListener);
        return call;

    }

    /**
     * Fetch callback URL settings
     * 
     * @return GetCallbackSettingsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetCallbackSettingsResponse getCallbackSettings() throws ApiException {
        ApiResponse resp = getCallbackSettingsWithHttpInfo();
        return resp.getData();
    }

    /**
     * Fetch callback URL settings
     * 
     * @return ApiResponse<GetCallbackSettingsResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getCallbackSettingsWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = getCallbackSettingsValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Fetch callback URL settings (asynchronously)
     * 
     * @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 getCallbackSettingsAsync(final ApiCallback 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 = getCallbackSettingsValidateBeforeCall(progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getChat
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getChatCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/chats/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getChatValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getChat(Async)");
        }
        

        com.squareup.okhttp.Call call = getChatCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get a single chat
     * 
     * @param id  (required)
     * @return Chat
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Chat getChat(Integer id) throws ApiException {
        ApiResponse resp = getChatWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get a single chat
     * 
     * @param id  (required)
     * @return ApiResponse<Chat>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getChatWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getChatValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a single chat (asynchronously)
     * 
     * @param 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 getChatAsync(Integer id, final ApiCallback 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 = getChatValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getChatByPhone
     * @param phone  (required)
     * @param upsert Create a new chat if not found. (optional, default to 0)
     * @param reopen Reopen chat if found or do not change status. (optional, default to 0)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getChatByPhoneCall(String phone, Integer upsert, Integer reopen, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/chats/{phone}/by/phone"
            .replaceAll("\\{" + "phone" + "\\}", apiClient.escapeString(phone.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (upsert != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("upsert", upsert));
        if (reopen != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("reopen", reopen));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getChatByPhoneValidateBeforeCall(String phone, Integer upsert, Integer reopen, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'phone' is set
        if (phone == null) {
            throw new ApiException("Missing the required parameter 'phone' when calling getChatByPhone(Async)");
        }
        

        com.squareup.okhttp.Call call = getChatByPhoneCall(phone, upsert, reopen, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Find chats by phone
     * 
     * @param phone  (required)
     * @param upsert Create a new chat if not found. (optional, default to 0)
     * @param reopen Reopen chat if found or do not change status. (optional, default to 0)
     * @return Chat
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Chat getChatByPhone(String phone, Integer upsert, Integer reopen) throws ApiException {
        ApiResponse resp = getChatByPhoneWithHttpInfo(phone, upsert, reopen);
        return resp.getData();
    }

    /**
     * Find chats by phone
     * 
     * @param phone  (required)
     * @param upsert Create a new chat if not found. (optional, default to 0)
     * @param reopen Reopen chat if found or do not change status. (optional, default to 0)
     * @return ApiResponse<Chat>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getChatByPhoneWithHttpInfo(String phone, Integer upsert, Integer reopen) throws ApiException {
        com.squareup.okhttp.Call call = getChatByPhoneValidateBeforeCall(phone, upsert, reopen, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Find chats by phone (asynchronously)
     * 
     * @param phone  (required)
     * @param upsert Create a new chat if not found. (optional, default to 0)
     * @param reopen Reopen chat if found or do not change status. (optional, default to 0)
     * @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 getChatByPhoneAsync(String phone, Integer upsert, Integer reopen, final ApiCallback 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 = getChatByPhoneValidateBeforeCall(phone, upsert, reopen, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getChatMessages
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find messages by specified search query. (optional)
     * @param start Return messages since specified timestamp only. (optional)
     * @param end Return messages up to specified timestamp only. (optional)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param voice Fetch results with voice calls. (optional, default to 0)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getChatMessagesCall(Integer id, Integer page, Integer limit, String query, Integer start, Integer end, String direction, Integer voice, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/chats/{id}/message"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));
        if (start != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("start", start));
        if (end != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("end", end));
        if (direction != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("direction", direction));
        if (voice != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("voice", voice));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getChatMessagesValidateBeforeCall(Integer id, Integer page, Integer limit, String query, Integer start, Integer end, String direction, Integer voice, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getChatMessages(Async)");
        }
        

        com.squareup.okhttp.Call call = getChatMessagesCall(id, page, limit, query, start, end, direction, voice, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get chat messages
     * 
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find messages by specified search query. (optional)
     * @param start Return messages since specified timestamp only. (optional)
     * @param end Return messages up to specified timestamp only. (optional)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param voice Fetch results with voice calls. (optional, default to 0)
     * @return GetChatMessagesPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetChatMessagesPaginatedResponse getChatMessages(Integer id, Integer page, Integer limit, String query, Integer start, Integer end, String direction, Integer voice) throws ApiException {
        ApiResponse resp = getChatMessagesWithHttpInfo(id, page, limit, query, start, end, direction, voice);
        return resp.getData();
    }

    /**
     * Get chat messages
     * 
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find messages by specified search query. (optional)
     * @param start Return messages since specified timestamp only. (optional)
     * @param end Return messages up to specified timestamp only. (optional)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param voice Fetch results with voice calls. (optional, default to 0)
     * @return ApiResponse<GetChatMessagesPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getChatMessagesWithHttpInfo(Integer id, Integer page, Integer limit, String query, Integer start, Integer end, String direction, Integer voice) throws ApiException {
        com.squareup.okhttp.Call call = getChatMessagesValidateBeforeCall(id, page, limit, query, start, end, direction, voice, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get chat messages (asynchronously)
     * 
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find messages by specified search query. (optional)
     * @param start Return messages since specified timestamp only. (optional)
     * @param end Return messages up to specified timestamp only. (optional)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param voice Fetch results with voice calls. (optional, default to 0)
     * @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 getChatMessagesAsync(Integer id, Integer page, Integer limit, String query, Integer start, Integer end, String direction, Integer voice, final ApiCallback 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 = getChatMessagesValidateBeforeCall(id, page, limit, query, start, end, direction, voice, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getContact
     * @param id Contact ID. (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getContactCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getContactValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getContact(Async)");
        }
        

        com.squareup.okhttp.Call call = getContactCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get the details of a specific contact
     * 
     * @param id Contact ID. (required)
     * @return Contact
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Contact getContact(Integer id) throws ApiException {
        ApiResponse resp = getContactWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get the details of a specific contact
     * 
     * @param id Contact ID. (required)
     * @return ApiResponse<Contact>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getContactWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getContactValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the details of a specific contact (asynchronously)
     * 
     * @param id Contact 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 getContactAsync(Integer id, final ApiCallback 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 = getContactValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getContactByPhone
     * @param phone  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getContactByPhoneCall(String phone, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/phone/{phone}"
            .replaceAll("\\{" + "phone" + "\\}", apiClient.escapeString(phone.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getContactByPhoneValidateBeforeCall(String phone, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'phone' is set
        if (phone == null) {
            throw new ApiException("Missing the required parameter 'phone' when calling getContactByPhone(Async)");
        }
        

        com.squareup.okhttp.Call call = getContactByPhoneCall(phone, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get the details of a specific contact by phone number
     * 
     * @param phone  (required)
     * @return Contact
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Contact getContactByPhone(String phone) throws ApiException {
        ApiResponse resp = getContactByPhoneWithHttpInfo(phone);
        return resp.getData();
    }

    /**
     * Get the details of a specific contact by phone number
     * 
     * @param phone  (required)
     * @return ApiResponse<Contact>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getContactByPhoneWithHttpInfo(String phone) throws ApiException {
        com.squareup.okhttp.Call call = getContactByPhoneValidateBeforeCall(phone, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the details of a specific contact by phone number (asynchronously)
     * 
     * @param phone  (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 getContactByPhoneAsync(String phone, final ApiCallback 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 = getContactByPhoneValidateBeforeCall(phone, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getContactIfBlocked
     * @param phone Phone number to check. (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getContactIfBlockedCall(String phone, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/block/phone";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (phone != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("phone", phone));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getContactIfBlockedValidateBeforeCall(String phone, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'phone' is set
        if (phone == null) {
            throw new ApiException("Missing the required parameter 'phone' when calling getContactIfBlocked(Async)");
        }
        

        com.squareup.okhttp.Call call = getContactIfBlockedCall(phone, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Check if a phone number is blocked
     * 
     * @param phone Phone number to check. (required)
     * @return Contact
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Contact getContactIfBlocked(String phone) throws ApiException {
        ApiResponse resp = getContactIfBlockedWithHttpInfo(phone);
        return resp.getData();
    }

    /**
     * Check if a phone number is blocked
     * 
     * @param phone Phone number to check. (required)
     * @return ApiResponse<Contact>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getContactIfBlockedWithHttpInfo(String phone) throws ApiException {
        com.squareup.okhttp.Call call = getContactIfBlockedValidateBeforeCall(phone, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Check if a phone number is blocked (asynchronously)
     * 
     * @param phone Phone number to check. (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 getContactIfBlockedAsync(String phone, final ApiCallback 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 = getContactIfBlockedValidateBeforeCall(phone, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getContactImportSessionProgress
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getContactImportSessionProgressCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/import/progress/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getContactImportSessionProgressValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getContactImportSessionProgress(Async)");
        }
        

        com.squareup.okhttp.Call call = getContactImportSessionProgressCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Check import progress
     * Get contact import session progress.
     * @param id  (required)
     * @return GetContactImportSessionProgressResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetContactImportSessionProgressResponse getContactImportSessionProgress(Integer id) throws ApiException {
        ApiResponse resp = getContactImportSessionProgressWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Check import progress
     * Get contact import session progress.
     * @param id  (required)
     * @return ApiResponse<GetContactImportSessionProgressResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getContactImportSessionProgressWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getContactImportSessionProgressValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Check import progress (asynchronously)
     * Get contact import session progress.
     * @param 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 getContactImportSessionProgressAsync(Integer id, final ApiCallback 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 = getContactImportSessionProgressValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getContactNote
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getContactNoteCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/notes/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getContactNoteValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getContactNote(Async)");
        }
        

        com.squareup.okhttp.Call call = getContactNoteCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get a contact note
     * 
     * @param id  (required)
     * @return ContactNote
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ContactNote getContactNote(Integer id) throws ApiException {
        ApiResponse resp = getContactNoteWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get a contact note
     * 
     * @param id  (required)
     * @return ApiResponse<ContactNote>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getContactNoteWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getContactNoteValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a contact note (asynchronously)
     * 
     * @param 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 getContactNoteAsync(Integer id, final ApiCallback 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 = getContactNoteValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getContactNotes
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getContactNotesCall(Integer id, Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/{id}/notes"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getContactNotesValidateBeforeCall(Integer id, Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getContactNotes(Async)");
        }
        

        com.squareup.okhttp.Call call = getContactNotesCall(id, page, limit, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Fetch notes assigned to a given contact
     * 
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return GetContactNotesPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetContactNotesPaginatedResponse getContactNotes(Integer id, Integer page, Integer limit) throws ApiException {
        ApiResponse resp = getContactNotesWithHttpInfo(id, page, limit);
        return resp.getData();
    }

    /**
     * Fetch notes assigned to a given contact
     * 
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return ApiResponse<GetContactNotesPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getContactNotesWithHttpInfo(Integer id, Integer page, Integer limit) throws ApiException {
        com.squareup.okhttp.Call call = getContactNotesValidateBeforeCall(id, page, limit, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Fetch notes assigned to a given contact (asynchronously)
     * 
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @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 getContactNotesAsync(Integer id, Integer page, Integer limit, final ApiCallback 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 = getContactNotesValidateBeforeCall(id, page, limit, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getContacts
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param shared Should shared contacts be included? (optional, default to 0)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getContactsCall(Integer page, Integer limit, Integer shared, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (shared != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("shared", shared));
        if (orderBy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("orderBy", orderBy));
        if (direction != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("direction", direction));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getContactsValidateBeforeCall(Integer page, Integer limit, Integer shared, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getContactsCall(page, limit, shared, orderBy, direction, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all contacts
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param shared Should shared contacts be included? (optional, default to 0)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return GetContactsPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetContactsPaginatedResponse getContacts(Integer page, Integer limit, Integer shared, String orderBy, String direction) throws ApiException {
        ApiResponse resp = getContactsWithHttpInfo(page, limit, shared, orderBy, direction);
        return resp.getData();
    }

    /**
     * Get all contacts
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param shared Should shared contacts be included? (optional, default to 0)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return ApiResponse<GetContactsPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getContactsWithHttpInfo(Integer page, Integer limit, Integer shared, String orderBy, String direction) throws ApiException {
        com.squareup.okhttp.Call call = getContactsValidateBeforeCall(page, limit, shared, orderBy, direction, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all contacts (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param shared Should shared contacts be included? (optional, default to 0)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @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 getContactsAsync(Integer page, Integer limit, Integer shared, String orderBy, String direction, final ApiCallback 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 = getContactsValidateBeforeCall(page, limit, shared, orderBy, direction, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getContactsAutocomplete
     * @param query Find recipients by specified search query. (required)
     * @param limit The number of results per page. (optional, default to 10)
     * @param lists Should lists be returned or not? (optional, default to 0)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getContactsAutocompleteCall(String query, Integer limit, Integer lists, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/autocomplete";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));
        if (lists != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("lists", lists));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getContactsAutocompleteValidateBeforeCall(String query, Integer limit, Integer lists, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'query' is set
        if (query == null) {
            throw new ApiException("Missing the required parameter 'query' when calling getContactsAutocomplete(Async)");
        }
        

        com.squareup.okhttp.Call call = getContactsAutocompleteCall(query, limit, lists, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get contacts autocomplete suggestions
     * Get contacts autocomplete suggestions by given search terms.
     * @param query Find recipients by specified search query. (required)
     * @param limit The number of results per page. (optional, default to 10)
     * @param lists Should lists be returned or not? (optional, default to 0)
     * @return GetContactsAutocompleteResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetContactsAutocompleteResponse getContactsAutocomplete(String query, Integer limit, Integer lists) throws ApiException {
        ApiResponse resp = getContactsAutocompleteWithHttpInfo(query, limit, lists);
        return resp.getData();
    }

    /**
     * Get contacts autocomplete suggestions
     * Get contacts autocomplete suggestions by given search terms.
     * @param query Find recipients by specified search query. (required)
     * @param limit The number of results per page. (optional, default to 10)
     * @param lists Should lists be returned or not? (optional, default to 0)
     * @return ApiResponse<GetContactsAutocompleteResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getContactsAutocompleteWithHttpInfo(String query, Integer limit, Integer lists) throws ApiException {
        com.squareup.okhttp.Call call = getContactsAutocompleteValidateBeforeCall(query, limit, lists, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get contacts autocomplete suggestions (asynchronously)
     * Get contacts autocomplete suggestions by given search terms.
     * @param query Find recipients by specified search query. (required)
     * @param limit The number of results per page. (optional, default to 10)
     * @param lists Should lists be returned or not? (optional, default to 0)
     * @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 getContactsAutocompleteAsync(String query, Integer limit, Integer lists, final ApiCallback 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 = getContactsAutocompleteValidateBeforeCall(query, limit, lists, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getContactsByListId
     * @param id Given group ID. (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getContactsByListIdCall(Integer id, Integer page, Integer limit, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/lists/{id}/contacts"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (orderBy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("orderBy", orderBy));
        if (direction != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("direction", direction));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getContactsByListIdValidateBeforeCall(Integer id, Integer page, Integer limit, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getContactsByListId(Async)");
        }
        

        com.squareup.okhttp.Call call = getContactsByListIdCall(id, page, limit, orderBy, direction, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all contacts in a list
     * A useful synonym for the \"contacts/search\" command with the provided \"listId\" parameter.
     * @param id Given group ID. (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return GetContactsByListIdPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetContactsByListIdPaginatedResponse getContactsByListId(Integer id, Integer page, Integer limit, String orderBy, String direction) throws ApiException {
        ApiResponse resp = getContactsByListIdWithHttpInfo(id, page, limit, orderBy, direction);
        return resp.getData();
    }

    /**
     * Get all contacts in a list
     * A useful synonym for the \"contacts/search\" command with the provided \"listId\" parameter.
     * @param id Given group ID. (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return ApiResponse<GetContactsByListIdPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getContactsByListIdWithHttpInfo(Integer id, Integer page, Integer limit, String orderBy, String direction) throws ApiException {
        com.squareup.okhttp.Call call = getContactsByListIdValidateBeforeCall(id, page, limit, orderBy, direction, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all contacts in a list (asynchronously)
     * A useful synonym for the \"contacts/search\" command with the provided \"listId\" parameter.
     * @param id Given group ID. (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @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 getContactsByListIdAsync(Integer id, Integer page, Integer limit, String orderBy, String direction, final ApiCallback 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 = getContactsByListIdValidateBeforeCall(id, page, limit, orderBy, direction, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getCountries
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getCountriesCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/countries";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getCountriesValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getCountriesCall(progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get countries
     * 
     * @return GetCountriesResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetCountriesResponse getCountries() throws ApiException {
        ApiResponse resp = getCountriesWithHttpInfo();
        return resp.getData();
    }

    /**
     * Get countries
     * 
     * @return ApiResponse<GetCountriesResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getCountriesWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = getCountriesValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get countries (asynchronously)
     * 
     * @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 getCountriesAsync(final ApiCallback 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 = getCountriesValidateBeforeCall(progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getCurrentUser
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getCurrentUserCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/user";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getCurrentUserValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getCurrentUserCall(progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get current account information
     * 
     * @return User
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public User getCurrentUser() throws ApiException {
        ApiResponse resp = getCurrentUserWithHttpInfo();
        return resp.getData();
    }

    /**
     * Get current account information
     * 
     * @return ApiResponse<User>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getCurrentUserWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = getCurrentUserValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get current account information (asynchronously)
     * 
     * @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 getCurrentUserAsync(final ApiCallback 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 = getCurrentUserValidateBeforeCall(progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getCustomField
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getCustomFieldCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/customfields/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getCustomFieldValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getCustomField(Async)");
        }
        

        com.squareup.okhttp.Call call = getCustomFieldCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get the details of a specific custom field
     * 
     * @param id  (required)
     * @return UserCustomField
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public UserCustomField getCustomField(Integer id) throws ApiException {
        ApiResponse resp = getCustomFieldWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get the details of a specific custom field
     * 
     * @param id  (required)
     * @return ApiResponse<UserCustomField>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getCustomFieldWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getCustomFieldValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the details of a specific custom field (asynchronously)
     * 
     * @param 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 getCustomFieldAsync(Integer id, final ApiCallback 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 = getCustomFieldValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getCustomFields
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getCustomFieldsCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/customfields";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getCustomFieldsValidateBeforeCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getCustomFieldsCall(page, limit, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all custom fields
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return GetCustomFieldsPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetCustomFieldsPaginatedResponse getCustomFields(Integer page, Integer limit) throws ApiException {
        ApiResponse resp = getCustomFieldsWithHttpInfo(page, limit);
        return resp.getData();
    }

    /**
     * Get all custom fields
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return ApiResponse<GetCustomFieldsPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getCustomFieldsWithHttpInfo(Integer page, Integer limit) throws ApiException {
        com.squareup.okhttp.Call call = getCustomFieldsValidateBeforeCall(page, limit, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all custom fields (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @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 getCustomFieldsAsync(Integer page, Integer limit, final ApiCallback 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 = getCustomFieldsValidateBeforeCall(page, limit, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getDedicatedNumber
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getDedicatedNumberCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/numbers/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getDedicatedNumberValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getDedicatedNumber(Async)");
        }
        

        com.squareup.okhttp.Call call = getDedicatedNumberCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get the details of a specific dedicated number
     * 
     * @param id  (required)
     * @return UsersInbound
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public UsersInbound getDedicatedNumber(Integer id) throws ApiException {
        ApiResponse resp = getDedicatedNumberWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get the details of a specific dedicated number
     * 
     * @param id  (required)
     * @return ApiResponse<UsersInbound>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getDedicatedNumberWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getDedicatedNumberValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the details of a specific dedicated number (asynchronously)
     * 
     * @param 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 getDedicatedNumberAsync(Integer id, final ApiCallback 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 = getDedicatedNumberValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getFavorites
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find contacts or lists by specified search query. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getFavoritesCall(Integer page, Integer limit, String query, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/favorite";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getFavoritesValidateBeforeCall(Integer page, Integer limit, String query, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getFavoritesCall(page, limit, query, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get favorite contacts and lists
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find contacts or lists by specified search query. (optional)
     * @return GetFavoritesPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetFavoritesPaginatedResponse getFavorites(Integer page, Integer limit, String query) throws ApiException {
        ApiResponse resp = getFavoritesWithHttpInfo(page, limit, query);
        return resp.getData();
    }

    /**
     * Get favorite contacts and lists
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find contacts or lists by specified search query. (optional)
     * @return ApiResponse<GetFavoritesPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getFavoritesWithHttpInfo(Integer page, Integer limit, String query) throws ApiException {
        com.squareup.okhttp.Call call = getFavoritesValidateBeforeCall(page, limit, query, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get favorite contacts and lists (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find contacts or lists by specified search query. (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 getFavoritesAsync(Integer page, Integer limit, String query, final ApiCallback 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 = getFavoritesValidateBeforeCall(page, limit, query, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getInboundMessage
     * @param id The unique numeric ID for the inbound message. (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getInboundMessageCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/replies/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getInboundMessageValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getInboundMessage(Async)");
        }
        

        com.squareup.okhttp.Call call = getInboundMessageCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get a single inbound message
     * 
     * @param id The unique numeric ID for the inbound message. (required)
     * @return MessageIn
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public MessageIn getInboundMessage(Integer id) throws ApiException {
        ApiResponse resp = getInboundMessageWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get a single inbound message
     * 
     * @param id The unique numeric ID for the inbound message. (required)
     * @return ApiResponse<MessageIn>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getInboundMessageWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getInboundMessageValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a single inbound message (asynchronously)
     * 
     * @param id The unique numeric ID for the inbound message. (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 getInboundMessageAsync(Integer id, final ApiCallback 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 = getInboundMessageValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getInboundMessagesNotificationSettings
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getInboundMessagesNotificationSettingsCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/user/notification/inbound";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getInboundMessagesNotificationSettingsValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getInboundMessagesNotificationSettingsCall(progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get inbound messages notification settings
     * 
     * @return GetInboundMessagesNotificationSettingsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetInboundMessagesNotificationSettingsResponse getInboundMessagesNotificationSettings() throws ApiException {
        ApiResponse resp = getInboundMessagesNotificationSettingsWithHttpInfo();
        return resp.getData();
    }

    /**
     * Get inbound messages notification settings
     * 
     * @return ApiResponse<GetInboundMessagesNotificationSettingsResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getInboundMessagesNotificationSettingsWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = getInboundMessagesNotificationSettingsValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get inbound messages notification settings (asynchronously)
     * 
     * @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 getInboundMessagesNotificationSettingsAsync(final ApiCallback 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 = getInboundMessagesNotificationSettingsValidateBeforeCall(progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getInvoices
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getInvoicesCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/invoices";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getInvoicesValidateBeforeCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getInvoicesCall(page, limit, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all invoices
     * With the TextMagic API, you can check the invoices and transactions for your account.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return GetInvoicesPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetInvoicesPaginatedResponse getInvoices(Integer page, Integer limit) throws ApiException {
        ApiResponse resp = getInvoicesWithHttpInfo(page, limit);
        return resp.getData();
    }

    /**
     * Get all invoices
     * With the TextMagic API, you can check the invoices and transactions for your account.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return ApiResponse<GetInvoicesPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getInvoicesWithHttpInfo(Integer page, Integer limit) throws ApiException {
        com.squareup.okhttp.Call call = getInvoicesValidateBeforeCall(page, limit, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all invoices (asynchronously)
     * With the TextMagic API, you can check the invoices and transactions for your account.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @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 getInvoicesAsync(Integer page, Integer limit, final ApiCallback 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 = getInvoicesValidateBeforeCall(page, limit, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getList
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getListCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/lists/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getListValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getList(Async)");
        }
        

        com.squareup.okhttp.Call call = getListCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get the details of a specific list
     * 
     * @param id  (required)
     * @return List
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public List getList(Integer id) throws ApiException {
        ApiResponse resp = getListWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get the details of a specific list
     * 
     * @param id  (required)
     * @return ApiResponse<List>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getListWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getListValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the details of a specific list (asynchronously)
     * 
     * @param 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 getListAsync(Integer id, final ApiCallback 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 = getListValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getListContactsIds
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getListContactsIdsCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/lists/{id}/contacts/ids"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getListContactsIdsValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getListContactsIds(Async)");
        }
        

        com.squareup.okhttp.Call call = getListContactsIdsCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all contact IDs in a list
     * 
     * @param id  (required)
     * @return GetListContactsIdsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetListContactsIdsResponse getListContactsIds(Integer id) throws ApiException {
        ApiResponse resp = getListContactsIdsWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get all contact IDs in a list
     * 
     * @param id  (required)
     * @return ApiResponse<GetListContactsIdsResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getListContactsIdsWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getListContactsIdsValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all contact IDs in a list (asynchronously)
     * 
     * @param 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 getListContactsIdsAsync(Integer id, final ApiCallback 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 = getListContactsIdsValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getLists
     * @param page The current fetched page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param favoriteOnly Return only favorited lists. (optional, default to 0)
     * @param onlyMine Return only current user lists. (optional, default to 0)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getListsCall(Integer page, Integer limit, String orderBy, String direction, Integer favoriteOnly, Integer onlyMine, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/lists";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (orderBy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("orderBy", orderBy));
        if (direction != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("direction", direction));
        if (favoriteOnly != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("favoriteOnly", favoriteOnly));
        if (onlyMine != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("onlyMine", onlyMine));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getListsValidateBeforeCall(Integer page, Integer limit, String orderBy, String direction, Integer favoriteOnly, Integer onlyMine, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getListsCall(page, limit, orderBy, direction, favoriteOnly, onlyMine, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all lists
     * 
     * @param page The current fetched page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param favoriteOnly Return only favorited lists. (optional, default to 0)
     * @param onlyMine Return only current user lists. (optional, default to 0)
     * @return GetListsPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetListsPaginatedResponse getLists(Integer page, Integer limit, String orderBy, String direction, Integer favoriteOnly, Integer onlyMine) throws ApiException {
        ApiResponse resp = getListsWithHttpInfo(page, limit, orderBy, direction, favoriteOnly, onlyMine);
        return resp.getData();
    }

    /**
     * Get all lists
     * 
     * @param page The current fetched page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param favoriteOnly Return only favorited lists. (optional, default to 0)
     * @param onlyMine Return only current user lists. (optional, default to 0)
     * @return ApiResponse<GetListsPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getListsWithHttpInfo(Integer page, Integer limit, String orderBy, String direction, Integer favoriteOnly, Integer onlyMine) throws ApiException {
        com.squareup.okhttp.Call call = getListsValidateBeforeCall(page, limit, orderBy, direction, favoriteOnly, onlyMine, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all lists (asynchronously)
     * 
     * @param page The current fetched page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param favoriteOnly Return only favorited lists. (optional, default to 0)
     * @param onlyMine Return only current user lists. (optional, default to 0)
     * @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 getListsAsync(Integer page, Integer limit, String orderBy, String direction, Integer favoriteOnly, Integer onlyMine, final ApiCallback 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 = getListsValidateBeforeCall(page, limit, orderBy, direction, favoriteOnly, onlyMine, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getListsOfContact
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getListsOfContactCall(Integer id, Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/{id}/lists"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getListsOfContactValidateBeforeCall(Integer id, Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getListsOfContact(Async)");
        }
        

        com.squareup.okhttp.Call call = getListsOfContactCall(id, page, limit, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get a contact's lists
     * Get all the lists in which a contact is included.
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return GetListsOfContactPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetListsOfContactPaginatedResponse getListsOfContact(Integer id, Integer page, Integer limit) throws ApiException {
        ApiResponse resp = getListsOfContactWithHttpInfo(id, page, limit);
        return resp.getData();
    }

    /**
     * Get a contact's lists
     * Get all the lists in which a contact is included.
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return ApiResponse<GetListsOfContactPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getListsOfContactWithHttpInfo(Integer id, Integer page, Integer limit) throws ApiException {
        com.squareup.okhttp.Call call = getListsOfContactValidateBeforeCall(id, page, limit, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a contact's lists (asynchronously)
     * Get all the lists in which a contact is included.
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @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 getListsOfContactAsync(Integer id, Integer page, Integer limit, final ApiCallback 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 = getListsOfContactValidateBeforeCall(id, page, limit, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getMessagePreview
     * @param text Message text. Required if **template_id** is not set. (optional)
     * @param templateId Template used instead of message text. Required if **text** is not set. (optional)
     * @param sendingTime DEPRECATED, consider using sendingDateTime and sendingTimezone parameters instead: Optional (required with rrule set). Message sending time is in unix timestamp format. Default is now. (optional)
     * @param sendingDateTime Sending time is in Y-m-d H:i:s format (e.g. 2016-05-27 13:02:33). This time is relative to the sendingTimezone. (optional)
     * @param sendingTimezone The ID or ISO-name of the timezone used for sending when the sendingDateTime parameter is set, e.g. if you specify sendingDateTime = \\\"2016-05-27 13:02:33\\\" and sendingTimezone = \\\"America/Buenos_Aires\\\", your message will be sent on May 27, 2016 13:02:33 Buenos Aires time, or 16:02:33 UTC. Default is the account timezone. (optional)
     * @param contacts Comma-separated array of contact resources id message will be sent to. (optional)
     * @param lists Comma-separated array of list resources id message will be sent to. (optional)
     * @param phones Comma-separated array of E.164 phone numbers message will be sent to. (optional)
     * @param cutExtra Should sending method cut extra characters which not fit supplied partsCount or return 400 Bad request response instead. (optional, default to 0)
     * @param partsCount Maximum message parts count (TextMagic allows sending of 1 to 6 message parts). (optional, default to 6)
     * @param referenceId Custom message reference id which can be used in your application infrastructure. (optional)
     * @param from One of the allowed Sender ID (phone number or alphanumeric sender ID). If the specified Sender ID is not allowed for some destinations, a fallback default Sender ID will be used to ensure delivery. See [Get timezones](https://docs.textmagic.com/#tag/Sender-IDs). (optional)
     * @param rule An iCal RRULE parameter to create recurrent scheduled messages. When used, sendingTime is mandatory as the start point of sending. See https://www.textmagic.com/free-tools/rrule-generator for format details. (optional)
     * @param createChat Should the sending method try to create new Chat(if not exist) with specified recipients? (optional, default to 0)
     * @param tts Send Text-to-Speech message. (optional, default to 0)
     * @param local Treat phone numbers passed in the \\'phones\\' field as local. (optional, default to 0)
     * @param localCountry The 2-letter ISO country code for local phone numbers, used when \\'local\\' is set to true. Default is the account country. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getMessagePreviewCall(String text, Integer templateId, Integer sendingTime, String sendingDateTime, String sendingTimezone, String contacts, String lists, String phones, Integer cutExtra, Integer partsCount, Integer referenceId, String from, String rule, Integer createChat, Integer tts, Integer local, String localCountry, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/messages/preview";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (text != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("text", text));
        if (templateId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("templateId", templateId));
        if (sendingTime != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("sendingTime", sendingTime));
        if (sendingDateTime != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("sendingDateTime", sendingDateTime));
        if (sendingTimezone != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("sendingTimezone", sendingTimezone));
        if (contacts != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("contacts", contacts));
        if (lists != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("lists", lists));
        if (phones != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("phones", phones));
        if (cutExtra != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("cutExtra", cutExtra));
        if (partsCount != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("partsCount", partsCount));
        if (referenceId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("referenceId", referenceId));
        if (from != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("from", from));
        if (rule != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("rule", rule));
        if (createChat != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("createChat", createChat));
        if (tts != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("tts", tts));
        if (local != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("local", local));
        if (localCountry != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("localCountry", localCountry));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getMessagePreviewValidateBeforeCall(String text, Integer templateId, Integer sendingTime, String sendingDateTime, String sendingTimezone, String contacts, String lists, String phones, Integer cutExtra, Integer partsCount, Integer referenceId, String from, String rule, Integer createChat, Integer tts, Integer local, String localCountry, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getMessagePreviewCall(text, templateId, sendingTime, sendingDateTime, sendingTimezone, contacts, lists, phones, cutExtra, partsCount, referenceId, from, rule, createChat, tts, local, localCountry, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Preview message
     * Get a messages preview (with tags merged) of up to 100 messages per session.
     * @param text Message text. Required if **template_id** is not set. (optional)
     * @param templateId Template used instead of message text. Required if **text** is not set. (optional)
     * @param sendingTime DEPRECATED, consider using sendingDateTime and sendingTimezone parameters instead: Optional (required with rrule set). Message sending time is in unix timestamp format. Default is now. (optional)
     * @param sendingDateTime Sending time is in Y-m-d H:i:s format (e.g. 2016-05-27 13:02:33). This time is relative to the sendingTimezone. (optional)
     * @param sendingTimezone The ID or ISO-name of the timezone used for sending when the sendingDateTime parameter is set, e.g. if you specify sendingDateTime = \\\"2016-05-27 13:02:33\\\" and sendingTimezone = \\\"America/Buenos_Aires\\\", your message will be sent on May 27, 2016 13:02:33 Buenos Aires time, or 16:02:33 UTC. Default is the account timezone. (optional)
     * @param contacts Comma-separated array of contact resources id message will be sent to. (optional)
     * @param lists Comma-separated array of list resources id message will be sent to. (optional)
     * @param phones Comma-separated array of E.164 phone numbers message will be sent to. (optional)
     * @param cutExtra Should sending method cut extra characters which not fit supplied partsCount or return 400 Bad request response instead. (optional, default to 0)
     * @param partsCount Maximum message parts count (TextMagic allows sending of 1 to 6 message parts). (optional, default to 6)
     * @param referenceId Custom message reference id which can be used in your application infrastructure. (optional)
     * @param from One of the allowed Sender ID (phone number or alphanumeric sender ID). If the specified Sender ID is not allowed for some destinations, a fallback default Sender ID will be used to ensure delivery. See [Get timezones](https://docs.textmagic.com/#tag/Sender-IDs). (optional)
     * @param rule An iCal RRULE parameter to create recurrent scheduled messages. When used, sendingTime is mandatory as the start point of sending. See https://www.textmagic.com/free-tools/rrule-generator for format details. (optional)
     * @param createChat Should the sending method try to create new Chat(if not exist) with specified recipients? (optional, default to 0)
     * @param tts Send Text-to-Speech message. (optional, default to 0)
     * @param local Treat phone numbers passed in the \\'phones\\' field as local. (optional, default to 0)
     * @param localCountry The 2-letter ISO country code for local phone numbers, used when \\'local\\' is set to true. Default is the account country. (optional)
     * @return GetMessagePreviewResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetMessagePreviewResponse getMessagePreview(String text, Integer templateId, Integer sendingTime, String sendingDateTime, String sendingTimezone, String contacts, String lists, String phones, Integer cutExtra, Integer partsCount, Integer referenceId, String from, String rule, Integer createChat, Integer tts, Integer local, String localCountry) throws ApiException {
        ApiResponse resp = getMessagePreviewWithHttpInfo(text, templateId, sendingTime, sendingDateTime, sendingTimezone, contacts, lists, phones, cutExtra, partsCount, referenceId, from, rule, createChat, tts, local, localCountry);
        return resp.getData();
    }

    /**
     * Preview message
     * Get a messages preview (with tags merged) of up to 100 messages per session.
     * @param text Message text. Required if **template_id** is not set. (optional)
     * @param templateId Template used instead of message text. Required if **text** is not set. (optional)
     * @param sendingTime DEPRECATED, consider using sendingDateTime and sendingTimezone parameters instead: Optional (required with rrule set). Message sending time is in unix timestamp format. Default is now. (optional)
     * @param sendingDateTime Sending time is in Y-m-d H:i:s format (e.g. 2016-05-27 13:02:33). This time is relative to the sendingTimezone. (optional)
     * @param sendingTimezone The ID or ISO-name of the timezone used for sending when the sendingDateTime parameter is set, e.g. if you specify sendingDateTime = \\\"2016-05-27 13:02:33\\\" and sendingTimezone = \\\"America/Buenos_Aires\\\", your message will be sent on May 27, 2016 13:02:33 Buenos Aires time, or 16:02:33 UTC. Default is the account timezone. (optional)
     * @param contacts Comma-separated array of contact resources id message will be sent to. (optional)
     * @param lists Comma-separated array of list resources id message will be sent to. (optional)
     * @param phones Comma-separated array of E.164 phone numbers message will be sent to. (optional)
     * @param cutExtra Should sending method cut extra characters which not fit supplied partsCount or return 400 Bad request response instead. (optional, default to 0)
     * @param partsCount Maximum message parts count (TextMagic allows sending of 1 to 6 message parts). (optional, default to 6)
     * @param referenceId Custom message reference id which can be used in your application infrastructure. (optional)
     * @param from One of the allowed Sender ID (phone number or alphanumeric sender ID). If the specified Sender ID is not allowed for some destinations, a fallback default Sender ID will be used to ensure delivery. See [Get timezones](https://docs.textmagic.com/#tag/Sender-IDs). (optional)
     * @param rule An iCal RRULE parameter to create recurrent scheduled messages. When used, sendingTime is mandatory as the start point of sending. See https://www.textmagic.com/free-tools/rrule-generator for format details. (optional)
     * @param createChat Should the sending method try to create new Chat(if not exist) with specified recipients? (optional, default to 0)
     * @param tts Send Text-to-Speech message. (optional, default to 0)
     * @param local Treat phone numbers passed in the \\'phones\\' field as local. (optional, default to 0)
     * @param localCountry The 2-letter ISO country code for local phone numbers, used when \\'local\\' is set to true. Default is the account country. (optional)
     * @return ApiResponse<GetMessagePreviewResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getMessagePreviewWithHttpInfo(String text, Integer templateId, Integer sendingTime, String sendingDateTime, String sendingTimezone, String contacts, String lists, String phones, Integer cutExtra, Integer partsCount, Integer referenceId, String from, String rule, Integer createChat, Integer tts, Integer local, String localCountry) throws ApiException {
        com.squareup.okhttp.Call call = getMessagePreviewValidateBeforeCall(text, templateId, sendingTime, sendingDateTime, sendingTimezone, contacts, lists, phones, cutExtra, partsCount, referenceId, from, rule, createChat, tts, local, localCountry, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Preview message (asynchronously)
     * Get a messages preview (with tags merged) of up to 100 messages per session.
     * @param text Message text. Required if **template_id** is not set. (optional)
     * @param templateId Template used instead of message text. Required if **text** is not set. (optional)
     * @param sendingTime DEPRECATED, consider using sendingDateTime and sendingTimezone parameters instead: Optional (required with rrule set). Message sending time is in unix timestamp format. Default is now. (optional)
     * @param sendingDateTime Sending time is in Y-m-d H:i:s format (e.g. 2016-05-27 13:02:33). This time is relative to the sendingTimezone. (optional)
     * @param sendingTimezone The ID or ISO-name of the timezone used for sending when the sendingDateTime parameter is set, e.g. if you specify sendingDateTime = \\\"2016-05-27 13:02:33\\\" and sendingTimezone = \\\"America/Buenos_Aires\\\", your message will be sent on May 27, 2016 13:02:33 Buenos Aires time, or 16:02:33 UTC. Default is the account timezone. (optional)
     * @param contacts Comma-separated array of contact resources id message will be sent to. (optional)
     * @param lists Comma-separated array of list resources id message will be sent to. (optional)
     * @param phones Comma-separated array of E.164 phone numbers message will be sent to. (optional)
     * @param cutExtra Should sending method cut extra characters which not fit supplied partsCount or return 400 Bad request response instead. (optional, default to 0)
     * @param partsCount Maximum message parts count (TextMagic allows sending of 1 to 6 message parts). (optional, default to 6)
     * @param referenceId Custom message reference id which can be used in your application infrastructure. (optional)
     * @param from One of the allowed Sender ID (phone number or alphanumeric sender ID). If the specified Sender ID is not allowed for some destinations, a fallback default Sender ID will be used to ensure delivery. See [Get timezones](https://docs.textmagic.com/#tag/Sender-IDs). (optional)
     * @param rule An iCal RRULE parameter to create recurrent scheduled messages. When used, sendingTime is mandatory as the start point of sending. See https://www.textmagic.com/free-tools/rrule-generator for format details. (optional)
     * @param createChat Should the sending method try to create new Chat(if not exist) with specified recipients? (optional, default to 0)
     * @param tts Send Text-to-Speech message. (optional, default to 0)
     * @param local Treat phone numbers passed in the \\'phones\\' field as local. (optional, default to 0)
     * @param localCountry The 2-letter ISO country code for local phone numbers, used when \\'local\\' is set to true. Default is the account country. (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 getMessagePreviewAsync(String text, Integer templateId, Integer sendingTime, String sendingDateTime, String sendingTimezone, String contacts, String lists, String phones, Integer cutExtra, Integer partsCount, Integer referenceId, String from, String rule, Integer createChat, Integer tts, Integer local, String localCountry, final ApiCallback 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 = getMessagePreviewValidateBeforeCall(text, templateId, sendingTime, sendingDateTime, sendingTimezone, contacts, lists, phones, cutExtra, partsCount, referenceId, from, rule, createChat, tts, local, localCountry, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getMessagePrice
     * @param includeBlocked Should we show the pricing for blocked contacts? (optional, default to 0)
     * @param text Message text. Required if the **template_id** is not set. (optional)
     * @param templateId Template used instead of message text. Required if the **text** is not set. (optional)
     * @param sendingTime DEPRECATED, consider using the sendingDateTime and sendingTimezone parameters instead: optional (required with rrule set). Message sending time is in unix timestamp format. Default is now. (optional)
     * @param sendingDateTime Sending time is in Y-m-d H:i:s format (e.g. 2016-05-27 13:02:33). This time is relative to the sendingTimezone. (optional)
     * @param sendingTimezone The ID or ISO-name of the timezone used for sending when sendingDateTime parameter is set, e.g. if you specify sendingDateTime = \\\"2016-05-27 13:02:33\\\" and sendingTimezone = \\\"America/Buenos_Aires\\\", your message will be sent on May 27, 2016 13:02:33 Buenos Aires time, or 16:02:33 UTC. Default is the account timezone. (optional)
     * @param contacts Comma-separated array of contact resources id message will be sent to. (optional)
     * @param lists Comma-separated array of list resources id message will be sent to. (optional)
     * @param phones Comma-separated array of E.164 phone numbers message will be sent to. (optional)
     * @param cutExtra Should sending method cut extra characters which not fit supplied partsCount or return 400 Bad request response instead. (optional, default to 0)
     * @param partsCount Maximum message parts count (TextMagic allows sending 1 to 6 message parts). (optional, default to 6)
     * @param referenceId Custom message reference id which can be used in your application infrastructure. (optional)
     * @param from One of the allowed Sender ID (phone number or alphanumeric sender ID). If the specified Sender ID is not allowed for some destinations, a fallback default Sender ID will be used to ensure delivery. See [Get timezones](https://docs.textmagic.com/#tag/Sender-IDs). (optional)
     * @param rule An iCal RRULE parameter to create recurrent scheduled messages. When used, sendingTime is mandatory as the start point of sending. See https://www.textmagic.com/free-tools/rrule-generator for format details. (optional)
     * @param createChat Should the sending method try to create new Chat (if not exist) with specified recipients? (optional, default to 0)
     * @param tts Send a Text-to-Speech message. (optional, default to 0)
     * @param local Treat phone numbers passed in the \\'phones\\' field as local. (optional, default to 0)
     * @param localCountry The 2-letter ISO country code for local phone numbers, used when \\'local\\' is set to true. Default is the account country. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getMessagePriceCall(Integer includeBlocked, String text, Integer templateId, Integer sendingTime, String sendingDateTime, String sendingTimezone, String contacts, String lists, String phones, Integer cutExtra, Integer partsCount, Integer referenceId, String from, String rule, Integer createChat, Integer tts, Integer local, String localCountry, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/messages/price/normalized";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (includeBlocked != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("includeBlocked", includeBlocked));
        if (text != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("text", text));
        if (templateId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("templateId", templateId));
        if (sendingTime != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("sendingTime", sendingTime));
        if (sendingDateTime != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("sendingDateTime", sendingDateTime));
        if (sendingTimezone != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("sendingTimezone", sendingTimezone));
        if (contacts != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("contacts", contacts));
        if (lists != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("lists", lists));
        if (phones != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("phones", phones));
        if (cutExtra != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("cutExtra", cutExtra));
        if (partsCount != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("partsCount", partsCount));
        if (referenceId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("referenceId", referenceId));
        if (from != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("from", from));
        if (rule != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("rule", rule));
        if (createChat != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("createChat", createChat));
        if (tts != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("tts", tts));
        if (local != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("local", local));
        if (localCountry != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("localCountry", localCountry));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getMessagePriceValidateBeforeCall(Integer includeBlocked, String text, Integer templateId, Integer sendingTime, String sendingDateTime, String sendingTimezone, String contacts, String lists, String phones, Integer cutExtra, Integer partsCount, Integer referenceId, String from, String rule, Integer createChat, Integer tts, Integer local, String localCountry, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getMessagePriceCall(includeBlocked, text, templateId, sendingTime, sendingDateTime, sendingTimezone, contacts, lists, phones, cutExtra, partsCount, referenceId, from, rule, createChat, tts, local, localCountry, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Check message price
     * Check pricing for a new outbound message.
     * @param includeBlocked Should we show the pricing for blocked contacts? (optional, default to 0)
     * @param text Message text. Required if the **template_id** is not set. (optional)
     * @param templateId Template used instead of message text. Required if the **text** is not set. (optional)
     * @param sendingTime DEPRECATED, consider using the sendingDateTime and sendingTimezone parameters instead: optional (required with rrule set). Message sending time is in unix timestamp format. Default is now. (optional)
     * @param sendingDateTime Sending time is in Y-m-d H:i:s format (e.g. 2016-05-27 13:02:33). This time is relative to the sendingTimezone. (optional)
     * @param sendingTimezone The ID or ISO-name of the timezone used for sending when sendingDateTime parameter is set, e.g. if you specify sendingDateTime = \\\"2016-05-27 13:02:33\\\" and sendingTimezone = \\\"America/Buenos_Aires\\\", your message will be sent on May 27, 2016 13:02:33 Buenos Aires time, or 16:02:33 UTC. Default is the account timezone. (optional)
     * @param contacts Comma-separated array of contact resources id message will be sent to. (optional)
     * @param lists Comma-separated array of list resources id message will be sent to. (optional)
     * @param phones Comma-separated array of E.164 phone numbers message will be sent to. (optional)
     * @param cutExtra Should sending method cut extra characters which not fit supplied partsCount or return 400 Bad request response instead. (optional, default to 0)
     * @param partsCount Maximum message parts count (TextMagic allows sending 1 to 6 message parts). (optional, default to 6)
     * @param referenceId Custom message reference id which can be used in your application infrastructure. (optional)
     * @param from One of the allowed Sender ID (phone number or alphanumeric sender ID). If the specified Sender ID is not allowed for some destinations, a fallback default Sender ID will be used to ensure delivery. See [Get timezones](https://docs.textmagic.com/#tag/Sender-IDs). (optional)
     * @param rule An iCal RRULE parameter to create recurrent scheduled messages. When used, sendingTime is mandatory as the start point of sending. See https://www.textmagic.com/free-tools/rrule-generator for format details. (optional)
     * @param createChat Should the sending method try to create new Chat (if not exist) with specified recipients? (optional, default to 0)
     * @param tts Send a Text-to-Speech message. (optional, default to 0)
     * @param local Treat phone numbers passed in the \\'phones\\' field as local. (optional, default to 0)
     * @param localCountry The 2-letter ISO country code for local phone numbers, used when \\'local\\' is set to true. Default is the account country. (optional)
     * @return GetMessagePriceResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetMessagePriceResponse getMessagePrice(Integer includeBlocked, String text, Integer templateId, Integer sendingTime, String sendingDateTime, String sendingTimezone, String contacts, String lists, String phones, Integer cutExtra, Integer partsCount, Integer referenceId, String from, String rule, Integer createChat, Integer tts, Integer local, String localCountry) throws ApiException {
        ApiResponse resp = getMessagePriceWithHttpInfo(includeBlocked, text, templateId, sendingTime, sendingDateTime, sendingTimezone, contacts, lists, phones, cutExtra, partsCount, referenceId, from, rule, createChat, tts, local, localCountry);
        return resp.getData();
    }

    /**
     * Check message price
     * Check pricing for a new outbound message.
     * @param includeBlocked Should we show the pricing for blocked contacts? (optional, default to 0)
     * @param text Message text. Required if the **template_id** is not set. (optional)
     * @param templateId Template used instead of message text. Required if the **text** is not set. (optional)
     * @param sendingTime DEPRECATED, consider using the sendingDateTime and sendingTimezone parameters instead: optional (required with rrule set). Message sending time is in unix timestamp format. Default is now. (optional)
     * @param sendingDateTime Sending time is in Y-m-d H:i:s format (e.g. 2016-05-27 13:02:33). This time is relative to the sendingTimezone. (optional)
     * @param sendingTimezone The ID or ISO-name of the timezone used for sending when sendingDateTime parameter is set, e.g. if you specify sendingDateTime = \\\"2016-05-27 13:02:33\\\" and sendingTimezone = \\\"America/Buenos_Aires\\\", your message will be sent on May 27, 2016 13:02:33 Buenos Aires time, or 16:02:33 UTC. Default is the account timezone. (optional)
     * @param contacts Comma-separated array of contact resources id message will be sent to. (optional)
     * @param lists Comma-separated array of list resources id message will be sent to. (optional)
     * @param phones Comma-separated array of E.164 phone numbers message will be sent to. (optional)
     * @param cutExtra Should sending method cut extra characters which not fit supplied partsCount or return 400 Bad request response instead. (optional, default to 0)
     * @param partsCount Maximum message parts count (TextMagic allows sending 1 to 6 message parts). (optional, default to 6)
     * @param referenceId Custom message reference id which can be used in your application infrastructure. (optional)
     * @param from One of the allowed Sender ID (phone number or alphanumeric sender ID). If the specified Sender ID is not allowed for some destinations, a fallback default Sender ID will be used to ensure delivery. See [Get timezones](https://docs.textmagic.com/#tag/Sender-IDs). (optional)
     * @param rule An iCal RRULE parameter to create recurrent scheduled messages. When used, sendingTime is mandatory as the start point of sending. See https://www.textmagic.com/free-tools/rrule-generator for format details. (optional)
     * @param createChat Should the sending method try to create new Chat (if not exist) with specified recipients? (optional, default to 0)
     * @param tts Send a Text-to-Speech message. (optional, default to 0)
     * @param local Treat phone numbers passed in the \\'phones\\' field as local. (optional, default to 0)
     * @param localCountry The 2-letter ISO country code for local phone numbers, used when \\'local\\' is set to true. Default is the account country. (optional)
     * @return ApiResponse<GetMessagePriceResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getMessagePriceWithHttpInfo(Integer includeBlocked, String text, Integer templateId, Integer sendingTime, String sendingDateTime, String sendingTimezone, String contacts, String lists, String phones, Integer cutExtra, Integer partsCount, Integer referenceId, String from, String rule, Integer createChat, Integer tts, Integer local, String localCountry) throws ApiException {
        com.squareup.okhttp.Call call = getMessagePriceValidateBeforeCall(includeBlocked, text, templateId, sendingTime, sendingDateTime, sendingTimezone, contacts, lists, phones, cutExtra, partsCount, referenceId, from, rule, createChat, tts, local, localCountry, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Check message price (asynchronously)
     * Check pricing for a new outbound message.
     * @param includeBlocked Should we show the pricing for blocked contacts? (optional, default to 0)
     * @param text Message text. Required if the **template_id** is not set. (optional)
     * @param templateId Template used instead of message text. Required if the **text** is not set. (optional)
     * @param sendingTime DEPRECATED, consider using the sendingDateTime and sendingTimezone parameters instead: optional (required with rrule set). Message sending time is in unix timestamp format. Default is now. (optional)
     * @param sendingDateTime Sending time is in Y-m-d H:i:s format (e.g. 2016-05-27 13:02:33). This time is relative to the sendingTimezone. (optional)
     * @param sendingTimezone The ID or ISO-name of the timezone used for sending when sendingDateTime parameter is set, e.g. if you specify sendingDateTime = \\\"2016-05-27 13:02:33\\\" and sendingTimezone = \\\"America/Buenos_Aires\\\", your message will be sent on May 27, 2016 13:02:33 Buenos Aires time, or 16:02:33 UTC. Default is the account timezone. (optional)
     * @param contacts Comma-separated array of contact resources id message will be sent to. (optional)
     * @param lists Comma-separated array of list resources id message will be sent to. (optional)
     * @param phones Comma-separated array of E.164 phone numbers message will be sent to. (optional)
     * @param cutExtra Should sending method cut extra characters which not fit supplied partsCount or return 400 Bad request response instead. (optional, default to 0)
     * @param partsCount Maximum message parts count (TextMagic allows sending 1 to 6 message parts). (optional, default to 6)
     * @param referenceId Custom message reference id which can be used in your application infrastructure. (optional)
     * @param from One of the allowed Sender ID (phone number or alphanumeric sender ID). If the specified Sender ID is not allowed for some destinations, a fallback default Sender ID will be used to ensure delivery. See [Get timezones](https://docs.textmagic.com/#tag/Sender-IDs). (optional)
     * @param rule An iCal RRULE parameter to create recurrent scheduled messages. When used, sendingTime is mandatory as the start point of sending. See https://www.textmagic.com/free-tools/rrule-generator for format details. (optional)
     * @param createChat Should the sending method try to create new Chat (if not exist) with specified recipients? (optional, default to 0)
     * @param tts Send a Text-to-Speech message. (optional, default to 0)
     * @param local Treat phone numbers passed in the \\'phones\\' field as local. (optional, default to 0)
     * @param localCountry The 2-letter ISO country code for local phone numbers, used when \\'local\\' is set to true. Default is the account country. (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 getMessagePriceAsync(Integer includeBlocked, String text, Integer templateId, Integer sendingTime, String sendingDateTime, String sendingTimezone, String contacts, String lists, String phones, Integer cutExtra, Integer partsCount, Integer referenceId, String from, String rule, Integer createChat, Integer tts, Integer local, String localCountry, final ApiCallback 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 = getMessagePriceValidateBeforeCall(includeBlocked, text, templateId, sendingTime, sendingDateTime, sendingTimezone, contacts, lists, phones, cutExtra, partsCount, referenceId, from, rule, createChat, tts, local, localCountry, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getMessageSession
     * @param id Session ID. (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getMessageSessionCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/sessions/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getMessageSessionValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getMessageSession(Async)");
        }
        

        com.squareup.okhttp.Call call = getMessageSessionCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get a session`s details
     * Get a specific session’s details.
     * @param id Session ID. (required)
     * @return MessageSession
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public MessageSession getMessageSession(Integer id) throws ApiException {
        ApiResponse resp = getMessageSessionWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get a session`s details
     * Get a specific session’s details.
     * @param id Session ID. (required)
     * @return ApiResponse<MessageSession>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getMessageSessionWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getMessageSessionValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a session`s details (asynchronously)
     * Get a specific session’s details.
     * @param id Session 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 getMessageSessionAsync(Integer id, final ApiCallback 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 = getMessageSessionValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getMessageSessionStat
     * @param id  (required)
     * @param includeDeleted Search also in deleted messages. (optional, default to 0)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getMessageSessionStatCall(Integer id, Integer includeDeleted, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/sessions/{id}/stat"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (includeDeleted != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("includeDeleted", includeDeleted));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getMessageSessionStatValidateBeforeCall(Integer id, Integer includeDeleted, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getMessageSessionStat(Async)");
        }
        

        com.squareup.okhttp.Call call = getMessageSessionStatCall(id, includeDeleted, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get a session`s statistics
     * 
     * @param id  (required)
     * @param includeDeleted Search also in deleted messages. (optional, default to 0)
     * @return GetMessageSessionStatResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetMessageSessionStatResponse getMessageSessionStat(Integer id, Integer includeDeleted) throws ApiException {
        ApiResponse resp = getMessageSessionStatWithHttpInfo(id, includeDeleted);
        return resp.getData();
    }

    /**
     * Get a session`s statistics
     * 
     * @param id  (required)
     * @param includeDeleted Search also in deleted messages. (optional, default to 0)
     * @return ApiResponse<GetMessageSessionStatResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getMessageSessionStatWithHttpInfo(Integer id, Integer includeDeleted) throws ApiException {
        com.squareup.okhttp.Call call = getMessageSessionStatValidateBeforeCall(id, includeDeleted, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a session`s statistics (asynchronously)
     * 
     * @param id  (required)
     * @param includeDeleted Search also in deleted messages. (optional, default to 0)
     * @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 getMessageSessionStatAsync(Integer id, Integer includeDeleted, final ApiCallback 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 = getMessageSessionStatValidateBeforeCall(id, includeDeleted, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getMessagesBySessionId
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param statuses Find messages by status. (optional)
     * @param includeDeleted Search also in deleted messages. (optional, default to 0)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getMessagesBySessionIdCall(Integer id, Integer page, Integer limit, String statuses, Integer includeDeleted, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/sessions/{id}/messages"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (statuses != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("statuses", statuses));
        if (includeDeleted != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("includeDeleted", includeDeleted));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getMessagesBySessionIdValidateBeforeCall(Integer id, Integer page, Integer limit, String statuses, Integer includeDeleted, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getMessagesBySessionId(Async)");
        }
        

        com.squareup.okhttp.Call call = getMessagesBySessionIdCall(id, page, limit, statuses, includeDeleted, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get a session`s messages
     * A useful synonym for the \"messages/search\" command with the provided \"sessionId\" parameter.
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param statuses Find messages by status. (optional)
     * @param includeDeleted Search also in deleted messages. (optional, default to 0)
     * @return GetMessagesBySessionIdPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetMessagesBySessionIdPaginatedResponse getMessagesBySessionId(Integer id, Integer page, Integer limit, String statuses, Integer includeDeleted) throws ApiException {
        ApiResponse resp = getMessagesBySessionIdWithHttpInfo(id, page, limit, statuses, includeDeleted);
        return resp.getData();
    }

    /**
     * Get a session`s messages
     * A useful synonym for the \"messages/search\" command with the provided \"sessionId\" parameter.
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param statuses Find messages by status. (optional)
     * @param includeDeleted Search also in deleted messages. (optional, default to 0)
     * @return ApiResponse<GetMessagesBySessionIdPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getMessagesBySessionIdWithHttpInfo(Integer id, Integer page, Integer limit, String statuses, Integer includeDeleted) throws ApiException {
        com.squareup.okhttp.Call call = getMessagesBySessionIdValidateBeforeCall(id, page, limit, statuses, includeDeleted, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a session`s messages (asynchronously)
     * A useful synonym for the \"messages/search\" command with the provided \"sessionId\" parameter.
     * @param id  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param statuses Find messages by status. (optional)
     * @param includeDeleted Search also in deleted messages. (optional, default to 0)
     * @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 getMessagesBySessionIdAsync(Integer id, Integer page, Integer limit, String statuses, Integer includeDeleted, final ApiCallback 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 = getMessagesBySessionIdValidateBeforeCall(id, page, limit, statuses, includeDeleted, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getMessagingCounters
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getMessagingCountersCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/stats/messaging/data";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getMessagingCountersValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getMessagingCountersCall(progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get sent/received messages counters values
     * Get total contacts, sent messages and received messages counters values.
     * @return GetMessagingCountersResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetMessagingCountersResponse getMessagingCounters() throws ApiException {
        ApiResponse resp = getMessagingCountersWithHttpInfo();
        return resp.getData();
    }

    /**
     * Get sent/received messages counters values
     * Get total contacts, sent messages and received messages counters values.
     * @return ApiResponse<GetMessagingCountersResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getMessagingCountersWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = getMessagingCountersValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get sent/received messages counters values (asynchronously)
     * Get total contacts, sent messages and received messages counters values.
     * @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 getMessagingCountersAsync(final ApiCallback 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 = getMessagingCountersValidateBeforeCall(progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getMessagingStat
     * @param by *   **off** - to get total values per specified time interval; *   **day** - to show values grouped by day; *   **month** - to show values grouped by month; *   **year** - to show values grouped by year.  (optional, default to off)
     * @param start Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is 7 days prior.  (optional)
     * @param end Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is today.  (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getMessagingStatCall(String by, Integer start, Integer end, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/stats/messaging";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (by != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("by", by));
        if (start != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("start", start));
        if (end != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("end", end));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getMessagingStatValidateBeforeCall(String by, Integer start, Integer end, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getMessagingStatCall(by, start, end, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get messaging statistics
     * 
     * @param by *   **off** - to get total values per specified time interval; *   **day** - to show values grouped by day; *   **month** - to show values grouped by month; *   **year** - to show values grouped by year.  (optional, default to off)
     * @param start Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is 7 days prior.  (optional)
     * @param end Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is today.  (optional)
     * @return GetMessagingStatResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetMessagingStatResponse getMessagingStat(String by, Integer start, Integer end) throws ApiException {
        ApiResponse resp = getMessagingStatWithHttpInfo(by, start, end);
        return resp.getData();
    }

    /**
     * Get messaging statistics
     * 
     * @param by *   **off** - to get total values per specified time interval; *   **day** - to show values grouped by day; *   **month** - to show values grouped by month; *   **year** - to show values grouped by year.  (optional, default to off)
     * @param start Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is 7 days prior.  (optional)
     * @param end Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is today.  (optional)
     * @return ApiResponse<GetMessagingStatResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getMessagingStatWithHttpInfo(String by, Integer start, Integer end) throws ApiException {
        com.squareup.okhttp.Call call = getMessagingStatValidateBeforeCall(by, start, end, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get messaging statistics (asynchronously)
     * 
     * @param by *   **off** - to get total values per specified time interval; *   **day** - to show values grouped by day; *   **month** - to show values grouped by month; *   **year** - to show values grouped by year.  (optional, default to off)
     * @param start Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is 7 days prior.  (optional)
     * @param end Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is today.  (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 getMessagingStatAsync(String by, Integer start, Integer end, final ApiCallback 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 = getMessagingStatValidateBeforeCall(by, start, end, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getOutboundMessage
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getOutboundMessageCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/messages/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getOutboundMessageValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getOutboundMessage(Async)");
        }
        

        com.squareup.okhttp.Call call = getOutboundMessageCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get a single message
     * Get a single outgoing message.
     * @param id  (required)
     * @return MessageOut
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public MessageOut getOutboundMessage(Integer id) throws ApiException {
        ApiResponse resp = getOutboundMessageWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get a single message
     * Get a single outgoing message.
     * @param id  (required)
     * @return ApiResponse<MessageOut>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getOutboundMessageWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getOutboundMessageValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a single message (asynchronously)
     * Get a single outgoing message.
     * @param 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 getOutboundMessageAsync(Integer id, final ApiCallback 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 = getOutboundMessageValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getOutboundMessagesHistory
     * @param limit The number of results per page. (optional, default to 10)
     * @param lastId Filter results by ID, selecting all values lesser than the specified ID. (optional)
     * @param query Find message by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getOutboundMessagesHistoryCall(Integer limit, Integer lastId, String query, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/history";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (lastId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("lastId", lastId));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));
        if (orderBy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("orderBy", orderBy));
        if (direction != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("direction", direction));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getOutboundMessagesHistoryValidateBeforeCall(Integer limit, Integer lastId, String query, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getOutboundMessagesHistoryCall(limit, lastId, query, orderBy, direction, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get history
     * Get the outbound messages history.
     * @param limit The number of results per page. (optional, default to 10)
     * @param lastId Filter results by ID, selecting all values lesser than the specified ID. (optional)
     * @param query Find message by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return GetOutboundMessagesHistoryPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetOutboundMessagesHistoryPaginatedResponse getOutboundMessagesHistory(Integer limit, Integer lastId, String query, String orderBy, String direction) throws ApiException {
        ApiResponse resp = getOutboundMessagesHistoryWithHttpInfo(limit, lastId, query, orderBy, direction);
        return resp.getData();
    }

    /**
     * Get history
     * Get the outbound messages history.
     * @param limit The number of results per page. (optional, default to 10)
     * @param lastId Filter results by ID, selecting all values lesser than the specified ID. (optional)
     * @param query Find message by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return ApiResponse<GetOutboundMessagesHistoryPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getOutboundMessagesHistoryWithHttpInfo(Integer limit, Integer lastId, String query, String orderBy, String direction) throws ApiException {
        com.squareup.okhttp.Call call = getOutboundMessagesHistoryValidateBeforeCall(limit, lastId, query, orderBy, direction, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get history (asynchronously)
     * Get the outbound messages history.
     * @param limit The number of results per page. (optional, default to 10)
     * @param lastId Filter results by ID, selecting all values lesser than the specified ID. (optional)
     * @param query Find message by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @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 getOutboundMessagesHistoryAsync(Integer limit, Integer lastId, String query, String orderBy, String direction, final ApiCallback 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 = getOutboundMessagesHistoryValidateBeforeCall(limit, lastId, query, orderBy, direction, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getScheduledMessage
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getScheduledMessageCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/schedules/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getScheduledMessageValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getScheduledMessage(Async)");
        }
        

        com.squareup.okhttp.Call call = getScheduledMessageCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get a single scheduled message
     * 
     * @param id  (required)
     * @return MessagesIcs
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public MessagesIcs getScheduledMessage(Integer id) throws ApiException {
        ApiResponse resp = getScheduledMessageWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get a single scheduled message
     * 
     * @param id  (required)
     * @return ApiResponse<MessagesIcs>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getScheduledMessageWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getScheduledMessageValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a single scheduled message (asynchronously)
     * 
     * @param 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 getScheduledMessageAsync(Integer id, final ApiCallback 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 = getScheduledMessageValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getSenderId
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getSenderIdCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/senderids/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getSenderIdValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getSenderId(Async)");
        }
        

        com.squareup.okhttp.Call call = getSenderIdCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get the details of a specific Sender ID
     * 
     * @param id  (required)
     * @return SenderId
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public SenderId getSenderId(Integer id) throws ApiException {
        ApiResponse resp = getSenderIdWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get the details of a specific Sender ID
     * 
     * @param id  (required)
     * @return ApiResponse<SenderId>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getSenderIdWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getSenderIdValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the details of a specific Sender ID (asynchronously)
     * 
     * @param 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 getSenderIdAsync(Integer id, final ApiCallback 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 = getSenderIdValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getSenderIds
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getSenderIdsCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/senderids";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getSenderIdsValidateBeforeCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getSenderIdsCall(page, limit, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all your approved Sender IDs
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return GetSenderIdsPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetSenderIdsPaginatedResponse getSenderIds(Integer page, Integer limit) throws ApiException {
        ApiResponse resp = getSenderIdsWithHttpInfo(page, limit);
        return resp.getData();
    }

    /**
     * Get all your approved Sender IDs
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return ApiResponse<GetSenderIdsPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getSenderIdsWithHttpInfo(Integer page, Integer limit) throws ApiException {
        com.squareup.okhttp.Call call = getSenderIdsValidateBeforeCall(page, limit, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all your approved Sender IDs (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @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 getSenderIdsAsync(Integer page, Integer limit, final ApiCallback 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 = getSenderIdsValidateBeforeCall(page, limit, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getSenderSettings
     * @param country Return sender settings enabled for sending to a specified country. Should be 2 upper-case characters. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getSenderSettingsCall(String country, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/sender/settings/normalized";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (country != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("country", country));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getSenderSettingsValidateBeforeCall(String country, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getSenderSettingsCall(country, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get current sender settings
     * 
     * @param country Return sender settings enabled for sending to a specified country. Should be 2 upper-case characters. (optional)
     * @return GetSenderSettingsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetSenderSettingsResponse getSenderSettings(String country) throws ApiException {
        ApiResponse resp = getSenderSettingsWithHttpInfo(country);
        return resp.getData();
    }

    /**
     * Get current sender settings
     * 
     * @param country Return sender settings enabled for sending to a specified country. Should be 2 upper-case characters. (optional)
     * @return ApiResponse<GetSenderSettingsResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getSenderSettingsWithHttpInfo(String country) throws ApiException {
        com.squareup.okhttp.Call call = getSenderSettingsValidateBeforeCall(country, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get current sender settings (asynchronously)
     * 
     * @param country Return sender settings enabled for sending to a specified country. Should be 2 upper-case characters. (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 getSenderSettingsAsync(String country, final ApiCallback 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 = getSenderSettingsValidateBeforeCall(country, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getSpendingStat
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param start Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is 7 days prior.  (optional)
     * @param end Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is today.  (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getSpendingStatCall(Integer page, Integer limit, String start, String end, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/stats/spending";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (start != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("start", start));
        if (end != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("end", end));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getSpendingStatValidateBeforeCall(Integer page, Integer limit, String start, String end, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getSpendingStatCall(page, limit, start, end, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get spending statistics
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param start Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is 7 days prior.  (optional)
     * @param end Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is today.  (optional)
     * @return GetSpendingStatPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetSpendingStatPaginatedResponse getSpendingStat(Integer page, Integer limit, String start, String end) throws ApiException {
        ApiResponse resp = getSpendingStatWithHttpInfo(page, limit, start, end);
        return resp.getData();
    }

    /**
     * Get spending statistics
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param start Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is 7 days prior.  (optional)
     * @param end Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is today.  (optional)
     * @return ApiResponse<GetSpendingStatPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getSpendingStatWithHttpInfo(Integer page, Integer limit, String start, String end) throws ApiException {
        com.squareup.okhttp.Call call = getSpendingStatValidateBeforeCall(page, limit, start, end, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get spending statistics (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param start Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is 7 days prior.  (optional)
     * @param end Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is today.  (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 getSpendingStatAsync(Integer page, Integer limit, String start, String end, final ApiCallback 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 = getSpendingStatValidateBeforeCall(page, limit, start, end, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getSubaccount
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getSubaccountCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/subaccounts/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getSubaccountValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getSubaccount(Async)");
        }
        

        com.squareup.okhttp.Call call = getSubaccountCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get sub-account information
     * 
     * @param id  (required)
     * @return User
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public User getSubaccount(Integer id) throws ApiException {
        ApiResponse resp = getSubaccountWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get sub-account information
     * 
     * @param id  (required)
     * @return ApiResponse<User>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getSubaccountWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getSubaccountValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get sub-account information (asynchronously)
     * 
     * @param 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 getSubaccountAsync(Integer id, final ApiCallback 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 = getSubaccountValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getSubaccounts
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getSubaccountsCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/subaccounts";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getSubaccountsValidateBeforeCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getSubaccountsCall(page, limit, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get a sub-accounts list
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return User
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public User getSubaccounts(Integer page, Integer limit) throws ApiException {
        ApiResponse resp = getSubaccountsWithHttpInfo(page, limit);
        return resp.getData();
    }

    /**
     * Get a sub-accounts list
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return ApiResponse<User>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getSubaccountsWithHttpInfo(Integer page, Integer limit) throws ApiException {
        com.squareup.okhttp.Call call = getSubaccountsValidateBeforeCall(page, limit, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a sub-accounts list (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @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 getSubaccountsAsync(Integer page, Integer limit, final ApiCallback 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 = getSubaccountsValidateBeforeCall(page, limit, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getSubaccountsWithTokens
     * @param getSubaccountsWithTokensInputObject  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getSubaccountsWithTokensCall(GetSubaccountsWithTokensInputObject getSubaccountsWithTokensInputObject, BigDecimal page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = getSubaccountsWithTokensInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/subaccounts/tokens/list";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getSubaccountsWithTokensValidateBeforeCall(GetSubaccountsWithTokensInputObject getSubaccountsWithTokensInputObject, BigDecimal page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'getSubaccountsWithTokensInputObject' is set
        if (getSubaccountsWithTokensInputObject == null) {
            throw new ApiException("Missing the required parameter 'getSubaccountsWithTokensInputObject' when calling getSubaccountsWithTokens(Async)");
        }
        

        com.squareup.okhttp.Call call = getSubaccountsWithTokensCall(getSubaccountsWithTokensInputObject, page, limit, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all sub-accounts with their REST API tokens associated with a specified app name
     * Get all sub-accounts with their REST API tokens associated with specified app name. When more than one token related to app name, last key will be returned.
     * @param getSubaccountsWithTokensInputObject  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return GetSubaccountsWithTokensResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetSubaccountsWithTokensResponse getSubaccountsWithTokens(GetSubaccountsWithTokensInputObject getSubaccountsWithTokensInputObject, BigDecimal page, Integer limit) throws ApiException {
        ApiResponse resp = getSubaccountsWithTokensWithHttpInfo(getSubaccountsWithTokensInputObject, page, limit);
        return resp.getData();
    }

    /**
     * Get all sub-accounts with their REST API tokens associated with a specified app name
     * Get all sub-accounts with their REST API tokens associated with specified app name. When more than one token related to app name, last key will be returned.
     * @param getSubaccountsWithTokensInputObject  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return ApiResponse<GetSubaccountsWithTokensResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getSubaccountsWithTokensWithHttpInfo(GetSubaccountsWithTokensInputObject getSubaccountsWithTokensInputObject, BigDecimal page, Integer limit) throws ApiException {
        com.squareup.okhttp.Call call = getSubaccountsWithTokensValidateBeforeCall(getSubaccountsWithTokensInputObject, page, limit, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all sub-accounts with their REST API tokens associated with a specified app name (asynchronously)
     * Get all sub-accounts with their REST API tokens associated with specified app name. When more than one token related to app name, last key will be returned.
     * @param getSubaccountsWithTokensInputObject  (required)
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @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 getSubaccountsWithTokensAsync(GetSubaccountsWithTokensInputObject getSubaccountsWithTokensInputObject, BigDecimal page, Integer limit, final ApiCallback 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 = getSubaccountsWithTokensValidateBeforeCall(getSubaccountsWithTokensInputObject, page, limit, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getTemplate
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getTemplateCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/templates/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getTemplateValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getTemplate(Async)");
        }
        

        com.squareup.okhttp.Call call = getTemplateCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get a template`s details
     * Get a single template.
     * @param id  (required)
     * @return MessageTemplate
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public MessageTemplate getTemplate(Integer id) throws ApiException {
        ApiResponse resp = getTemplateWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get a template`s details
     * Get a single template.
     * @param id  (required)
     * @return ApiResponse<MessageTemplate>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getTemplateWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getTemplateValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a template`s details (asynchronously)
     * Get a single template.
     * @param 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 getTemplateAsync(Integer id, final ApiCallback 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 = getTemplateValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getTimezones
     * @param full Return full info about timezones in array (0 or 1). Default is 0. (optional, default to 0)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getTimezonesCall(Integer full, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/timezones";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (full != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("full", full));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getTimezonesValidateBeforeCall(Integer full, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getTimezonesCall(full, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get timezones
     * Return all available timezone IDs
     * @param full Return full info about timezones in array (0 or 1). Default is 0. (optional, default to 0)
     * @return GetTimezonesResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetTimezonesResponse getTimezones(Integer full) throws ApiException {
        ApiResponse resp = getTimezonesWithHttpInfo(full);
        return resp.getData();
    }

    /**
     * Get timezones
     * Return all available timezone IDs
     * @param full Return full info about timezones in array (0 or 1). Default is 0. (optional, default to 0)
     * @return ApiResponse<GetTimezonesResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getTimezonesWithHttpInfo(Integer full) throws ApiException {
        com.squareup.okhttp.Call call = getTimezonesValidateBeforeCall(full, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get timezones (asynchronously)
     * Return all available timezone IDs
     * @param full Return full info about timezones in array (0 or 1). Default is 0. (optional, default to 0)
     * @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 getTimezonesAsync(Integer full, final ApiCallback 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 = getTimezonesValidateBeforeCall(full, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getUnreadMessagesTotal
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getUnreadMessagesTotalCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/chats/unread/count";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getUnreadMessagesTotalValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getUnreadMessagesTotalCall(progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get unread messages number
     * Get the total amount of unread messages in the current user chats.
     * @return GetUnreadMessagesTotalResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetUnreadMessagesTotalResponse getUnreadMessagesTotal() throws ApiException {
        ApiResponse resp = getUnreadMessagesTotalWithHttpInfo();
        return resp.getData();
    }

    /**
     * Get unread messages number
     * Get the total amount of unread messages in the current user chats.
     * @return ApiResponse<GetUnreadMessagesTotalResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getUnreadMessagesTotalWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = getUnreadMessagesTotalValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get unread messages number (asynchronously)
     * Get the total amount of unread messages in the current user chats.
     * @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 getUnreadMessagesTotalAsync(final ApiCallback 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 = getUnreadMessagesTotalValidateBeforeCall(progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getUnsubscribedContact
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getUnsubscribedContactCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/unsubscribers/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getUnsubscribedContactValidateBeforeCall(Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getUnsubscribedContact(Async)");
        }
        

        com.squareup.okhttp.Call call = getUnsubscribedContactCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get the details of a specific unsubscribed contact
     * 
     * @param id  (required)
     * @return UnsubscribedContact
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public UnsubscribedContact getUnsubscribedContact(Integer id) throws ApiException {
        ApiResponse resp = getUnsubscribedContactWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Get the details of a specific unsubscribed contact
     * 
     * @param id  (required)
     * @return ApiResponse<UnsubscribedContact>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getUnsubscribedContactWithHttpInfo(Integer id) throws ApiException {
        com.squareup.okhttp.Call call = getUnsubscribedContactValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the details of a specific unsubscribed contact (asynchronously)
     * 
     * @param 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 getUnsubscribedContactAsync(Integer id, final ApiCallback 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 = getUnsubscribedContactValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getUnsubscribers
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getUnsubscribersCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/unsubscribers";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getUnsubscribersValidateBeforeCall(Integer page, Integer limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getUnsubscribersCall(page, limit, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all unsubscribed contacts
     * When one of your message recipients sends a request with one of the [STOP-words](https://www.textmagic.com/sms-stop-command/), they will be immediately opted-out of your send lists and their contact status will change to an unsubscribed contact. To retrieve information on all contacts who have unsubscribed status, use: 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return GetUnsubscribersPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetUnsubscribersPaginatedResponse getUnsubscribers(Integer page, Integer limit) throws ApiException {
        ApiResponse resp = getUnsubscribersWithHttpInfo(page, limit);
        return resp.getData();
    }

    /**
     * Get all unsubscribed contacts
     * When one of your message recipients sends a request with one of the [STOP-words](https://www.textmagic.com/sms-stop-command/), they will be immediately opted-out of your send lists and their contact status will change to an unsubscribed contact. To retrieve information on all contacts who have unsubscribed status, use: 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @return ApiResponse<GetUnsubscribersPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getUnsubscribersWithHttpInfo(Integer page, Integer limit) throws ApiException {
        com.squareup.okhttp.Call call = getUnsubscribersValidateBeforeCall(page, limit, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all unsubscribed contacts (asynchronously)
     * When one of your message recipients sends a request with one of the [STOP-words](https://www.textmagic.com/sms-stop-command/), they will be immediately opted-out of your send lists and their contact status will change to an unsubscribed contact. To retrieve information on all contacts who have unsubscribed status, use: 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @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 getUnsubscribersAsync(Integer page, Integer limit, final ApiCallback 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 = getUnsubscribersValidateBeforeCall(page, limit, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getUserDedicatedNumbers
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param surveyId Fetch only those numbers that are ready for the survey. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getUserDedicatedNumbersCall(Integer page, Integer limit, Integer surveyId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/numbers";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (surveyId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("surveyId", surveyId));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getUserDedicatedNumbersValidateBeforeCall(Integer page, Integer limit, Integer surveyId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = getUserDedicatedNumbersCall(page, limit, surveyId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get all your dedicated numbers
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param surveyId Fetch only those numbers that are ready for the survey. (optional)
     * @return GetUserDedicatedNumbersPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public GetUserDedicatedNumbersPaginatedResponse getUserDedicatedNumbers(Integer page, Integer limit, Integer surveyId) throws ApiException {
        ApiResponse resp = getUserDedicatedNumbersWithHttpInfo(page, limit, surveyId);
        return resp.getData();
    }

    /**
     * Get all your dedicated numbers
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param surveyId Fetch only those numbers that are ready for the survey. (optional)
     * @return ApiResponse<GetUserDedicatedNumbersPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getUserDedicatedNumbersWithHttpInfo(Integer page, Integer limit, Integer surveyId) throws ApiException {
        com.squareup.okhttp.Call call = getUserDedicatedNumbersValidateBeforeCall(page, limit, surveyId, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get all your dedicated numbers (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param surveyId Fetch only those numbers that are ready for the survey. (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 getUserDedicatedNumbersAsync(Integer page, Integer limit, Integer surveyId, final ApiCallback 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 = getUserDedicatedNumbersValidateBeforeCall(page, limit, surveyId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for importContacts
     * @param file File containing contacts in csv or xls(x) formats. (required)
     * @param column Import file column mapping. The string must contain sub-strings of mapping in format `columnNumber:field` glued by `;`. For example: `0:firstName;1:lastName;3:phone;4:email` where the value before `:` is a number of the column in the file, and the value after `:` is a field of the newly created contact or the ID of a custom field. Numbers of columns begin from zero. Allowed built-in contact fields are: `firstName`, `lastName`, `phone`, `email`. Existing of `phone` mapping is required.  (required)
     * @param listId List that ID contacts will be imported to. Ignored if `listName` is specified.  (optional)
     * @param listName List name. This list will be created during import. If such name is already taken, an ordinal (1, 2, ...) will be added to the end. Ignored if `listId` is specified.  (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call importContactsCall(File file, String column, Integer listId, String listName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/import/normalized";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (column != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("column", column));
        if (listId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("listId", listId));
        if (listName != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("listName", listName));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();
        if (file != null)
        localVarFormParams.put("file", file);

        final String[] localVarAccepts = {
            "application/json"
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call importContactsValidateBeforeCall(File file, String column, Integer listId, String listName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'file' is set
        if (file == null) {
            throw new ApiException("Missing the required parameter 'file' when calling importContacts(Async)");
        }
        
        // verify the required parameter 'column' is set
        if (column == null) {
            throw new ApiException("Missing the required parameter 'column' when calling importContacts(Async)");
        }
        

        com.squareup.okhttp.Call call = importContactsCall(file, column, listId, listName, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Import contacts
     * Import contacts from the CSV, XLS or XLSX file.
     * @param file File containing contacts in csv or xls(x) formats. (required)
     * @param column Import file column mapping. The string must contain sub-strings of mapping in format `columnNumber:field` glued by `;`. For example: `0:firstName;1:lastName;3:phone;4:email` where the value before `:` is a number of the column in the file, and the value after `:` is a field of the newly created contact or the ID of a custom field. Numbers of columns begin from zero. Allowed built-in contact fields are: `firstName`, `lastName`, `phone`, `email`. Existing of `phone` mapping is required.  (required)
     * @param listId List that ID contacts will be imported to. Ignored if `listName` is specified.  (optional)
     * @param listName List name. This list will be created during import. If such name is already taken, an ordinal (1, 2, ...) will be added to the end. Ignored if `listId` is specified.  (optional)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse importContacts(File file, String column, Integer listId, String listName) throws ApiException {
        ApiResponse resp = importContactsWithHttpInfo(file, column, listId, listName);
        return resp.getData();
    }

    /**
     * Import contacts
     * Import contacts from the CSV, XLS or XLSX file.
     * @param file File containing contacts in csv or xls(x) formats. (required)
     * @param column Import file column mapping. The string must contain sub-strings of mapping in format `columnNumber:field` glued by `;`. For example: `0:firstName;1:lastName;3:phone;4:email` where the value before `:` is a number of the column in the file, and the value after `:` is a field of the newly created contact or the ID of a custom field. Numbers of columns begin from zero. Allowed built-in contact fields are: `firstName`, `lastName`, `phone`, `email`. Existing of `phone` mapping is required.  (required)
     * @param listId List that ID contacts will be imported to. Ignored if `listName` is specified.  (optional)
     * @param listName List name. This list will be created during import. If such name is already taken, an ordinal (1, 2, ...) will be added to the end. Ignored if `listId` is specified.  (optional)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse importContactsWithHttpInfo(File file, String column, Integer listId, String listName) throws ApiException {
        com.squareup.okhttp.Call call = importContactsValidateBeforeCall(file, column, listId, listName, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Import contacts (asynchronously)
     * Import contacts from the CSV, XLS or XLSX file.
     * @param file File containing contacts in csv or xls(x) formats. (required)
     * @param column Import file column mapping. The string must contain sub-strings of mapping in format `columnNumber:field` glued by `;`. For example: `0:firstName;1:lastName;3:phone;4:email` where the value before `:` is a number of the column in the file, and the value after `:` is a field of the newly created contact or the ID of a custom field. Numbers of columns begin from zero. Allowed built-in contact fields are: `firstName`, `lastName`, `phone`, `email`. Existing of `phone` mapping is required.  (required)
     * @param listId List that ID contacts will be imported to. Ignored if `listName` is specified.  (optional)
     * @param listName List name. This list will be created during import. If such name is already taken, an ordinal (1, 2, ...) will be added to the end. Ignored if `listId` is specified.  (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 importContactsAsync(File file, String column, Integer listId, String listName, final ApiCallback 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 = importContactsValidateBeforeCall(file, column, listId, listName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for inviteSubaccount
     * @param inviteSubaccountInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call inviteSubaccountCall(InviteSubaccountInputObject inviteSubaccountInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = inviteSubaccountInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/subaccounts";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call inviteSubaccountValidateBeforeCall(InviteSubaccountInputObject inviteSubaccountInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'inviteSubaccountInputObject' is set
        if (inviteSubaccountInputObject == null) {
            throw new ApiException("Missing the required parameter 'inviteSubaccountInputObject' when calling inviteSubaccount(Async)");
        }
        

        com.squareup.okhttp.Call call = inviteSubaccountCall(inviteSubaccountInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Invite a new sub-account
     * 
     * @param inviteSubaccountInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void inviteSubaccount(InviteSubaccountInputObject inviteSubaccountInputObject) throws ApiException {
        inviteSubaccountWithHttpInfo(inviteSubaccountInputObject);
    }

    /**
     * Invite a new sub-account
     * 
     * @param inviteSubaccountInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse inviteSubaccountWithHttpInfo(InviteSubaccountInputObject inviteSubaccountInputObject) throws ApiException {
        com.squareup.okhttp.Call call = inviteSubaccountValidateBeforeCall(inviteSubaccountInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Invite a new sub-account (asynchronously)
     * 
     * @param inviteSubaccountInputObject  (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 inviteSubaccountAsync(InviteSubaccountInputObject inviteSubaccountInputObject, final ApiCallback 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 = inviteSubaccountValidateBeforeCall(inviteSubaccountInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for markChatsReadBulk
     * @param markChatsReadBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call markChatsReadBulkCall(MarkChatsReadBulkInputObject markChatsReadBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = markChatsReadBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/chats/read/bulk";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call markChatsReadBulkValidateBeforeCall(MarkChatsReadBulkInputObject markChatsReadBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'markChatsReadBulkInputObject' is set
        if (markChatsReadBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'markChatsReadBulkInputObject' when calling markChatsReadBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = markChatsReadBulkCall(markChatsReadBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Mark chats as read (bulk)
     * Mark several chats as read by chat IDs or mark all chats as read
     * @param markChatsReadBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void markChatsReadBulk(MarkChatsReadBulkInputObject markChatsReadBulkInputObject) throws ApiException {
        markChatsReadBulkWithHttpInfo(markChatsReadBulkInputObject);
    }

    /**
     * Mark chats as read (bulk)
     * Mark several chats as read by chat IDs or mark all chats as read
     * @param markChatsReadBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse markChatsReadBulkWithHttpInfo(MarkChatsReadBulkInputObject markChatsReadBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = markChatsReadBulkValidateBeforeCall(markChatsReadBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Mark chats as read (bulk) (asynchronously)
     * Mark several chats as read by chat IDs or mark all chats as read
     * @param markChatsReadBulkInputObject  (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 markChatsReadBulkAsync(MarkChatsReadBulkInputObject markChatsReadBulkInputObject, final ApiCallback 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 = markChatsReadBulkValidateBeforeCall(markChatsReadBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for markChatsUnreadBulk
     * @param markChatsUnreadBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call markChatsUnreadBulkCall(MarkChatsUnreadBulkInputObject markChatsUnreadBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = markChatsUnreadBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/chats/unread/bulk";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call markChatsUnreadBulkValidateBeforeCall(MarkChatsUnreadBulkInputObject markChatsUnreadBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'markChatsUnreadBulkInputObject' is set
        if (markChatsUnreadBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'markChatsUnreadBulkInputObject' when calling markChatsUnreadBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = markChatsUnreadBulkCall(markChatsUnreadBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Mark chats as unread (bulk)
     * Mark several chats as UNread by chat IDs or mark all chats as UNread
     * @param markChatsUnreadBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void markChatsUnreadBulk(MarkChatsUnreadBulkInputObject markChatsUnreadBulkInputObject) throws ApiException {
        markChatsUnreadBulkWithHttpInfo(markChatsUnreadBulkInputObject);
    }

    /**
     * Mark chats as unread (bulk)
     * Mark several chats as UNread by chat IDs or mark all chats as UNread
     * @param markChatsUnreadBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse markChatsUnreadBulkWithHttpInfo(MarkChatsUnreadBulkInputObject markChatsUnreadBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = markChatsUnreadBulkValidateBeforeCall(markChatsUnreadBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Mark chats as unread (bulk) (asynchronously)
     * Mark several chats as UNread by chat IDs or mark all chats as UNread
     * @param markChatsUnreadBulkInputObject  (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 markChatsUnreadBulkAsync(MarkChatsUnreadBulkInputObject markChatsUnreadBulkInputObject, final ApiCallback 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 = markChatsUnreadBulkValidateBeforeCall(markChatsUnreadBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for muteChat
     * @param muteChatInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call muteChatCall(MuteChatInputObject muteChatInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = muteChatInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/chats/mute";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call muteChatValidateBeforeCall(MuteChatInputObject muteChatInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'muteChatInputObject' is set
        if (muteChatInputObject == null) {
            throw new ApiException("Missing the required parameter 'muteChatInputObject' when calling muteChat(Async)");
        }
        

        com.squareup.okhttp.Call call = muteChatCall(muteChatInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Mute chat sounds
     * 
     * @param muteChatInputObject  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse muteChat(MuteChatInputObject muteChatInputObject) throws ApiException {
        ApiResponse resp = muteChatWithHttpInfo(muteChatInputObject);
        return resp.getData();
    }

    /**
     * Mute chat sounds
     * 
     * @param muteChatInputObject  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse muteChatWithHttpInfo(MuteChatInputObject muteChatInputObject) throws ApiException {
        com.squareup.okhttp.Call call = muteChatValidateBeforeCall(muteChatInputObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Mute chat sounds (asynchronously)
     * 
     * @param muteChatInputObject  (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 muteChatAsync(MuteChatInputObject muteChatInputObject, final ApiCallback 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 = muteChatValidateBeforeCall(muteChatInputObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for muteChatsBulk
     * @param muteChatsBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call muteChatsBulkCall(MuteChatsBulkInputObject muteChatsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = muteChatsBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/chats/mute/bulk";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call muteChatsBulkValidateBeforeCall(MuteChatsBulkInputObject muteChatsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'muteChatsBulkInputObject' is set
        if (muteChatsBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'muteChatsBulkInputObject' when calling muteChatsBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = muteChatsBulkCall(muteChatsBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Mute chats (bulk)
     * Mute several chats by chat ids or mute all chats.
     * @param muteChatsBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void muteChatsBulk(MuteChatsBulkInputObject muteChatsBulkInputObject) throws ApiException {
        muteChatsBulkWithHttpInfo(muteChatsBulkInputObject);
    }

    /**
     * Mute chats (bulk)
     * Mute several chats by chat ids or mute all chats.
     * @param muteChatsBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse muteChatsBulkWithHttpInfo(MuteChatsBulkInputObject muteChatsBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = muteChatsBulkValidateBeforeCall(muteChatsBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Mute chats (bulk) (asynchronously)
     * Mute several chats by chat ids or mute all chats.
     * @param muteChatsBulkInputObject  (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 muteChatsBulkAsync(MuteChatsBulkInputObject muteChatsBulkInputObject, final ApiCallback 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 = muteChatsBulkValidateBeforeCall(muteChatsBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for ping
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call pingCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/ping";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call pingValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = pingCall(progressListener, progressRequestListener);
        return call;

    }

    /**
     * Ping
     * Make a simple ping request.
     * @return PingResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public PingResponse ping() throws ApiException {
        ApiResponse resp = pingWithHttpInfo();
        return resp.getData();
    }

    /**
     * Ping
     * Make a simple ping request.
     * @return ApiResponse<PingResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse pingWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = pingValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Ping (asynchronously)
     * Make a simple ping request.
     * @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 pingAsync(final ApiCallback 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 = pingValidateBeforeCall(progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for reopenChatsBulk
     * @param reopenChatsBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call reopenChatsBulkCall(ReopenChatsBulkInputObject reopenChatsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = reopenChatsBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/chats/reopen/bulk";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call reopenChatsBulkValidateBeforeCall(ReopenChatsBulkInputObject reopenChatsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'reopenChatsBulkInputObject' is set
        if (reopenChatsBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'reopenChatsBulkInputObject' when calling reopenChatsBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = reopenChatsBulkCall(reopenChatsBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Reopen chats (bulk)
     * Reopen chats by chat IDs or reopen all chats
     * @param reopenChatsBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void reopenChatsBulk(ReopenChatsBulkInputObject reopenChatsBulkInputObject) throws ApiException {
        reopenChatsBulkWithHttpInfo(reopenChatsBulkInputObject);
    }

    /**
     * Reopen chats (bulk)
     * Reopen chats by chat IDs or reopen all chats
     * @param reopenChatsBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse reopenChatsBulkWithHttpInfo(ReopenChatsBulkInputObject reopenChatsBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = reopenChatsBulkValidateBeforeCall(reopenChatsBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Reopen chats (bulk) (asynchronously)
     * Reopen chats by chat IDs or reopen all chats
     * @param reopenChatsBulkInputObject  (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 reopenChatsBulkAsync(ReopenChatsBulkInputObject reopenChatsBulkInputObject, final ApiCallback 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 = reopenChatsBulkValidateBeforeCall(reopenChatsBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for requestNewSubaccountToken
     * @param requestNewSubaccountTokenInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call requestNewSubaccountTokenCall(RequestNewSubaccountTokenInputObject requestNewSubaccountTokenInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = requestNewSubaccountTokenInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/subaccounts/tokens";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call requestNewSubaccountTokenValidateBeforeCall(RequestNewSubaccountTokenInputObject requestNewSubaccountTokenInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'requestNewSubaccountTokenInputObject' is set
        if (requestNewSubaccountTokenInputObject == null) {
            throw new ApiException("Missing the required parameter 'requestNewSubaccountTokenInputObject' when calling requestNewSubaccountToken(Async)");
        }
        

        com.squareup.okhttp.Call call = requestNewSubaccountTokenCall(requestNewSubaccountTokenInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Request a new REST API token for sub-account
     * Returning user object, key and app name.
     * @param requestNewSubaccountTokenInputObject  (required)
     * @return User
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public User requestNewSubaccountToken(RequestNewSubaccountTokenInputObject requestNewSubaccountTokenInputObject) throws ApiException {
        ApiResponse resp = requestNewSubaccountTokenWithHttpInfo(requestNewSubaccountTokenInputObject);
        return resp.getData();
    }

    /**
     * Request a new REST API token for sub-account
     * Returning user object, key and app name.
     * @param requestNewSubaccountTokenInputObject  (required)
     * @return ApiResponse<User>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse requestNewSubaccountTokenWithHttpInfo(RequestNewSubaccountTokenInputObject requestNewSubaccountTokenInputObject) throws ApiException {
        com.squareup.okhttp.Call call = requestNewSubaccountTokenValidateBeforeCall(requestNewSubaccountTokenInputObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Request a new REST API token for sub-account (asynchronously)
     * Returning user object, key and app name.
     * @param requestNewSubaccountTokenInputObject  (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 requestNewSubaccountTokenAsync(RequestNewSubaccountTokenInputObject requestNewSubaccountTokenInputObject, final ApiCallback 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 = requestNewSubaccountTokenValidateBeforeCall(requestNewSubaccountTokenInputObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for requestSenderId
     * @param requestSenderIdInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call requestSenderIdCall(RequestSenderIdInputObject requestSenderIdInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = requestSenderIdInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/senderids";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call requestSenderIdValidateBeforeCall(RequestSenderIdInputObject requestSenderIdInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'requestSenderIdInputObject' is set
        if (requestSenderIdInputObject == null) {
            throw new ApiException("Missing the required parameter 'requestSenderIdInputObject' when calling requestSenderId(Async)");
        }
        

        com.squareup.okhttp.Call call = requestSenderIdCall(requestSenderIdInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Apply for a new Sender ID
     * > Sender IDs are shared among all of your sub-accounts.
     * @param requestSenderIdInputObject  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse requestSenderId(RequestSenderIdInputObject requestSenderIdInputObject) throws ApiException {
        ApiResponse resp = requestSenderIdWithHttpInfo(requestSenderIdInputObject);
        return resp.getData();
    }

    /**
     * Apply for a new Sender ID
     * > Sender IDs are shared among all of your sub-accounts.
     * @param requestSenderIdInputObject  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse requestSenderIdWithHttpInfo(RequestSenderIdInputObject requestSenderIdInputObject) throws ApiException {
        com.squareup.okhttp.Call call = requestSenderIdValidateBeforeCall(requestSenderIdInputObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Apply for a new Sender ID (asynchronously)
     * > Sender IDs are shared among all of your sub-accounts.
     * @param requestSenderIdInputObject  (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 requestSenderIdAsync(RequestSenderIdInputObject requestSenderIdInputObject, final ApiCallback 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 = requestSenderIdValidateBeforeCall(requestSenderIdInputObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for searchChats
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find chats by specified search query. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call searchChatsCall(Integer page, Integer limit, String query, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/chats/search";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call searchChatsValidateBeforeCall(Integer page, Integer limit, String query, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = searchChatsCall(page, limit, query, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Find chats by message text
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find chats by specified search query. (optional)
     * @return SearchChatsPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public SearchChatsPaginatedResponse searchChats(Integer page, Integer limit, String query) throws ApiException {
        ApiResponse resp = searchChatsWithHttpInfo(page, limit, query);
        return resp.getData();
    }

    /**
     * Find chats by message text
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find chats by specified search query. (optional)
     * @return ApiResponse<SearchChatsPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse searchChatsWithHttpInfo(Integer page, Integer limit, String query) throws ApiException {
        com.squareup.okhttp.Call call = searchChatsValidateBeforeCall(page, limit, query, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Find chats by message text (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find chats by specified search query. (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 searchChatsAsync(Integer page, Integer limit, String query, final ApiCallback 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 = searchChatsValidateBeforeCall(page, limit, query, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for searchChatsByIds
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find chats by ID(s). (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call searchChatsByIdsCall(Integer page, Integer limit, String ids, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/chats/search/ids";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (ids != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("ids", ids));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call searchChatsByIdsValidateBeforeCall(Integer page, Integer limit, String ids, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = searchChatsByIdsCall(page, limit, ids, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Find chats (bulk)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find chats by ID(s). (optional)
     * @return SearchChatsByIdsPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public SearchChatsByIdsPaginatedResponse searchChatsByIds(Integer page, Integer limit, String ids) throws ApiException {
        ApiResponse resp = searchChatsByIdsWithHttpInfo(page, limit, ids);
        return resp.getData();
    }

    /**
     * Find chats (bulk)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find chats by ID(s). (optional)
     * @return ApiResponse<SearchChatsByIdsPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse searchChatsByIdsWithHttpInfo(Integer page, Integer limit, String ids) throws ApiException {
        com.squareup.okhttp.Call call = searchChatsByIdsValidateBeforeCall(page, limit, ids, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Find chats (bulk) (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find chats by ID(s). (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 searchChatsByIdsAsync(Integer page, Integer limit, String ids, final ApiCallback 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 = searchChatsByIdsValidateBeforeCall(page, limit, ids, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for searchChatsByReceipent
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find chats by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call searchChatsByReceipentCall(Integer page, Integer limit, String query, String orderBy, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/chats/search/recipients";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));
        if (orderBy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("orderBy", orderBy));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call searchChatsByReceipentValidateBeforeCall(Integer page, Integer limit, String query, String orderBy, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = searchChatsByReceipentCall(page, limit, query, orderBy, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Find chats by recipient
     * Find chats by recipient (contact, list name or phone number).
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find chats by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @return SearchChatsByReceipentPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public SearchChatsByReceipentPaginatedResponse searchChatsByReceipent(Integer page, Integer limit, String query, String orderBy) throws ApiException {
        ApiResponse resp = searchChatsByReceipentWithHttpInfo(page, limit, query, orderBy);
        return resp.getData();
    }

    /**
     * Find chats by recipient
     * Find chats by recipient (contact, list name or phone number).
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find chats by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @return ApiResponse<SearchChatsByReceipentPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse searchChatsByReceipentWithHttpInfo(Integer page, Integer limit, String query, String orderBy) throws ApiException {
        com.squareup.okhttp.Call call = searchChatsByReceipentValidateBeforeCall(page, limit, query, orderBy, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Find chats by recipient (asynchronously)
     * Find chats by recipient (contact, list name or phone number).
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find chats by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @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 searchChatsByReceipentAsync(Integer page, Integer limit, String query, String orderBy, final ApiCallback 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 = searchChatsByReceipentValidateBeforeCall(page, limit, query, orderBy, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for searchContacts
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param shared Should shared contacts be included? (optional, default to 0)
     * @param ids Find contacts by IDs. (optional)
     * @param listId Find contacts by List ID. (optional)
     * @param includeBlocked Should blocked contacts be included? (optional)
     * @param query Find contacts by specified search query. (optional)
     * @param local Treat phone number passed in the \"query\" field as local. Default is 0. (optional, default to 0)
     * @param country The 2-letter ISO country code for local phone numbers, used when \"local\" is set to true. Default is the account country. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call searchContactsCall(Integer page, Integer limit, Integer shared, String ids, Integer listId, Integer includeBlocked, String query, Integer local, String country, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/search";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (shared != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("shared", shared));
        if (ids != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("ids", ids));
        if (listId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("listId", listId));
        if (includeBlocked != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("includeBlocked", includeBlocked));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));
        if (local != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("local", local));
        if (country != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("country", country));
        if (orderBy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("orderBy", orderBy));
        if (direction != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("direction", direction));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call searchContactsValidateBeforeCall(Integer page, Integer limit, Integer shared, String ids, Integer listId, Integer includeBlocked, String query, Integer local, String country, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = searchContactsCall(page, limit, shared, ids, listId, includeBlocked, query, local, country, orderBy, direction, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Find contacts by given criteria
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param shared Should shared contacts be included? (optional, default to 0)
     * @param ids Find contacts by IDs. (optional)
     * @param listId Find contacts by List ID. (optional)
     * @param includeBlocked Should blocked contacts be included? (optional)
     * @param query Find contacts by specified search query. (optional)
     * @param local Treat phone number passed in the \"query\" field as local. Default is 0. (optional, default to 0)
     * @param country The 2-letter ISO country code for local phone numbers, used when \"local\" is set to true. Default is the account country. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return SearchContactsPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public SearchContactsPaginatedResponse searchContacts(Integer page, Integer limit, Integer shared, String ids, Integer listId, Integer includeBlocked, String query, Integer local, String country, String orderBy, String direction) throws ApiException {
        ApiResponse resp = searchContactsWithHttpInfo(page, limit, shared, ids, listId, includeBlocked, query, local, country, orderBy, direction);
        return resp.getData();
    }

    /**
     * Find contacts by given criteria
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param shared Should shared contacts be included? (optional, default to 0)
     * @param ids Find contacts by IDs. (optional)
     * @param listId Find contacts by List ID. (optional)
     * @param includeBlocked Should blocked contacts be included? (optional)
     * @param query Find contacts by specified search query. (optional)
     * @param local Treat phone number passed in the \"query\" field as local. Default is 0. (optional, default to 0)
     * @param country The 2-letter ISO country code for local phone numbers, used when \"local\" is set to true. Default is the account country. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return ApiResponse<SearchContactsPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse searchContactsWithHttpInfo(Integer page, Integer limit, Integer shared, String ids, Integer listId, Integer includeBlocked, String query, Integer local, String country, String orderBy, String direction) throws ApiException {
        com.squareup.okhttp.Call call = searchContactsValidateBeforeCall(page, limit, shared, ids, listId, includeBlocked, query, local, country, orderBy, direction, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Find contacts by given criteria (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param shared Should shared contacts be included? (optional, default to 0)
     * @param ids Find contacts by IDs. (optional)
     * @param listId Find contacts by List ID. (optional)
     * @param includeBlocked Should blocked contacts be included? (optional)
     * @param query Find contacts by specified search query. (optional)
     * @param local Treat phone number passed in the \"query\" field as local. Default is 0. (optional, default to 0)
     * @param country The 2-letter ISO country code for local phone numbers, used when \"local\" is set to true. Default is the account country. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @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 searchContactsAsync(Integer page, Integer limit, Integer shared, String ids, Integer listId, Integer includeBlocked, String query, Integer local, String country, String orderBy, String direction, final ApiCallback 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 = searchContactsValidateBeforeCall(page, limit, shared, ids, listId, includeBlocked, query, local, country, orderBy, direction, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for searchInboundMessages
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find message by ID(s). (optional)
     * @param query Find recipients by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param expand Expand by adding firstName, lastName and contactId. (optional, default to 0)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call searchInboundMessagesCall(Integer page, Integer limit, String ids, String query, String orderBy, String direction, Integer expand, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/replies/search";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (ids != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("ids", ids));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));
        if (orderBy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("orderBy", orderBy));
        if (direction != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("direction", direction));
        if (expand != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("expand", expand));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call searchInboundMessagesValidateBeforeCall(Integer page, Integer limit, String ids, String query, String orderBy, String direction, Integer expand, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = searchInboundMessagesCall(page, limit, ids, query, orderBy, direction, expand, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Find inbound messages
     * Find inbound messages by given parameters.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find message by ID(s). (optional)
     * @param query Find recipients by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param expand Expand by adding firstName, lastName and contactId. (optional, default to 0)
     * @return SearchInboundMessagesPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public SearchInboundMessagesPaginatedResponse searchInboundMessages(Integer page, Integer limit, String ids, String query, String orderBy, String direction, Integer expand) throws ApiException {
        ApiResponse resp = searchInboundMessagesWithHttpInfo(page, limit, ids, query, orderBy, direction, expand);
        return resp.getData();
    }

    /**
     * Find inbound messages
     * Find inbound messages by given parameters.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find message by ID(s). (optional)
     * @param query Find recipients by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param expand Expand by adding firstName, lastName and contactId. (optional, default to 0)
     * @return ApiResponse<SearchInboundMessagesPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse searchInboundMessagesWithHttpInfo(Integer page, Integer limit, String ids, String query, String orderBy, String direction, Integer expand) throws ApiException {
        com.squareup.okhttp.Call call = searchInboundMessagesValidateBeforeCall(page, limit, ids, query, orderBy, direction, expand, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Find inbound messages (asynchronously)
     * Find inbound messages by given parameters.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find message by ID(s). (optional)
     * @param query Find recipients by specified search query. (optional)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param expand Expand by adding firstName, lastName and contactId. (optional, default to 0)
     * @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 searchInboundMessagesAsync(Integer page, Integer limit, String ids, String query, String orderBy, String direction, Integer expand, final ApiCallback 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 = searchInboundMessagesValidateBeforeCall(page, limit, ids, query, orderBy, direction, expand, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for searchLists
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find lists by IDs. (optional)
     * @param query Find lists by specified search query. (optional)
     * @param onlyMine Return only current user lists. (optional, default to 0)
     * @param onlyDefault Return only default lists. (optional, default to 0)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call searchListsCall(Integer page, Integer limit, String ids, String query, Integer onlyMine, Integer onlyDefault, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/lists/search";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (ids != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("ids", ids));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));
        if (onlyMine != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("onlyMine", onlyMine));
        if (onlyDefault != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("onlyDefault", onlyDefault));
        if (orderBy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("orderBy", orderBy));
        if (direction != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("direction", direction));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call searchListsValidateBeforeCall(Integer page, Integer limit, String ids, String query, Integer onlyMine, Integer onlyDefault, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = searchListsCall(page, limit, ids, query, onlyMine, onlyDefault, orderBy, direction, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Find lists by given criteria
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find lists by IDs. (optional)
     * @param query Find lists by specified search query. (optional)
     * @param onlyMine Return only current user lists. (optional, default to 0)
     * @param onlyDefault Return only default lists. (optional, default to 0)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return SearchListsPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public SearchListsPaginatedResponse searchLists(Integer page, Integer limit, String ids, String query, Integer onlyMine, Integer onlyDefault, String orderBy, String direction) throws ApiException {
        ApiResponse resp = searchListsWithHttpInfo(page, limit, ids, query, onlyMine, onlyDefault, orderBy, direction);
        return resp.getData();
    }

    /**
     * Find lists by given criteria
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find lists by IDs. (optional)
     * @param query Find lists by specified search query. (optional)
     * @param onlyMine Return only current user lists. (optional, default to 0)
     * @param onlyDefault Return only default lists. (optional, default to 0)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return ApiResponse<SearchListsPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse searchListsWithHttpInfo(Integer page, Integer limit, String ids, String query, Integer onlyMine, Integer onlyDefault, String orderBy, String direction) throws ApiException {
        com.squareup.okhttp.Call call = searchListsValidateBeforeCall(page, limit, ids, query, onlyMine, onlyDefault, orderBy, direction, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Find lists by given criteria (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find lists by IDs. (optional)
     * @param query Find lists by specified search query. (optional)
     * @param onlyMine Return only current user lists. (optional, default to 0)
     * @param onlyDefault Return only default lists. (optional, default to 0)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @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 searchListsAsync(Integer page, Integer limit, String ids, String query, Integer onlyMine, Integer onlyDefault, String orderBy, String direction, final ApiCallback 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 = searchListsValidateBeforeCall(page, limit, ids, query, onlyMine, onlyDefault, orderBy, direction, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for searchOutboundMessages
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param lastId Filter results by ID, selecting all values lesser than the specified ID. Note that the \\'page\\' parameter is ignored when \\'lastId\\' is specified. (optional)
     * @param ids Find message by ID(s). (optional)
     * @param sessionId Find messages by session ID. (optional)
     * @param statuses Find messages by status. (optional)
     * @param includeDeleted Search also in deleted messages. (optional, default to 0)
     * @param query Find messages by specified search query. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call searchOutboundMessagesCall(Integer page, Integer limit, Integer lastId, String ids, Integer sessionId, String statuses, Integer includeDeleted, String query, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/messages/search";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (lastId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("lastId", lastId));
        if (ids != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("ids", ids));
        if (sessionId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("sessionId", sessionId));
        if (statuses != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("statuses", statuses));
        if (includeDeleted != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("includeDeleted", includeDeleted));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call searchOutboundMessagesValidateBeforeCall(Integer page, Integer limit, Integer lastId, String ids, Integer sessionId, String statuses, Integer includeDeleted, String query, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = searchOutboundMessagesCall(page, limit, lastId, ids, sessionId, statuses, includeDeleted, query, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Find messages
     * Find outbound messages by given parameters.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param lastId Filter results by ID, selecting all values lesser than the specified ID. Note that the \\'page\\' parameter is ignored when \\'lastId\\' is specified. (optional)
     * @param ids Find message by ID(s). (optional)
     * @param sessionId Find messages by session ID. (optional)
     * @param statuses Find messages by status. (optional)
     * @param includeDeleted Search also in deleted messages. (optional, default to 0)
     * @param query Find messages by specified search query. (optional)
     * @return SearchOutboundMessagesPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public SearchOutboundMessagesPaginatedResponse searchOutboundMessages(Integer page, Integer limit, Integer lastId, String ids, Integer sessionId, String statuses, Integer includeDeleted, String query) throws ApiException {
        ApiResponse resp = searchOutboundMessagesWithHttpInfo(page, limit, lastId, ids, sessionId, statuses, includeDeleted, query);
        return resp.getData();
    }

    /**
     * Find messages
     * Find outbound messages by given parameters.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param lastId Filter results by ID, selecting all values lesser than the specified ID. Note that the \\'page\\' parameter is ignored when \\'lastId\\' is specified. (optional)
     * @param ids Find message by ID(s). (optional)
     * @param sessionId Find messages by session ID. (optional)
     * @param statuses Find messages by status. (optional)
     * @param includeDeleted Search also in deleted messages. (optional, default to 0)
     * @param query Find messages by specified search query. (optional)
     * @return ApiResponse<SearchOutboundMessagesPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse searchOutboundMessagesWithHttpInfo(Integer page, Integer limit, Integer lastId, String ids, Integer sessionId, String statuses, Integer includeDeleted, String query) throws ApiException {
        com.squareup.okhttp.Call call = searchOutboundMessagesValidateBeforeCall(page, limit, lastId, ids, sessionId, statuses, includeDeleted, query, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Find messages (asynchronously)
     * Find outbound messages by given parameters.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param lastId Filter results by ID, selecting all values lesser than the specified ID. Note that the \\'page\\' parameter is ignored when \\'lastId\\' is specified. (optional)
     * @param ids Find message by ID(s). (optional)
     * @param sessionId Find messages by session ID. (optional)
     * @param statuses Find messages by status. (optional)
     * @param includeDeleted Search also in deleted messages. (optional, default to 0)
     * @param query Find messages by specified search query. (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 searchOutboundMessagesAsync(Integer page, Integer limit, Integer lastId, String ids, Integer sessionId, String statuses, Integer includeDeleted, String query, final ApiCallback 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 = searchOutboundMessagesValidateBeforeCall(page, limit, lastId, ids, sessionId, statuses, includeDeleted, query, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for searchScheduledMessages
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find messages by specified search query. (optional)
     * @param ids Find schedules by ID(s). (optional)
     * @param status Fetch schedules with a specific status: a - actual, c - completed, x - all. (optional, default to x)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call searchScheduledMessagesCall(Integer page, Integer limit, String query, String ids, String status, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/schedules/search";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));
        if (ids != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("ids", ids));
        if (status != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("status", status));
        if (orderBy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("orderBy", orderBy));
        if (direction != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("direction", direction));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call searchScheduledMessagesValidateBeforeCall(Integer page, Integer limit, String query, String ids, String status, String orderBy, String direction, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = searchScheduledMessagesCall(page, limit, query, ids, status, orderBy, direction, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Find scheduled messages
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find messages by specified search query. (optional)
     * @param ids Find schedules by ID(s). (optional)
     * @param status Fetch schedules with a specific status: a - actual, c - completed, x - all. (optional, default to x)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return SearchScheduledMessagesPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public SearchScheduledMessagesPaginatedResponse searchScheduledMessages(Integer page, Integer limit, String query, String ids, String status, String orderBy, String direction) throws ApiException {
        ApiResponse resp = searchScheduledMessagesWithHttpInfo(page, limit, query, ids, status, orderBy, direction);
        return resp.getData();
    }

    /**
     * Find scheduled messages
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find messages by specified search query. (optional)
     * @param ids Find schedules by ID(s). (optional)
     * @param status Fetch schedules with a specific status: a - actual, c - completed, x - all. (optional, default to x)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @return ApiResponse<SearchScheduledMessagesPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse searchScheduledMessagesWithHttpInfo(Integer page, Integer limit, String query, String ids, String status, String orderBy, String direction) throws ApiException {
        com.squareup.okhttp.Call call = searchScheduledMessagesValidateBeforeCall(page, limit, query, ids, status, orderBy, direction, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Find scheduled messages (asynchronously)
     * 
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param query Find messages by specified search query. (optional)
     * @param ids Find schedules by ID(s). (optional)
     * @param status Fetch schedules with a specific status: a - actual, c - completed, x - all. (optional, default to x)
     * @param orderBy Order results by some field. Default is id. (optional, default to id)
     * @param direction Order direction. Default is desc. (optional, default to desc)
     * @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 searchScheduledMessagesAsync(Integer page, Integer limit, String query, String ids, String status, String orderBy, String direction, final ApiCallback 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 = searchScheduledMessagesValidateBeforeCall(page, limit, query, ids, status, orderBy, direction, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for searchTemplates
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find template by ID(s). (optional)
     * @param name Find template by name. (optional)
     * @param content Find template by content. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call searchTemplatesCall(Integer page, Integer limit, String ids, String name, String content, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/templates/search";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (page != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("page", page));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (ids != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("ids", ids));
        if (name != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("name", name));
        if (content != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("content", content));

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call searchTemplatesValidateBeforeCall(Integer page, Integer limit, String ids, String name, String content, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = searchTemplatesCall(page, limit, ids, name, content, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Find templates by criteria
     * Find user templates by given parameters.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find template by ID(s). (optional)
     * @param name Find template by name. (optional)
     * @param content Find template by content. (optional)
     * @return SearchTemplatesPaginatedResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public SearchTemplatesPaginatedResponse searchTemplates(Integer page, Integer limit, String ids, String name, String content) throws ApiException {
        ApiResponse resp = searchTemplatesWithHttpInfo(page, limit, ids, name, content);
        return resp.getData();
    }

    /**
     * Find templates by criteria
     * Find user templates by given parameters.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find template by ID(s). (optional)
     * @param name Find template by name. (optional)
     * @param content Find template by content. (optional)
     * @return ApiResponse<SearchTemplatesPaginatedResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse searchTemplatesWithHttpInfo(Integer page, Integer limit, String ids, String name, String content) throws ApiException {
        com.squareup.okhttp.Call call = searchTemplatesValidateBeforeCall(page, limit, ids, name, content, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Find templates by criteria (asynchronously)
     * Find user templates by given parameters.
     * @param page Fetch specified results page. (optional, default to 1)
     * @param limit The number of results per page. (optional, default to 10)
     * @param ids Find template by ID(s). (optional)
     * @param name Find template by name. (optional)
     * @param content Find template by content. (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 searchTemplatesAsync(Integer page, Integer limit, String ids, String name, String content, final ApiCallback 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 = searchTemplatesValidateBeforeCall(page, limit, ids, name, content, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for sendMessage
     * @param sendMessageInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call sendMessageCall(SendMessageInputObject sendMessageInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = sendMessageInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/messages";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call sendMessageValidateBeforeCall(SendMessageInputObject sendMessageInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'sendMessageInputObject' is set
        if (sendMessageInputObject == null) {
            throw new ApiException("Missing the required parameter 'sendMessageInputObject' when calling sendMessage(Async)");
        }
        

        com.squareup.okhttp.Call call = sendMessageCall(sendMessageInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Send message
     * This is the main entrypoint to send messages. See the examples above for the reference.
     * @param sendMessageInputObject  (required)
     * @return SendMessageResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public SendMessageResponse sendMessage(SendMessageInputObject sendMessageInputObject) throws ApiException {
        ApiResponse resp = sendMessageWithHttpInfo(sendMessageInputObject);
        return resp.getData();
    }

    /**
     * Send message
     * This is the main entrypoint to send messages. See the examples above for the reference.
     * @param sendMessageInputObject  (required)
     * @return ApiResponse<SendMessageResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse sendMessageWithHttpInfo(SendMessageInputObject sendMessageInputObject) throws ApiException {
        com.squareup.okhttp.Call call = sendMessageValidateBeforeCall(sendMessageInputObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Send message (asynchronously)
     * This is the main entrypoint to send messages. See the examples above for the reference.
     * @param sendMessageInputObject  (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 sendMessageAsync(SendMessageInputObject sendMessageInputObject, final ApiCallback 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 = sendMessageValidateBeforeCall(sendMessageInputObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for sendPhoneVerificationCodeTFA
     * @param sendPhoneVerificationCodeInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call sendPhoneVerificationCodeTFACall(SendPhoneVerificationCodeInputObject sendPhoneVerificationCodeInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = sendPhoneVerificationCodeInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/verify";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call sendPhoneVerificationCodeTFAValidateBeforeCall(SendPhoneVerificationCodeInputObject sendPhoneVerificationCodeInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'sendPhoneVerificationCodeInputObject' is set
        if (sendPhoneVerificationCodeInputObject == null) {
            throw new ApiException("Missing the required parameter 'sendPhoneVerificationCodeInputObject' when calling sendPhoneVerificationCodeTFA(Async)");
        }
        

        com.squareup.okhttp.Call call = sendPhoneVerificationCodeTFACall(sendPhoneVerificationCodeInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Step 1: Send a verification code 
     * Sends a verification code to a specified phone number.
     * @param sendPhoneVerificationCodeInputObject  (required)
     * @return SendPhoneVerificationCodeResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public SendPhoneVerificationCodeResponse sendPhoneVerificationCodeTFA(SendPhoneVerificationCodeInputObject sendPhoneVerificationCodeInputObject) throws ApiException {
        ApiResponse resp = sendPhoneVerificationCodeTFAWithHttpInfo(sendPhoneVerificationCodeInputObject);
        return resp.getData();
    }

    /**
     * Step 1: Send a verification code 
     * Sends a verification code to a specified phone number.
     * @param sendPhoneVerificationCodeInputObject  (required)
     * @return ApiResponse<SendPhoneVerificationCodeResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse sendPhoneVerificationCodeTFAWithHttpInfo(SendPhoneVerificationCodeInputObject sendPhoneVerificationCodeInputObject) throws ApiException {
        com.squareup.okhttp.Call call = sendPhoneVerificationCodeTFAValidateBeforeCall(sendPhoneVerificationCodeInputObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Step 1: Send a verification code  (asynchronously)
     * Sends a verification code to a specified phone number.
     * @param sendPhoneVerificationCodeInputObject  (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 sendPhoneVerificationCodeTFAAsync(SendPhoneVerificationCodeInputObject sendPhoneVerificationCodeInputObject, final ApiCallback 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 = sendPhoneVerificationCodeTFAValidateBeforeCall(sendPhoneVerificationCodeInputObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for setChatStatus
     * @param setChatStatusInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call setChatStatusCall(SetChatStatusInputObject setChatStatusInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = setChatStatusInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/chats/status";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call setChatStatusValidateBeforeCall(SetChatStatusInputObject setChatStatusInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'setChatStatusInputObject' is set
        if (setChatStatusInputObject == null) {
            throw new ApiException("Missing the required parameter 'setChatStatusInputObject' when calling setChatStatus(Async)");
        }
        

        com.squareup.okhttp.Call call = setChatStatusCall(setChatStatusInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Change chat status
     * Set the status of the chat given by ID.
     * @param setChatStatusInputObject  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse setChatStatus(SetChatStatusInputObject setChatStatusInputObject) throws ApiException {
        ApiResponse resp = setChatStatusWithHttpInfo(setChatStatusInputObject);
        return resp.getData();
    }

    /**
     * Change chat status
     * Set the status of the chat given by ID.
     * @param setChatStatusInputObject  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse setChatStatusWithHttpInfo(SetChatStatusInputObject setChatStatusInputObject) throws ApiException {
        com.squareup.okhttp.Call call = setChatStatusValidateBeforeCall(setChatStatusInputObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Change chat status (asynchronously)
     * Set the status of the chat given by ID.
     * @param setChatStatusInputObject  (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 setChatStatusAsync(SetChatStatusInputObject setChatStatusInputObject, final ApiCallback 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 = setChatStatusValidateBeforeCall(setChatStatusInputObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for unblockContact
     * @param unblockContactInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call unblockContactCall(UnblockContactInputObject unblockContactInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = unblockContactInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/unblock";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call unblockContactValidateBeforeCall(UnblockContactInputObject unblockContactInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'unblockContactInputObject' is set
        if (unblockContactInputObject == null) {
            throw new ApiException("Missing the required parameter 'unblockContactInputObject' when calling unblockContact(Async)");
        }
        

        com.squareup.okhttp.Call call = unblockContactCall(unblockContactInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Unblock a contact by phone number
     * Unblock a contact by phone number
     * @param unblockContactInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void unblockContact(UnblockContactInputObject unblockContactInputObject) throws ApiException {
        unblockContactWithHttpInfo(unblockContactInputObject);
    }

    /**
     * Unblock a contact by phone number
     * Unblock a contact by phone number
     * @param unblockContactInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse unblockContactWithHttpInfo(UnblockContactInputObject unblockContactInputObject) throws ApiException {
        com.squareup.okhttp.Call call = unblockContactValidateBeforeCall(unblockContactInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Unblock a contact by phone number (asynchronously)
     * Unblock a contact by phone number
     * @param unblockContactInputObject  (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 unblockContactAsync(UnblockContactInputObject unblockContactInputObject, final ApiCallback 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 = unblockContactValidateBeforeCall(unblockContactInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for unblockContactsBulk
     * @param unblockContactsBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call unblockContactsBulkCall(UnblockContactsBulkInputObject unblockContactsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = unblockContactsBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/unblock/bulk";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call unblockContactsBulkValidateBeforeCall(UnblockContactsBulkInputObject unblockContactsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'unblockContactsBulkInputObject' is set
        if (unblockContactsBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'unblockContactsBulkInputObject' when calling unblockContactsBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = unblockContactsBulkCall(unblockContactsBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Unblock contacts (bulk)
     * Unblock several contacts by blocked contact IDs or unblock all contacts.
     * @param unblockContactsBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void unblockContactsBulk(UnblockContactsBulkInputObject unblockContactsBulkInputObject) throws ApiException {
        unblockContactsBulkWithHttpInfo(unblockContactsBulkInputObject);
    }

    /**
     * Unblock contacts (bulk)
     * Unblock several contacts by blocked contact IDs or unblock all contacts.
     * @param unblockContactsBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse unblockContactsBulkWithHttpInfo(UnblockContactsBulkInputObject unblockContactsBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = unblockContactsBulkValidateBeforeCall(unblockContactsBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Unblock contacts (bulk) (asynchronously)
     * Unblock several contacts by blocked contact IDs or unblock all contacts.
     * @param unblockContactsBulkInputObject  (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 unblockContactsBulkAsync(UnblockContactsBulkInputObject unblockContactsBulkInputObject, final ApiCallback 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 = unblockContactsBulkValidateBeforeCall(unblockContactsBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for unmuteChatsBulk
     * @param unmuteChatsBulkInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call unmuteChatsBulkCall(UnmuteChatsBulkInputObject unmuteChatsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = unmuteChatsBulkInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/chats/unmute/bulk";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call unmuteChatsBulkValidateBeforeCall(UnmuteChatsBulkInputObject unmuteChatsBulkInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'unmuteChatsBulkInputObject' is set
        if (unmuteChatsBulkInputObject == null) {
            throw new ApiException("Missing the required parameter 'unmuteChatsBulkInputObject' when calling unmuteChatsBulk(Async)");
        }
        

        com.squareup.okhttp.Call call = unmuteChatsBulkCall(unmuteChatsBulkInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Unmute chats (bulk)
     * Unmute several chats by chat ids or unmute all chats.
     * @param unmuteChatsBulkInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void unmuteChatsBulk(UnmuteChatsBulkInputObject unmuteChatsBulkInputObject) throws ApiException {
        unmuteChatsBulkWithHttpInfo(unmuteChatsBulkInputObject);
    }

    /**
     * Unmute chats (bulk)
     * Unmute several chats by chat ids or unmute all chats.
     * @param unmuteChatsBulkInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse unmuteChatsBulkWithHttpInfo(UnmuteChatsBulkInputObject unmuteChatsBulkInputObject) throws ApiException {
        com.squareup.okhttp.Call call = unmuteChatsBulkValidateBeforeCall(unmuteChatsBulkInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Unmute chats (bulk) (asynchronously)
     * Unmute several chats by chat ids or unmute all chats.
     * @param unmuteChatsBulkInputObject  (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 unmuteChatsBulkAsync(UnmuteChatsBulkInputObject unmuteChatsBulkInputObject, final ApiCallback 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 = unmuteChatsBulkValidateBeforeCall(unmuteChatsBulkInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for unsubscribeContact
     * @param unsubscribeContactInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call unsubscribeContactCall(UnsubscribeContactInputObject unsubscribeContactInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = unsubscribeContactInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/unsubscribers";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call unsubscribeContactValidateBeforeCall(UnsubscribeContactInputObject unsubscribeContactInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'unsubscribeContactInputObject' is set
        if (unsubscribeContactInputObject == null) {
            throw new ApiException("Missing the required parameter 'unsubscribeContactInputObject' when calling unsubscribeContact(Async)");
        }
        

        com.squareup.okhttp.Call call = unsubscribeContactCall(unsubscribeContactInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Manually unsubscribe a contact
     * > Please note, if you unsubscribe a contact, this action cannot be reversed. 
     * @param unsubscribeContactInputObject  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse unsubscribeContact(UnsubscribeContactInputObject unsubscribeContactInputObject) throws ApiException {
        ApiResponse resp = unsubscribeContactWithHttpInfo(unsubscribeContactInputObject);
        return resp.getData();
    }

    /**
     * Manually unsubscribe a contact
     * > Please note, if you unsubscribe a contact, this action cannot be reversed. 
     * @param unsubscribeContactInputObject  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse unsubscribeContactWithHttpInfo(UnsubscribeContactInputObject unsubscribeContactInputObject) throws ApiException {
        com.squareup.okhttp.Call call = unsubscribeContactValidateBeforeCall(unsubscribeContactInputObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Manually unsubscribe a contact (asynchronously)
     * > Please note, if you unsubscribe a contact, this action cannot be reversed. 
     * @param unsubscribeContactInputObject  (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 unsubscribeContactAsync(UnsubscribeContactInputObject unsubscribeContactInputObject, final ApiCallback 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 = unsubscribeContactValidateBeforeCall(unsubscribeContactInputObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for updateBalanceNotificationSettings
     * @param updateBalanceNotificationSettingsInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call updateBalanceNotificationSettingsCall(UpdateBalanceNotificationSettingsInputObject updateBalanceNotificationSettingsInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = updateBalanceNotificationSettingsInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/user/notification/balance";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call updateBalanceNotificationSettingsValidateBeforeCall(UpdateBalanceNotificationSettingsInputObject updateBalanceNotificationSettingsInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'updateBalanceNotificationSettingsInputObject' is set
        if (updateBalanceNotificationSettingsInputObject == null) {
            throw new ApiException("Missing the required parameter 'updateBalanceNotificationSettingsInputObject' when calling updateBalanceNotificationSettings(Async)");
        }
        

        com.squareup.okhttp.Call call = updateBalanceNotificationSettingsCall(updateBalanceNotificationSettingsInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Update balance notification settings
     * 
     * @param updateBalanceNotificationSettingsInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void updateBalanceNotificationSettings(UpdateBalanceNotificationSettingsInputObject updateBalanceNotificationSettingsInputObject) throws ApiException {
        updateBalanceNotificationSettingsWithHttpInfo(updateBalanceNotificationSettingsInputObject);
    }

    /**
     * Update balance notification settings
     * 
     * @param updateBalanceNotificationSettingsInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse updateBalanceNotificationSettingsWithHttpInfo(UpdateBalanceNotificationSettingsInputObject updateBalanceNotificationSettingsInputObject) throws ApiException {
        com.squareup.okhttp.Call call = updateBalanceNotificationSettingsValidateBeforeCall(updateBalanceNotificationSettingsInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Update balance notification settings (asynchronously)
     * 
     * @param updateBalanceNotificationSettingsInputObject  (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 updateBalanceNotificationSettingsAsync(UpdateBalanceNotificationSettingsInputObject updateBalanceNotificationSettingsInputObject, final ApiCallback 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 = updateBalanceNotificationSettingsValidateBeforeCall(updateBalanceNotificationSettingsInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for updateCallbackSettings
     * @param updateCallbackSettingsInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call updateCallbackSettingsCall(UpdateCallbackSettingsInputObject updateCallbackSettingsInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = updateCallbackSettingsInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/callback/settings";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call updateCallbackSettingsValidateBeforeCall(UpdateCallbackSettingsInputObject updateCallbackSettingsInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'updateCallbackSettingsInputObject' is set
        if (updateCallbackSettingsInputObject == null) {
            throw new ApiException("Missing the required parameter 'updateCallbackSettingsInputObject' when calling updateCallbackSettings(Async)");
        }
        

        com.squareup.okhttp.Call call = updateCallbackSettingsCall(updateCallbackSettingsInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Update callback URL settings
     * 
     * @param updateCallbackSettingsInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void updateCallbackSettings(UpdateCallbackSettingsInputObject updateCallbackSettingsInputObject) throws ApiException {
        updateCallbackSettingsWithHttpInfo(updateCallbackSettingsInputObject);
    }

    /**
     * Update callback URL settings
     * 
     * @param updateCallbackSettingsInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse updateCallbackSettingsWithHttpInfo(UpdateCallbackSettingsInputObject updateCallbackSettingsInputObject) throws ApiException {
        com.squareup.okhttp.Call call = updateCallbackSettingsValidateBeforeCall(updateCallbackSettingsInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Update callback URL settings (asynchronously)
     * 
     * @param updateCallbackSettingsInputObject  (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 updateCallbackSettingsAsync(UpdateCallbackSettingsInputObject updateCallbackSettingsInputObject, final ApiCallback 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 = updateCallbackSettingsValidateBeforeCall(updateCallbackSettingsInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for updateChatDesktopNotificationSettings
     * @param updateChatDesktopNotificationSettingsInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call updateChatDesktopNotificationSettingsCall(UpdateChatDesktopNotificationSettingsInputObject updateChatDesktopNotificationSettingsInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = updateChatDesktopNotificationSettingsInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/user/desktop/notification";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call updateChatDesktopNotificationSettingsValidateBeforeCall(UpdateChatDesktopNotificationSettingsInputObject updateChatDesktopNotificationSettingsInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'updateChatDesktopNotificationSettingsInputObject' is set
        if (updateChatDesktopNotificationSettingsInputObject == null) {
            throw new ApiException("Missing the required parameter 'updateChatDesktopNotificationSettingsInputObject' when calling updateChatDesktopNotificationSettings(Async)");
        }
        

        com.squareup.okhttp.Call call = updateChatDesktopNotificationSettingsCall(updateChatDesktopNotificationSettingsInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Update chat desktop notification settings
     * 
     * @param updateChatDesktopNotificationSettingsInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void updateChatDesktopNotificationSettings(UpdateChatDesktopNotificationSettingsInputObject updateChatDesktopNotificationSettingsInputObject) throws ApiException {
        updateChatDesktopNotificationSettingsWithHttpInfo(updateChatDesktopNotificationSettingsInputObject);
    }

    /**
     * Update chat desktop notification settings
     * 
     * @param updateChatDesktopNotificationSettingsInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse updateChatDesktopNotificationSettingsWithHttpInfo(UpdateChatDesktopNotificationSettingsInputObject updateChatDesktopNotificationSettingsInputObject) throws ApiException {
        com.squareup.okhttp.Call call = updateChatDesktopNotificationSettingsValidateBeforeCall(updateChatDesktopNotificationSettingsInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Update chat desktop notification settings (asynchronously)
     * 
     * @param updateChatDesktopNotificationSettingsInputObject  (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 updateChatDesktopNotificationSettingsAsync(UpdateChatDesktopNotificationSettingsInputObject updateChatDesktopNotificationSettingsInputObject, final ApiCallback 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 = updateChatDesktopNotificationSettingsValidateBeforeCall(updateChatDesktopNotificationSettingsInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for updateContact
     * @param updateContactInputObject  (required)
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call updateContactCall(UpdateContactInputObject updateContactInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = updateContactInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/{id}/normalized"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call updateContactValidateBeforeCall(UpdateContactInputObject updateContactInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'updateContactInputObject' is set
        if (updateContactInputObject == null) {
            throw new ApiException("Missing the required parameter 'updateContactInputObject' when calling updateContact(Async)");
        }
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling updateContact(Async)");
        }
        

        com.squareup.okhttp.Call call = updateContactCall(updateContactInputObject, id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Edit a contact
     * 
     * @param updateContactInputObject  (required)
     * @param id  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse updateContact(UpdateContactInputObject updateContactInputObject, Integer id) throws ApiException {
        ApiResponse resp = updateContactWithHttpInfo(updateContactInputObject, id);
        return resp.getData();
    }

    /**
     * Edit a contact
     * 
     * @param updateContactInputObject  (required)
     * @param id  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse updateContactWithHttpInfo(UpdateContactInputObject updateContactInputObject, Integer id) throws ApiException {
        com.squareup.okhttp.Call call = updateContactValidateBeforeCall(updateContactInputObject, id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Edit a contact (asynchronously)
     * 
     * @param updateContactInputObject  (required)
     * @param 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 updateContactAsync(UpdateContactInputObject updateContactInputObject, Integer id, final ApiCallback 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 = updateContactValidateBeforeCall(updateContactInputObject, id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for updateContactNote
     * @param updateContactNoteInputObject  (required)
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call updateContactNoteCall(UpdateContactNoteInputObject updateContactNoteInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = updateContactNoteInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/notes/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call updateContactNoteValidateBeforeCall(UpdateContactNoteInputObject updateContactNoteInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'updateContactNoteInputObject' is set
        if (updateContactNoteInputObject == null) {
            throw new ApiException("Missing the required parameter 'updateContactNoteInputObject' when calling updateContactNote(Async)");
        }
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling updateContactNote(Async)");
        }
        

        com.squareup.okhttp.Call call = updateContactNoteCall(updateContactNoteInputObject, id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Update a contact note
     * 
     * @param updateContactNoteInputObject  (required)
     * @param id  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse updateContactNote(UpdateContactNoteInputObject updateContactNoteInputObject, Integer id) throws ApiException {
        ApiResponse resp = updateContactNoteWithHttpInfo(updateContactNoteInputObject, id);
        return resp.getData();
    }

    /**
     * Update a contact note
     * 
     * @param updateContactNoteInputObject  (required)
     * @param id  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse updateContactNoteWithHttpInfo(UpdateContactNoteInputObject updateContactNoteInputObject, Integer id) throws ApiException {
        com.squareup.okhttp.Call call = updateContactNoteValidateBeforeCall(updateContactNoteInputObject, id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Update a contact note (asynchronously)
     * 
     * @param updateContactNoteInputObject  (required)
     * @param 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 updateContactNoteAsync(UpdateContactNoteInputObject updateContactNoteInputObject, Integer id, final ApiCallback 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 = updateContactNoteValidateBeforeCall(updateContactNoteInputObject, id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for updateCurrentUser
     * @param updateCurrentUserInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call updateCurrentUserCall(UpdateCurrentUserInputObject updateCurrentUserInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = updateCurrentUserInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/user";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call updateCurrentUserValidateBeforeCall(UpdateCurrentUserInputObject updateCurrentUserInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'updateCurrentUserInputObject' is set
        if (updateCurrentUserInputObject == null) {
            throw new ApiException("Missing the required parameter 'updateCurrentUserInputObject' when calling updateCurrentUser(Async)");
        }
        

        com.squareup.okhttp.Call call = updateCurrentUserCall(updateCurrentUserInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Edit current account info
     * 
     * @param updateCurrentUserInputObject  (required)
     * @return UpdateCurrentUserResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public UpdateCurrentUserResponse updateCurrentUser(UpdateCurrentUserInputObject updateCurrentUserInputObject) throws ApiException {
        ApiResponse resp = updateCurrentUserWithHttpInfo(updateCurrentUserInputObject);
        return resp.getData();
    }

    /**
     * Edit current account info
     * 
     * @param updateCurrentUserInputObject  (required)
     * @return ApiResponse<UpdateCurrentUserResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse updateCurrentUserWithHttpInfo(UpdateCurrentUserInputObject updateCurrentUserInputObject) throws ApiException {
        com.squareup.okhttp.Call call = updateCurrentUserValidateBeforeCall(updateCurrentUserInputObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Edit current account info (asynchronously)
     * 
     * @param updateCurrentUserInputObject  (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 updateCurrentUserAsync(UpdateCurrentUserInputObject updateCurrentUserInputObject, final ApiCallback 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 = updateCurrentUserValidateBeforeCall(updateCurrentUserInputObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for updateCustomField
     * @param updateCustomFieldInputObject  (required)
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call updateCustomFieldCall(UpdateCustomFieldInputObject updateCustomFieldInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = updateCustomFieldInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/customfields/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call updateCustomFieldValidateBeforeCall(UpdateCustomFieldInputObject updateCustomFieldInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'updateCustomFieldInputObject' is set
        if (updateCustomFieldInputObject == null) {
            throw new ApiException("Missing the required parameter 'updateCustomFieldInputObject' when calling updateCustomField(Async)");
        }
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling updateCustomField(Async)");
        }
        

        com.squareup.okhttp.Call call = updateCustomFieldCall(updateCustomFieldInputObject, id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Edit a custom field
     * 
     * @param updateCustomFieldInputObject  (required)
     * @param id  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse updateCustomField(UpdateCustomFieldInputObject updateCustomFieldInputObject, Integer id) throws ApiException {
        ApiResponse resp = updateCustomFieldWithHttpInfo(updateCustomFieldInputObject, id);
        return resp.getData();
    }

    /**
     * Edit a custom field
     * 
     * @param updateCustomFieldInputObject  (required)
     * @param id  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse updateCustomFieldWithHttpInfo(UpdateCustomFieldInputObject updateCustomFieldInputObject, Integer id) throws ApiException {
        com.squareup.okhttp.Call call = updateCustomFieldValidateBeforeCall(updateCustomFieldInputObject, id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Edit a custom field (asynchronously)
     * 
     * @param updateCustomFieldInputObject  (required)
     * @param 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 updateCustomFieldAsync(UpdateCustomFieldInputObject updateCustomFieldInputObject, Integer id, final ApiCallback 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 = updateCustomFieldValidateBeforeCall(updateCustomFieldInputObject, id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for updateCustomFieldValue
     * @param updateCustomFieldValueInputObject  (required)
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call updateCustomFieldValueCall(UpdateCustomFieldValueInputObject updateCustomFieldValueInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = updateCustomFieldValueInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/customfields/{id}/update"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call updateCustomFieldValueValidateBeforeCall(UpdateCustomFieldValueInputObject updateCustomFieldValueInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'updateCustomFieldValueInputObject' is set
        if (updateCustomFieldValueInputObject == null) {
            throw new ApiException("Missing the required parameter 'updateCustomFieldValueInputObject' when calling updateCustomFieldValue(Async)");
        }
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling updateCustomFieldValue(Async)");
        }
        

        com.squareup.okhttp.Call call = updateCustomFieldValueCall(updateCustomFieldValueInputObject, id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Edit the custom field value of a specified contact
     * 
     * @param updateCustomFieldValueInputObject  (required)
     * @param id  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse updateCustomFieldValue(UpdateCustomFieldValueInputObject updateCustomFieldValueInputObject, Integer id) throws ApiException {
        ApiResponse resp = updateCustomFieldValueWithHttpInfo(updateCustomFieldValueInputObject, id);
        return resp.getData();
    }

    /**
     * Edit the custom field value of a specified contact
     * 
     * @param updateCustomFieldValueInputObject  (required)
     * @param id  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse updateCustomFieldValueWithHttpInfo(UpdateCustomFieldValueInputObject updateCustomFieldValueInputObject, Integer id) throws ApiException {
        com.squareup.okhttp.Call call = updateCustomFieldValueValidateBeforeCall(updateCustomFieldValueInputObject, id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Edit the custom field value of a specified contact (asynchronously)
     * 
     * @param updateCustomFieldValueInputObject  (required)
     * @param 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 updateCustomFieldValueAsync(UpdateCustomFieldValueInputObject updateCustomFieldValueInputObject, Integer id, final ApiCallback 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 = updateCustomFieldValueValidateBeforeCall(updateCustomFieldValueInputObject, id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for updateInboundMessagesNotificationSettings
     * @param updateInboundMessagesNotificationSettingsInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call updateInboundMessagesNotificationSettingsCall(UpdateInboundMessagesNotificationSettingsInputObject updateInboundMessagesNotificationSettingsInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = updateInboundMessagesNotificationSettingsInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/user/notification/inbound";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call updateInboundMessagesNotificationSettingsValidateBeforeCall(UpdateInboundMessagesNotificationSettingsInputObject updateInboundMessagesNotificationSettingsInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'updateInboundMessagesNotificationSettingsInputObject' is set
        if (updateInboundMessagesNotificationSettingsInputObject == null) {
            throw new ApiException("Missing the required parameter 'updateInboundMessagesNotificationSettingsInputObject' when calling updateInboundMessagesNotificationSettings(Async)");
        }
        

        com.squareup.okhttp.Call call = updateInboundMessagesNotificationSettingsCall(updateInboundMessagesNotificationSettingsInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Update inbound messages notification settings
     * 
     * @param updateInboundMessagesNotificationSettingsInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void updateInboundMessagesNotificationSettings(UpdateInboundMessagesNotificationSettingsInputObject updateInboundMessagesNotificationSettingsInputObject) throws ApiException {
        updateInboundMessagesNotificationSettingsWithHttpInfo(updateInboundMessagesNotificationSettingsInputObject);
    }

    /**
     * Update inbound messages notification settings
     * 
     * @param updateInboundMessagesNotificationSettingsInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse updateInboundMessagesNotificationSettingsWithHttpInfo(UpdateInboundMessagesNotificationSettingsInputObject updateInboundMessagesNotificationSettingsInputObject) throws ApiException {
        com.squareup.okhttp.Call call = updateInboundMessagesNotificationSettingsValidateBeforeCall(updateInboundMessagesNotificationSettingsInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Update inbound messages notification settings (asynchronously)
     * 
     * @param updateInboundMessagesNotificationSettingsInputObject  (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 updateInboundMessagesNotificationSettingsAsync(UpdateInboundMessagesNotificationSettingsInputObject updateInboundMessagesNotificationSettingsInputObject, final ApiCallback 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 = updateInboundMessagesNotificationSettingsValidateBeforeCall(updateInboundMessagesNotificationSettingsInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for updateList
     * @param id  (required)
     * @param updateListObject  (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call updateListCall(Integer id, UpdateListObject updateListObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = updateListObject;

        // create path and map variables
        String localVarPath = "/api/v2/lists/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call updateListValidateBeforeCall(Integer id, UpdateListObject updateListObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling updateList(Async)");
        }
        

        com.squareup.okhttp.Call call = updateListCall(id, updateListObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Edit a list
     * 
     * @param id  (required)
     * @param updateListObject  (optional)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse updateList(Integer id, UpdateListObject updateListObject) throws ApiException {
        ApiResponse resp = updateListWithHttpInfo(id, updateListObject);
        return resp.getData();
    }

    /**
     * Edit a list
     * 
     * @param id  (required)
     * @param updateListObject  (optional)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse updateListWithHttpInfo(Integer id, UpdateListObject updateListObject) throws ApiException {
        com.squareup.okhttp.Call call = updateListValidateBeforeCall(id, updateListObject, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Edit a list (asynchronously)
     * 
     * @param id  (required)
     * @param updateListObject  (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 updateListAsync(Integer id, UpdateListObject updateListObject, final ApiCallback 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 = updateListValidateBeforeCall(id, updateListObject, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for updateSenderSetting
     * @param updateSenderSettingInputObject  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call updateSenderSettingCall(UpdateSenderSettingInputObject updateSenderSettingInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = updateSenderSettingInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/sender/settings";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call updateSenderSettingValidateBeforeCall(UpdateSenderSettingInputObject updateSenderSettingInputObject, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'updateSenderSettingInputObject' is set
        if (updateSenderSettingInputObject == null) {
            throw new ApiException("Missing the required parameter 'updateSenderSettingInputObject' when calling updateSenderSetting(Async)");
        }
        

        com.squareup.okhttp.Call call = updateSenderSettingCall(updateSenderSettingInputObject, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Change sender settings
     * 
     * @param updateSenderSettingInputObject  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void updateSenderSetting(UpdateSenderSettingInputObject updateSenderSettingInputObject) throws ApiException {
        updateSenderSettingWithHttpInfo(updateSenderSettingInputObject);
    }

    /**
     * Change sender settings
     * 
     * @param updateSenderSettingInputObject  (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse updateSenderSettingWithHttpInfo(UpdateSenderSettingInputObject updateSenderSettingInputObject) throws ApiException {
        com.squareup.okhttp.Call call = updateSenderSettingValidateBeforeCall(updateSenderSettingInputObject, null, null);
        return apiClient.execute(call);
    }

    /**
     * Change sender settings (asynchronously)
     * 
     * @param updateSenderSettingInputObject  (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 updateSenderSettingAsync(UpdateSenderSettingInputObject updateSenderSettingInputObject, final ApiCallback 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 = updateSenderSettingValidateBeforeCall(updateSenderSettingInputObject, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for updateTemplate
     * @param updateTemplateInputObject  (required)
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call updateTemplateCall(UpdateTemplateInputObject updateTemplateInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = updateTemplateInputObject;

        // create path and map variables
        String localVarPath = "/api/v2/templates/{id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call updateTemplateValidateBeforeCall(UpdateTemplateInputObject updateTemplateInputObject, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'updateTemplateInputObject' is set
        if (updateTemplateInputObject == null) {
            throw new ApiException("Missing the required parameter 'updateTemplateInputObject' when calling updateTemplate(Async)");
        }
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling updateTemplate(Async)");
        }
        

        com.squareup.okhttp.Call call = updateTemplateCall(updateTemplateInputObject, id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Update a template
     * 
     * @param updateTemplateInputObject  (required)
     * @param id  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse updateTemplate(UpdateTemplateInputObject updateTemplateInputObject, Integer id) throws ApiException {
        ApiResponse resp = updateTemplateWithHttpInfo(updateTemplateInputObject, id);
        return resp.getData();
    }

    /**
     * Update a template
     * 
     * @param updateTemplateInputObject  (required)
     * @param id  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse updateTemplateWithHttpInfo(UpdateTemplateInputObject updateTemplateInputObject, Integer id) throws ApiException {
        com.squareup.okhttp.Call call = updateTemplateValidateBeforeCall(updateTemplateInputObject, id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Update a template (asynchronously)
     * 
     * @param updateTemplateInputObject  (required)
     * @param 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 updateTemplateAsync(UpdateTemplateInputObject updateTemplateInputObject, Integer id, final ApiCallback 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 = updateTemplateValidateBeforeCall(updateTemplateInputObject, id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for uploadAvatar
     * @param image User avatar. Should be a PNG or JPG file not more than 10 MB. (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call uploadAvatarCall(File image, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/user/avatar";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();
        if (image != null)
        localVarFormParams.put("image", image);

        final String[] localVarAccepts = {
            "application/json"
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call uploadAvatarValidateBeforeCall(File image, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'image' is set
        if (image == null) {
            throw new ApiException("Missing the required parameter 'image' when calling uploadAvatar(Async)");
        }
        

        com.squareup.okhttp.Call call = uploadAvatarCall(image, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Upload an avatar
     * 
     * @param image User avatar. Should be a PNG or JPG file not more than 10 MB. (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void uploadAvatar(File image) throws ApiException {
        uploadAvatarWithHttpInfo(image);
    }

    /**
     * Upload an avatar
     * 
     * @param image User avatar. Should be a PNG or JPG file not more than 10 MB. (required)
     * @return ApiResponse<Void>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse uploadAvatarWithHttpInfo(File image) throws ApiException {
        com.squareup.okhttp.Call call = uploadAvatarValidateBeforeCall(image, null, null);
        return apiClient.execute(call);
    }

    /**
     * Upload an avatar (asynchronously)
     * 
     * @param image User avatar. Should be a PNG or JPG file not more than 10 MB. (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 uploadAvatarAsync(File image, final ApiCallback 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 = uploadAvatarValidateBeforeCall(image, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for uploadContactAvatar
     * @param image Contact avatar. Should be a PNG or JPG file not more than 10 MB. (required)
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call uploadContactAvatarCall(File image, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/contacts/{id}/avatar"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();
        if (image != null)
        localVarFormParams.put("image", image);

        final String[] localVarAccepts = {
            "application/json"
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call uploadContactAvatarValidateBeforeCall(File image, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'image' is set
        if (image == null) {
            throw new ApiException("Missing the required parameter 'image' when calling uploadContactAvatar(Async)");
        }
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling uploadContactAvatar(Async)");
        }
        

        com.squareup.okhttp.Call call = uploadContactAvatarCall(image, id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Upload an avatar
     * 
     * @param image Contact avatar. Should be a PNG or JPG file not more than 10 MB. (required)
     * @param id  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse uploadContactAvatar(File image, Integer id) throws ApiException {
        ApiResponse resp = uploadContactAvatarWithHttpInfo(image, id);
        return resp.getData();
    }

    /**
     * Upload an avatar
     * 
     * @param image Contact avatar. Should be a PNG or JPG file not more than 10 MB. (required)
     * @param id  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse uploadContactAvatarWithHttpInfo(File image, Integer id) throws ApiException {
        com.squareup.okhttp.Call call = uploadContactAvatarValidateBeforeCall(image, id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Upload an avatar (asynchronously)
     * 
     * @param image Contact avatar. Should be a PNG or JPG file not more than 10 MB. (required)
     * @param 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 uploadContactAvatarAsync(File image, Integer id, final ApiCallback 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 = uploadContactAvatarValidateBeforeCall(image, id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for uploadListAvatar
     * @param image List avatar. Should be a PNG or JPG file not more than 10 MB. (required)
     * @param id  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call uploadListAvatarCall(File image, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/lists/{id}/avatar"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();
        if (image != null)
        localVarFormParams.put("image", image);

        final String[] localVarAccepts = {
            "application/json"
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call uploadListAvatarValidateBeforeCall(File image, Integer id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'image' is set
        if (image == null) {
            throw new ApiException("Missing the required parameter 'image' when calling uploadListAvatar(Async)");
        }
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling uploadListAvatar(Async)");
        }
        

        com.squareup.okhttp.Call call = uploadListAvatarCall(image, id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Add an avatar for a list
     * Add an avatar for a list
     * @param image List avatar. Should be a PNG or JPG file not more than 10 MB. (required)
     * @param id  (required)
     * @return ResourceLinkResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourceLinkResponse uploadListAvatar(File image, Integer id) throws ApiException {
        ApiResponse resp = uploadListAvatarWithHttpInfo(image, id);
        return resp.getData();
    }

    /**
     * Add an avatar for a list
     * Add an avatar for a list
     * @param image List avatar. Should be a PNG or JPG file not more than 10 MB. (required)
     * @param id  (required)
     * @return ApiResponse<ResourceLinkResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse uploadListAvatarWithHttpInfo(File image, Integer id) throws ApiException {
        com.squareup.okhttp.Call call = uploadListAvatarValidateBeforeCall(image, id, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Add an avatar for a list (asynchronously)
     * Add an avatar for a list
     * @param image List avatar. Should be a PNG or JPG file not more than 10 MB. (required)
     * @param 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 uploadListAvatarAsync(File image, Integer id, final ApiCallback 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 = uploadListAvatarValidateBeforeCall(image, id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for uploadMessageAttachment
     * @param file Attachment. Supports .jpg, .gif, .png, .pdf, .txt, .csv, .doc, .docx, .xls, .xlsx, .ppt, .pptx & .vcf file formats. (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call uploadMessageAttachmentCall(File file, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/api/v2/messages/attachment";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();

        Map localVarFormParams = new HashMap();
        if (file != null)
        localVarFormParams.put("file", file);

        final String[] localVarAccepts = {
            "application/json"
        };
        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[] { "BasicAuth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call uploadMessageAttachmentValidateBeforeCall(File file, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'file' is set
        if (file == null) {
            throw new ApiException("Missing the required parameter 'file' when calling uploadMessageAttachment(Async)");
        }
        

        com.squareup.okhttp.Call call = uploadMessageAttachmentCall(file, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Upload message attachment
     * Upload a new file to insert it as a link.
     * @param file Attachment. Supports .jpg, .gif, .png, .pdf, .txt, .csv, .doc, .docx, .xls, .xlsx, .ppt, .pptx & .vcf file formats. (required)
     * @return UploadMessageAttachmentResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public UploadMessageAttachmentResponse uploadMessageAttachment(File file) throws ApiException {
        ApiResponse resp = uploadMessageAttachmentWithHttpInfo(file);
        return resp.getData();
    }

    /**
     * Upload message attachment
     * Upload a new file to insert it as a link.
     * @param file Attachment. Supports .jpg, .gif, .png, .pdf, .txt, .csv, .doc, .docx, .xls, .xlsx, .ppt, .pptx & .vcf file formats. (required)
     * @return ApiResponse<UploadMessageAttachmentResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse uploadMessageAttachmentWithHttpInfo(File file) throws ApiException {
        com.squareup.okhttp.Call call = uploadMessageAttachmentValidateBeforeCall(file, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Upload message attachment (asynchronously)
     * Upload a new file to insert it as a link.
     * @param file Attachment. Supports .jpg, .gif, .png, .pdf, .txt, .csv, .doc, .docx, .xls, .xlsx, .ppt, .pptx & .vcf file formats. (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 uploadMessageAttachmentAsync(File file, final ApiCallback 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 = uploadMessageAttachmentValidateBeforeCall(file, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy