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

com.criteo.marketing.api.AudiencesApi Maven / Gradle / Ivy

There is a newer version: 1.0.28
Show newest version
/*
 * Marketing API v.1.0
 * IMPORTANT: This swagger links to Criteo production environment. Any test applied here will thus impact real campaigns.
 *
 * OpenAPI spec version: v.1.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package com.criteo.marketing.api;

import com.criteo.marketing.ApiCallback;
import com.criteo.marketing.ApiClient;
import com.criteo.marketing.ApiException;
import com.criteo.marketing.ApiResponse;
import com.criteo.marketing.Configuration;
import com.criteo.marketing.Pair;
import com.criteo.marketing.ProgressRequestBody;
import com.criteo.marketing.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import com.criteo.marketing.model.AudienceCreateRequest;
import com.criteo.marketing.model.AudienceCreateResponse;
import com.criteo.marketing.model.AudiencePatchRequest;
import com.criteo.marketing.model.AudiencePatchResponse;
import com.criteo.marketing.model.AudiencePutRequest;
import com.criteo.marketing.model.AudiencesGetResponse;

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

public class AudiencesApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for addRemoveUsersToAudience
     * @param audienceId Mandatory. The id of the audience to add or remove users to. (required)
     * @param authorization JWT Bearer Token (required)
     * @param request Mandatory. The request to create the Audience. (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 okhttp3.Call addRemoveUsersToAudienceCall(Integer audienceId, String authorization, AudiencePatchRequest request, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = request;

        // create path and map variables
        String localVarPath = "/v1/audiences/userlist/{audienceId}"
            .replaceAll("\\{" + "audienceId" + "\\}", apiClient.escapeString(audienceId.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();
        if (authorization != null) {
            localVarHeaderParams.put("Authorization", apiClient.parameterToString(authorization));
        }

        Map localVarFormParams = new HashMap();
        final String[] localVarAccepts = {
            "application/json", "text/json", "application/xml", "text/xml", "text/html"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            "application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded", "text/html"
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if (progressListener != null) {
            apiClient.setHttpClient(apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                            .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                            .build();
                }
            }).build());
        }

        String[] localVarAuthNames = new String[] { "Authorization" };
        return apiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call addRemoveUsersToAudienceValidateBeforeCall(Integer audienceId, String authorization, AudiencePatchRequest request, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'audienceId' is set
        if (audienceId == null) {
            throw new ApiException("Missing the required parameter 'audienceId' when calling addRemoveUsersToAudience(Async)");
        }
        
        // verify the required parameter 'authorization' is set
        if (authorization == null) {
            throw new ApiException("Missing the required parameter 'authorization' when calling addRemoveUsersToAudience(Async)");
        }
        
        // verify the required parameter 'request' is set
        if (request == null) {
            throw new ApiException("Missing the required parameter 'request' when calling addRemoveUsersToAudience(Async)");
        }
        

        okhttp3.Call call = addRemoveUsersToAudienceCall(audienceId, authorization, request, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Add/Remove users to an Audience.
     * Add/Remove users to an Audience.
     * @param audienceId Mandatory. The id of the audience to add or remove users to. (required)
     * @param authorization JWT Bearer Token (required)
     * @param request Mandatory. The request to create the Audience. (required)
     * @return AudiencePatchResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public AudiencePatchResponse addRemoveUsersToAudience(Integer audienceId, String authorization, AudiencePatchRequest request) throws ApiException {
        ApiResponse resp = addRemoveUsersToAudienceWithHttpInfo(audienceId, authorization, request);
        return resp.getData();
    }

    /**
     * Add/Remove users to an Audience.
     * Add/Remove users to an Audience.
     * @param audienceId Mandatory. The id of the audience to add or remove users to. (required)
     * @param authorization JWT Bearer Token (required)
     * @param request Mandatory. The request to create the Audience. (required)
     * @return ApiResponse<AudiencePatchResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse addRemoveUsersToAudienceWithHttpInfo(Integer audienceId, String authorization, AudiencePatchRequest request) throws ApiException {
        okhttp3.Call call = addRemoveUsersToAudienceValidateBeforeCall(audienceId, authorization, request, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Add/Remove users to an Audience. (asynchronously)
     * Add/Remove users to an Audience.
     * @param audienceId Mandatory. The id of the audience to add or remove users to. (required)
     * @param authorization JWT Bearer Token (required)
     * @param request Mandatory. The request to create the Audience. (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 okhttp3.Call addRemoveUsersToAudienceAsync(Integer audienceId, String authorization, AudiencePatchRequest request, 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);
                }
            };
        }

        okhttp3.Call call = addRemoveUsersToAudienceValidateBeforeCall(audienceId, authorization, request, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for createAudience
     * @param authorization JWT Bearer Token (required)
     * @param createRequest  (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 okhttp3.Call createAudienceCall(String authorization, AudienceCreateRequest createRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = createRequest;

        // create path and map variables
        String localVarPath = "/v1/audiences/userlist";

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();
        if (authorization != null) {
            localVarHeaderParams.put("Authorization", apiClient.parameterToString(authorization));
        }

        Map localVarFormParams = new HashMap();
        final String[] localVarAccepts = {
            "application/json", "text/json", "application/xml", "text/xml", "text/html"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            "application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded", "text/html"
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if (progressListener != null) {
            apiClient.setHttpClient(apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                            .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                            .build();
                }
            }).build());
        }

        String[] localVarAuthNames = new String[] { "Authorization" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call createAudienceValidateBeforeCall(String authorization, AudienceCreateRequest createRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'authorization' is set
        if (authorization == null) {
            throw new ApiException("Missing the required parameter 'authorization' when calling createAudience(Async)");
        }
        
        // verify the required parameter 'createRequest' is set
        if (createRequest == null) {
            throw new ApiException("Missing the required parameter 'createRequest' when calling createAudience(Async)");
        }
        

        okhttp3.Call call = createAudienceCall(authorization, createRequest, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Create a new Audience.
     * Create a new Audience for the given Advertiser.
     * @param authorization JWT Bearer Token (required)
     * @param createRequest  (required)
     * @return AudienceCreateResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public AudienceCreateResponse createAudience(String authorization, AudienceCreateRequest createRequest) throws ApiException {
        ApiResponse resp = createAudienceWithHttpInfo(authorization, createRequest);
        return resp.getData();
    }

    /**
     * Create a new Audience.
     * Create a new Audience for the given Advertiser.
     * @param authorization JWT Bearer Token (required)
     * @param createRequest  (required)
     * @return ApiResponse<AudienceCreateResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse createAudienceWithHttpInfo(String authorization, AudienceCreateRequest createRequest) throws ApiException {
        okhttp3.Call call = createAudienceValidateBeforeCall(authorization, createRequest, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Create a new Audience. (asynchronously)
     * Create a new Audience for the given Advertiser.
     * @param authorization JWT Bearer Token (required)
     * @param createRequest  (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 okhttp3.Call createAudienceAsync(String authorization, AudienceCreateRequest createRequest, 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);
                }
            };
        }

        okhttp3.Call call = createAudienceValidateBeforeCall(authorization, createRequest, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for deleteAudience
     * @param audienceId Mandatory. The id of the audience to delete. (required)
     * @param authorization JWT Bearer Token (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 okhttp3.Call deleteAudienceCall(Integer audienceId, String authorization, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = new Object();

        // create path and map variables
        String localVarPath = "/v1/audiences/{audienceId}"
            .replaceAll("\\{" + "audienceId" + "\\}", apiClient.escapeString(audienceId.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();
        if (authorization != null) {
            localVarHeaderParams.put("Authorization", apiClient.parameterToString(authorization));
        }

        Map localVarFormParams = new HashMap();
        final String[] localVarAccepts = {
            "application/json", "text/json", "application/xml", "text/xml", "text/html"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if (progressListener != null) {
            apiClient.setHttpClient(apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                            .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                            .build();
                }
            }).build());
        }

        String[] localVarAuthNames = new String[] { "Authorization" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call deleteAudienceValidateBeforeCall(Integer audienceId, String authorization, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'audienceId' is set
        if (audienceId == null) {
            throw new ApiException("Missing the required parameter 'audienceId' when calling deleteAudience(Async)");
        }
        
        // verify the required parameter 'authorization' is set
        if (authorization == null) {
            throw new ApiException("Missing the required parameter 'authorization' when calling deleteAudience(Async)");
        }
        

        okhttp3.Call call = deleteAudienceCall(audienceId, authorization, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete an Audience.
     * Delete an Audience.
     * @param audienceId Mandatory. The id of the audience to delete. (required)
     * @param authorization JWT Bearer Token (required)
     * @return Object
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Object deleteAudience(Integer audienceId, String authorization) throws ApiException {
        ApiResponse resp = deleteAudienceWithHttpInfo(audienceId, authorization);
        return resp.getData();
    }

    /**
     * Delete an Audience.
     * Delete an Audience.
     * @param audienceId Mandatory. The id of the audience to delete. (required)
     * @param authorization JWT Bearer Token (required)
     * @return ApiResponse<Object>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse deleteAudienceWithHttpInfo(Integer audienceId, String authorization) throws ApiException {
        okhttp3.Call call = deleteAudienceValidateBeforeCall(audienceId, authorization, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Delete an Audience. (asynchronously)
     * Delete an Audience.
     * @param audienceId Mandatory. The id of the audience to delete. (required)
     * @param authorization JWT Bearer Token (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 okhttp3.Call deleteAudienceAsync(Integer audienceId, String authorization, 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);
                }
            };
        }

        okhttp3.Call call = deleteAudienceValidateBeforeCall(audienceId, authorization, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getAudiences
     * @param authorization JWT Bearer Token (required)
     * @param advertiserId Mandatory. Advertiser to get all Audiences for. (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 okhttp3.Call getAudiencesCall(String authorization, Integer advertiserId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = new Object();

        // create path and map variables
        String localVarPath = "/v1/audiences";

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

        Map localVarHeaderParams = new HashMap();
        if (authorization != null) {
            localVarHeaderParams.put("Authorization", apiClient.parameterToString(authorization));
        }

        Map localVarFormParams = new HashMap();
        final String[] localVarAccepts = {
            "application/json", "text/json", "application/xml", "text/xml", "text/html"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if (progressListener != null) {
            apiClient.setHttpClient(apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                            .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                            .build();
                }
            }).build());
        }

        String[] localVarAuthNames = new String[] { "Authorization" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getAudiencesValidateBeforeCall(String authorization, Integer advertiserId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'authorization' is set
        if (authorization == null) {
            throw new ApiException("Missing the required parameter 'authorization' when calling getAudiences(Async)");
        }
        

        okhttp3.Call call = getAudiencesCall(authorization, advertiserId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get the list of Audiences.
     * Get the list of Audiences for the given Advertiser.
     * @param authorization JWT Bearer Token (required)
     * @param advertiserId Mandatory. Advertiser to get all Audiences for. (optional)
     * @return AudiencesGetResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public AudiencesGetResponse getAudiences(String authorization, Integer advertiserId) throws ApiException {
        ApiResponse resp = getAudiencesWithHttpInfo(authorization, advertiserId);
        return resp.getData();
    }

    /**
     * Get the list of Audiences.
     * Get the list of Audiences for the given Advertiser.
     * @param authorization JWT Bearer Token (required)
     * @param advertiserId Mandatory. Advertiser to get all Audiences for. (optional)
     * @return ApiResponse<AudiencesGetResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse getAudiencesWithHttpInfo(String authorization, Integer advertiserId) throws ApiException {
        okhttp3.Call call = getAudiencesValidateBeforeCall(authorization, advertiserId, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the list of Audiences. (asynchronously)
     * Get the list of Audiences for the given Advertiser.
     * @param authorization JWT Bearer Token (required)
     * @param advertiserId Mandatory. Advertiser to get all Audiences for. (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 okhttp3.Call getAudiencesAsync(String authorization, Integer advertiserId, 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);
                }
            };
        }

        okhttp3.Call call = getAudiencesValidateBeforeCall(authorization, advertiserId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for removeUsersFromAudience
     * @param audienceId Mandatory. The id of the audience to empty. (required)
     * @param authorization JWT Bearer Token (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 okhttp3.Call removeUsersFromAudienceCall(Integer audienceId, String authorization, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = new Object();

        // create path and map variables
        String localVarPath = "/v1/audiences/userlist/{audienceId}/users"
            .replaceAll("\\{" + "audienceId" + "\\}", apiClient.escapeString(audienceId.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();
        if (authorization != null) {
            localVarHeaderParams.put("Authorization", apiClient.parameterToString(authorization));
        }

        Map localVarFormParams = new HashMap();
        final String[] localVarAccepts = {
            "application/json", "text/json", "application/xml", "text/xml", "text/html"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if (progressListener != null) {
            apiClient.setHttpClient(apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                            .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                            .build();
                }
            }).build());
        }

        String[] localVarAuthNames = new String[] { "Authorization" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call removeUsersFromAudienceValidateBeforeCall(Integer audienceId, String authorization, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'audienceId' is set
        if (audienceId == null) {
            throw new ApiException("Missing the required parameter 'audienceId' when calling removeUsersFromAudience(Async)");
        }
        
        // verify the required parameter 'authorization' is set
        if (authorization == null) {
            throw new ApiException("Missing the required parameter 'authorization' when calling removeUsersFromAudience(Async)");
        }
        

        okhttp3.Call call = removeUsersFromAudienceCall(audienceId, authorization, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Remove all users from an Audience.
     * Remove all users from an Audience.
     * @param audienceId Mandatory. The id of the audience to empty. (required)
     * @param authorization JWT Bearer Token (required)
     * @return Object
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Object removeUsersFromAudience(Integer audienceId, String authorization) throws ApiException {
        ApiResponse resp = removeUsersFromAudienceWithHttpInfo(audienceId, authorization);
        return resp.getData();
    }

    /**
     * Remove all users from an Audience.
     * Remove all users from an Audience.
     * @param audienceId Mandatory. The id of the audience to empty. (required)
     * @param authorization JWT Bearer Token (required)
     * @return ApiResponse<Object>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse removeUsersFromAudienceWithHttpInfo(Integer audienceId, String authorization) throws ApiException {
        okhttp3.Call call = removeUsersFromAudienceValidateBeforeCall(audienceId, authorization, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Remove all users from an Audience. (asynchronously)
     * Remove all users from an Audience.
     * @param audienceId Mandatory. The id of the audience to empty. (required)
     * @param authorization JWT Bearer Token (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 okhttp3.Call removeUsersFromAudienceAsync(Integer audienceId, String authorization, 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);
                }
            };
        }

        okhttp3.Call call = removeUsersFromAudienceValidateBeforeCall(audienceId, authorization, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for updateAudienceMetadata
     * @param audienceId Mandatory. The id of the Audience to update. (required)
     * @param authorization JWT Bearer Token (required)
     * @param request Mandatory. The request to update the Audience metadata. (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 okhttp3.Call updateAudienceMetadataCall(Integer audienceId, String authorization, AudiencePutRequest request, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = request;

        // create path and map variables
        String localVarPath = "/v1/audiences/{audienceId}"
            .replaceAll("\\{" + "audienceId" + "\\}", apiClient.escapeString(audienceId.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();
        if (authorization != null) {
            localVarHeaderParams.put("Authorization", apiClient.parameterToString(authorization));
        }

        Map localVarFormParams = new HashMap();
        final String[] localVarAccepts = {
            "application/json", "text/json", "application/xml", "text/xml", "text/html"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            "application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded", "text/html"
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if (progressListener != null) {
            apiClient.setHttpClient(apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                            .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                            .build();
                }
            }).build());
        }

        String[] localVarAuthNames = new String[] { "Authorization" };
        return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call updateAudienceMetadataValidateBeforeCall(Integer audienceId, String authorization, AudiencePutRequest request, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'audienceId' is set
        if (audienceId == null) {
            throw new ApiException("Missing the required parameter 'audienceId' when calling updateAudienceMetadata(Async)");
        }
        
        // verify the required parameter 'authorization' is set
        if (authorization == null) {
            throw new ApiException("Missing the required parameter 'authorization' when calling updateAudienceMetadata(Async)");
        }
        
        // verify the required parameter 'request' is set
        if (request == null) {
            throw new ApiException("Missing the required parameter 'request' when calling updateAudienceMetadata(Async)");
        }
        

        okhttp3.Call call = updateAudienceMetadataCall(audienceId, authorization, request, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Update an Audience metadata.
     * Update an Audience metadata.
     * @param audienceId Mandatory. The id of the Audience to update. (required)
     * @param authorization JWT Bearer Token (required)
     * @param request Mandatory. The request to update the Audience metadata. (required)
     * @return Object
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Object updateAudienceMetadata(Integer audienceId, String authorization, AudiencePutRequest request) throws ApiException {
        ApiResponse resp = updateAudienceMetadataWithHttpInfo(audienceId, authorization, request);
        return resp.getData();
    }

    /**
     * Update an Audience metadata.
     * Update an Audience metadata.
     * @param audienceId Mandatory. The id of the Audience to update. (required)
     * @param authorization JWT Bearer Token (required)
     * @param request Mandatory. The request to update the Audience metadata. (required)
     * @return ApiResponse<Object>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse updateAudienceMetadataWithHttpInfo(Integer audienceId, String authorization, AudiencePutRequest request) throws ApiException {
        okhttp3.Call call = updateAudienceMetadataValidateBeforeCall(audienceId, authorization, request, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Update an Audience metadata. (asynchronously)
     * Update an Audience metadata.
     * @param audienceId Mandatory. The id of the Audience to update. (required)
     * @param authorization JWT Bearer Token (required)
     * @param request Mandatory. The request to update the Audience metadata. (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 okhttp3.Call updateAudienceMetadataAsync(Integer audienceId, String authorization, AudiencePutRequest request, 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);
                }
            };
        }

        okhttp3.Call call = updateAudienceMetadataValidateBeforeCall(audienceId, authorization, request, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}