com.criteo.marketing.api.AudiencesApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marketing.java-client Show documentation
Show all versions of marketing.java-client Show documentation
Criteo Marketing SDK for Java
/*
* 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